📄 wpttrackdistance.java
字号:
package net.aetherial.gis.publicuse;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
import net.aetherial.gis.surface.ItemValue;
/**
* <p>Title: </p>
*
* <p>Description: </p>
*
* <p>Copyright: Copyright (c) 2004</p>
*
* <p>Company: </p>
*
* @author not attributable
* @version 1.0
*/
public class WptTrackDistance {
public WptTrackDistance() {
}
/**
* 得到航点到指定线段的距离
* 返回的不是实际距离
*/
public static double getWptToTrackPointsDis(Node wpt,Node trackPoint1,Node trackPoint2){
if (wpt == null || trackPoint1 == null || trackPoint2 == null) {
return Double.MAX_VALUE;
}
PointLineDistance pd = new PointLineDistance();
pd.setPoint0(Double.parseDouble(ItemValue.getWaypointX(wpt)), Double.parseDouble(ItemValue.getWaypointY(wpt)));
pd.setPoint1(Double.parseDouble(ItemValue.getTracksPointX(trackPoint1)), Double.parseDouble(ItemValue.getTracksPointY(trackPoint1)));
pd.setPoint2(Double.parseDouble(ItemValue.getTracksPointX(trackPoint2)), Double.parseDouble(ItemValue.getTracksPointY(trackPoint2)));
return pd.getDis();
}
/**
* 得到航点到指定线段的距离
* 返回的不是实际距离
*/
public static double getWptToTrackDis(Node wpt,Node track){
if (wpt == null || track == null) {
return Double.MAX_VALUE;
}
NodeList nl = ItemValue.getTracksPoint(track);
if (nl == null) {
return Double.MAX_VALUE;
}
PointLineDistance pd;
double temp = Double.MAX_VALUE;
for (int i = 0; i < nl.getLength()-1; i++) {
pd = new PointLineDistance();
pd.setPoint0(Double.parseDouble(ItemValue.getWaypointX(wpt)),
Double.parseDouble(ItemValue.getWaypointY(wpt)));
pd.setPoint1(Double.parseDouble(ItemValue.getTracksPointX(nl.item(i))),
Double.parseDouble(ItemValue.getTracksPointY(nl.item(i))));
pd.setPoint2(Double.parseDouble(ItemValue.getTracksPointX(nl.item(i+1))),
Double.parseDouble(ItemValue.getTracksPointY(nl.item(i+1))));
temp = Math.min(temp,pd.getDis());
}
return temp;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -