📄 qizhidianname.java
字号:
package net.aetherial.gis.test.tools.pointName;
import org.w3c.dom.Node;
import java.util.Vector;
import java.util.Hashtable;
import java.util.Enumeration;
import net.aetherial.gis.surface.ItemValue;
import org.w3c.dom.NodeList;
import net.aetherial.gis.our.FrameOur;
import net.aetherial.gis.garmin.GarminGMLDoc;
import org.w3c.dom.Element;
import java.io.File;
import net.aetherial.gis.output.toLd.OpenDirectory;
import net.aetherial.gis.jiaotongbu.input.publicuse.ReFangxiang;
import net.aetherial.gis.jiaotongbu.input.jxl.ReadFangxiang;
import net.aetherial.gis.publicuse.track.ConcatenatedTrack;
/**
* <p>标题: 农村公路数据采集与核对工具</p>
*
* <p>描述: </p>
*
* <p>版权: Copyright (c) 2006</p>
*
* <p>公司: 安徽省通途信息技术公司</p>
*
* @author 王爱国
* @version 1.0
*/
public class QiZhiDianName {
private Vector wpts = new Vector();
public QiZhiDianName() {
}
private Node getNearstNode(Node trackpoint) {
if (trackpoint == null) {
System.out.println("trackpoint null");
return null;
}
if (wpts == null) {
System.out.println("wpts null");
}
double minDis = Double.MAX_VALUE, dis;
Node wpt = null,wptsNode = null;;
for (int i = 0; wpts != null && i < wpts.size(); i++) {
wptsNode = (Node)wpts.get(i);
dis = this.getDis(wptsNode, trackpoint);
// System.out.println("dis:" + dis + ",minDis:" + minDis);
if (dis < minDis) {
minDis = dis;
wpt = wptsNode;
// System.out.println(ItemValue.getWaypointName(wpt));
}
}
// System.out.println(ItemValue.getWaypointName(wpt)+"**********!");
// this.wpts.remove(wpt);
return wpt;
}
private double getDis(Node wpt, Node trackpoint) {
double w_x = Double.parseDouble(ItemValue.getWaypointX(wpt));
double w_y = Double.parseDouble(ItemValue.getWaypointY(wpt));
double tp_x = Double.parseDouble(ItemValue.getTracksPointX(trackpoint));
double tp_y = Double.parseDouble(ItemValue.getTracksPointY(trackpoint));
// System.out.println("w_x:"+ w_x + ",tp_x" + tp_x + ",w_x - tp_x:" + (tp_x - w_x));
// System.out.println("w_y:"+ w_y + ",tp_y" + tp_y + ",w_y - tp_y:" + (w_y - tp_y));
return Math.sqrt( (w_x - tp_x) * (w_x - tp_x) + (w_y - tp_y) * (w_y - tp_y));
}
public String getQidianName(Node track) {
NodeList nl = ItemValue.getTracksPoint(track);
if (nl != null) {
Node temp = this.getNearstNode(nl.item(0));
if (temp != null) {
return ItemValue.getWaypointName(temp);
}else{
System.out.println("Qidian == null");
}
}
return "";
}
public String getZhidianName(Node track) {
NodeList nl = ItemValue.getTracksPoint(track);
if (nl != null) {
Node temp = this.getNearstNode(nl.item(nl.getLength() - 1));
if (temp != null) {
return ItemValue.getWaypointName(temp);
}
}
return "";
}
public void setWpts(Node[] wpts) {
this.wpts.removeAllElements();
for (int i = 0; wpts != null && i < wpts.length; i++) {
this.wpts.add(wpts[i]);
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -