📄 newlmtrack.java
字号:
package net.aetherial.gis.jiaotongbu.outputJTB.txtOutput.module.gpsdata.lxld.ld.
ldhf.lumian;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
import net.aetherial.gis.surface.ItemValue;
import java.util.*;
import java.util.Hashtable;
import net.aetherial.gis.jiaotongbu.outputJTB.txtOutput.module.gpsdata.lxld.ld.ldhf.TrackToLD;
import net.aetherial.gis.dataType.TrackType;
import net.aetherial.gis.publicuse.TrackOper;
import org.w3c.dom.Document;
import net.aetherial.gis.garmin.GarminGMLDoc;
import org.w3c.dom.Text;
import org.w3c.dom.Element;
/**
* <p>Title: </p>
*
* <p>Description: </p>
*
* <p>Copyright: Copyright (c) 2004</p>
*
* <p>Company: </p>
*
* @author not attributable
* @version 1.0
*/
public class NewLMTrack {
public NewLMTrack() {
}
/**
* 用路面变化点产生新的航迹
*/
public void createNewTrack(){
Node[] rsChange = this.getAllChageNode();
Node[] tracks = ItemValue.getTracks();
if (rsChange == null) {
return;
}
Vector trks = new Vector();
for (int i = 0; i < tracks.length; i++) {
trks.add(tracks[i]);
}
Vector tps = new Vector();
for (int i = 0; i < rsChange.length; i++) {
/**
* 得到路面变化点的航迹
* 1.相关联的航迹
* 2.距离最近的航迹
*/
// Node nearTrk = getNearstTrk(rsChange[i]);
// tps.add(getNearstTP(nearTrk, rsChange[i]));
}
TrackToLD.cutByTrackPoints(trks, tps);
}
/**
*删除掉重复的航点
*/
private String getNearstTrk(Node wpt){
Node trk = ItemValue.getWaypointHisTrack(wpt);
String trkName = "";
Enumeration keys = ItemValue.namedTracks.keys();
String[] tn = new String[ItemValue.namedTracks.size()];
int i=0;
while(keys.hasMoreElements()){
tn[i] = (String) keys.nextElement();
}
// if (trk != null) {
// return trk;
// }else{
//
return TrackOper.getTDTrackNearest(Double.parseDouble(ItemValue.getWaypointX(wpt)),Double.parseDouble(ItemValue.getWaypointX(wpt)),tn,1000);
// }
}
/**
* 得到最近的航迹点
*/
private Node getNearstTP(Node trk,Node wpt){
if (trk == null) {
return null;
}
NodeList nl = ItemValue.getTracksPoint(trk);
double dis = 0.0,minDis = 1000.0;
Node tp = null;
for (int i = 0; i < nl.getLength()-1; i++) {
Node nd1 = nl.item(i);
Node nd2 = nl.item(i + 1);
double x, y, z, x1, y1, z1, x2, y2, z2, x3, y3, z3, x4, y4, z4;
double A1, B1, C1, A2, B2, C2, A3, B3, C3, A4, B4, C4;
x1 = Double.parseDouble(ItemValue.getTracksPointX(nd1));
y1 = Double.parseDouble(ItemValue.getTracksPointY(nd1));
z1 = Double.parseDouble(ItemValue.getTracksPointZ(nd1));
x2 = Double.parseDouble(ItemValue.getTracksPointX(nd2));
y2 = Double.parseDouble(ItemValue.getTracksPointY(nd2));
z2 = Double.parseDouble(ItemValue.getTracksPointZ(nd2));
x3 = Double.parseDouble(ItemValue.getTracksPointX(tp));
y3 = Double.parseDouble(ItemValue.getTracksPointY(tp));
z3 = Double.parseDouble(ItemValue.getTracksPointZ(tp));
A1 = y2 - y1;
B1 = x1 - x2;
C1 = x2 * y1 - x1 * y2;
// x = ( k^2 * pt1.x + k * (point.y - pt1.y ) + point.x ) / ( k^2 + 1) ,
// y = k * ( x - pt1.x) + pt1.y;
// k = ( pt2.y - pt1. y ) / (pt2.x - pt1.x )
double k = (y2 - y1) / (x2 - x1);
x = (k * k * x1 * k * (y3 - y1) + x3) / (k * k + 1);
y = k * (x - x1) + y1;
z = (y - y1) / k + z1;
double distance = Math.abs(A1 * x3 + B1 * y3 + C1) /
Math.sqrt(A1 * A1 + B1 * B1);
boolean inside = Math.min(x2, x1) < x && x < Math.max(x2, x1) &&
(Math.min(y2, y1) < y && y < Math.max(y2, y1));
if (!inside) {
distance = Math.min(Math.sqrt( (x2 - x3) * (x2 - x3) + (y2 - y3) * (y2 - y3)),
Math.sqrt( (x1 - x3) * (x1 - x3) + (y1 - y3) * (y1 - y3)));
}else{
Document d = GarminGMLDoc.d;
tp = d.createElement("gml_coord");
Element dx = d.createElement("X");
Text t = d.createTextNode(x + "");
dx.appendChild(t);
Element dy = d.createElement("Y");
t = d.createTextNode(y + "");
dy.appendChild(t);
Element dz = d.createElement("Z");
t = d.createTextNode(z + "");
dz.appendChild(t);
Element time = d.createElement("Time");
t = d.createTextNode("");
time.appendChild(t);
tp.appendChild(dx);
tp.appendChild(dy);
tp.appendChild(dz);
tp.appendChild(time);
}
if (distance < minDis) {
minDis = distance;
if(!inside){
tp = nl.item(i);
}
}
}
return tp;
}
/**
* 得到给定的坐标与航迹点的距离
*/
private double getDisOfTP(Node tp,double lon,double lat){
double tpx = Double.parseDouble(ItemValue.getTracksPointX(tp));
double tpy = Double.parseDouble(ItemValue.getTracksPointY(tp));
return Math.pow((tpx - lon) * (tpx - lon) + (tpy - lat) * (tpy - lat),0.5);
}
/**
* 得到所有路面变化的航点
*/
private Node[] getAllChageNode(){
Node[] wpts = ItemValue.getWaypoint();
if (wpts == null) {
return null;
}
Vector ve = new Vector();
for (int i = 0; i < wpts.length; i++) {
if (!((ItemValue.getWaypointRS(wpts[i]).trim()).equals(""))) {
ve.addElement(wpts[i]);
}
}
Node[] rsChange = new Node[ve.size()];
for (int i = 0; i < rsChange.length; i++) {
rsChange[i] = (Node)ve.elementAt(i);
}
return rsChange;
}
/**
* 得到路面变化 的结果,即变化成的路面类型,可以直接将此值放在航迹路面里面
*/
private String getChangeTo(Node wpt){
String value = ItemValue.getWaypointRS(wpt).trim();
if (value.equals("")) {
return "";
}else{
String last = value.substring(3,5);
return TrackType.getRSType(last);
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -