📄 createzhuanghao.java
字号:
package net.aetherial.gis.cutAndLink.zhuanghao;
import net.aetherial.gis.surface.ItemValue;
import org.w3c.dom.*;
import java.util.Vector;
import net.aetherial.gis.dataType.WptType;
import net.aetherial.gis.jiaotongbu.input.publicuse.Permanence;
/**
* <p>Title: </p>
*
* <p>Description: </p>
*
* <p>Copyright: Copyright (c) 2004</p>
*
* <p>Company: </p>
*
* @author not attributable
* @version 1.0
*/
public class CreateZhuanghao {
private Node zhWpt = null;
public CreateZhuanghao(Zhuanghao zh, String lxNumber) {
Node[] trks = ItemValue.getTracks();
Vector sameNumberTrks = new Vector();
String trkNumber = "";
for (int i = 0; i < trks.length; i++) {
if (ItemValue.getTracksNumber(trks[i]).toUpperCase().equals(lxNumber)) {
sameNumberTrks.add(trks[i]);
}
}
}
public CreateZhuanghao(Zhuanghao zh, Node trk) throws Exception {
// System.out.println("[isZhuanghaoInTrk]:" +
// this.isZhuanghaoInTrk(trk, zh.getMeterData()));
if (this.isZhuanghaoInTrk(trk, zh.getMeterData())) {
Node temp = this.createEndZhaunghao(zh, trk);
if (temp != null) {
this.zhWpt = temp;
this.initZhuanghaoWpt(zh, trk, this.zhWpt);
return;
}
NodeList nl = ItemValue.getTracksPoint(trk);
double disTemp = zh.getMeterData();
double dis = 0.0;
Node firstNode, lastNode;
for (int i = 0; nl != null && (i < nl.getLength() - 1); i++) {
disTemp = disTemp -
ItemValue.calculateDistanceBetween2Nodes1(nl.item(i), nl.item(i + 1));
if (disTemp <= 0) {
dis = ItemValue.calculateDistanceBetween2Nodes1(nl.item(i),
nl.item(i + 1)) + disTemp;
firstNode = nl.item(i);
lastNode = nl.item(i + 1);
this.zhWpt = this.createZhuanghaoWpt(firstNode, lastNode, dis);
this.initZhuanghaoWpt(zh, trk, this.zhWpt);
break;
}
}
}
else {
throw new Exception("桩号不在航迹的范围内。航迹" + ItemValue.getTracksDistance(trk) +
"米。" + " 桩号:" + zh.getZhuanghaoName() + "[" +
zh.getMeterData() + "]");
}
}
private void initZhuanghaoWpt(Zhuanghao zh, Node trk, Node wpt) {
ItemValue.setWaypointName(wpt, zh.getZhuanghaoName());
ItemValue.setWaypointTracksID(wpt, ItemValue.getTracksID(trk));
ItemValue.setWaypointKP(wpt, WptType.W13_zhuanghao);
}
/**
*
*/
private Node createEndZhaunghao(Zhuanghao zh, Node trk) {
// Permanence.addLog(
// "\tzh.getMeterData() - ItemValue.getTracksDistance(trk) = " +
// (zh.getMeterData() - ItemValue.getTracksDistance(trk)));
if (zh.getMeterData() - ItemValue.getTracksDistance(trk) >= -0.00001) {
// Permanence.addLog("\tcreateEndZhaunghao...");
NodeList nl = ItemValue.getTracksPoint(trk);
if (nl != null && nl.getLength() > 0) {
Node lastTrackPoint = nl.item(nl.getLength() - 1);
return ItemValue.createNewWaypoint("",
ItemValue.getTracksPointX(
lastTrackPoint),
ItemValue.getTracksPointY(
lastTrackPoint),
ItemValue.
getTracksPointZ(lastTrackPoint));
}
}
return null;
}
private Node createZhuanghaoWpt(Node firstTrackPoint, Node lastTrackPoint,
double dis) {
double disRef = ItemValue.calculateDistanceBetween2Nodes1(firstTrackPoint,
lastTrackPoint);
double scale = dis / disRef;
double f_x = Double.parseDouble(ItemValue.getTracksPointX(firstTrackPoint));
double l_x = Double.parseDouble(ItemValue.getTracksPointX(lastTrackPoint));
double f_y = Double.parseDouble(ItemValue.getTracksPointY(firstTrackPoint));
double l_y = Double.parseDouble(ItemValue.getTracksPointY(lastTrackPoint));
double f_z = Double.parseDouble(ItemValue.getTracksPointZ(firstTrackPoint));
double l_z = Double.parseDouble(ItemValue.getTracksPointZ(lastTrackPoint));
double diff_x = (l_x - f_x) * scale;
double diff_y = (l_y - f_y) * scale;
double diff_z = (l_z - f_z) * scale;
double zh_x, zh_y, zh_z;
zh_x = f_x + diff_x;
zh_y = f_y + diff_y;
zh_z = f_z + diff_z;
// if (f_x > l_x) {
// zh_x = f_x - diff_x;
// }
// else {
// zh_x = f_x + diff_x;
// }
// if (f_y > l_y) {
// zh_y = f_y - diff_y;
// }
// else {
// zh_y = f_y + diff_y;
// }
// if (f_z > l_z) {
// zh_z = f_z - diff_z;
// }
// else {
// zh_z = f_z + diff_z;
// }
return ItemValue.createNewWaypoint("", zh_x + "", zh_y + "", zh_z + "");
}
private boolean isZhuanghaoInTrk(Node trk, double length) {
if (length < 0) {
return false;
}
double dis = ItemValue.getTracksDistance(trk);
// System.out.println("[isZhuanghaoInTrk]dis:" + dis + ",length:" + length +
// ".dis - length:" + (dis - length));
if ( (dis - length) >= -0.00001) {
return true;
}
else {
return false;
}
}
/**
* 得到桩号航点
*/
public Node getZhuanghaoWaypoint() {
return this.zhWpt;
}
public static void main(String[] args) {
CreateZhuanghao createzhuanghao;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -