📄 cuttofittrk.java
字号:
package net.aetherial.gis.output.toLd.repeate;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
import java.util.Vector;
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 CutToFitTrk {
private Node trk = null;
private NodeList tps = null;
private Node fitPointA = null, fitPointB = null;
public CutToFitTrk() {
}
/**
* 返回的是 新产生 的 航迹 点
*/
private Node getFootPoint_ByTp(Node begin, Node end, Node trackPoint) {
double bx, by, bz, ex, ey, ez, px, py, pz, fpx, fpy, fpz;
/**
* begin 经纬度
*/
bx = Double.parseDouble(ItemValue.getTracksPointX(begin));
by = Double.parseDouble(ItemValue.getTracksPointY(begin));
bz = Double.parseDouble(ItemValue.getTracksPointZ(begin));
/**
* end 经纬度
*/
ex = Double.parseDouble(ItemValue.getTracksPointX(end));
ey = Double.parseDouble(ItemValue.getTracksPointY(end));
ez = Double.parseDouble(ItemValue.getTracksPointZ(end));
/**
* 航迹点 经纬度
*/
px = Double.parseDouble(ItemValue.getTracksPointX(trackPoint));
py = Double.parseDouble(ItemValue.getTracksPointY(trackPoint));
pz = Double.parseDouble(ItemValue.getTracksPointZ(trackPoint));
double k = (ey - by) / (ex - bx);
fpx = (k * k * bx + k * (py - by) + px) / (k * k + 1);
fpy = k * (fpx - bx) + by;
if (bz - ez > 0.00001) {
double k1 = (ey - by) / (ez - bz);
fpz = (k1 * k1 * bz + k1 * (py - by) + pz) / (k1 * k1 + 1);
}
else {
fpz = bz;
}
double minx = Math.min(bx, ex);
double miny = Math.min(by, ey);
double minz = Math.min(bz, ez);
double maxx = Math.max(bx, ex);
double maxy = Math.max(by, ey);
double maxz = Math.max(bz, ez);
Node fp = ItemValue.getNewTrackPoint("" + fpx, "" + fpy, "" + fpz, "");
if (minx < fpx && fpx < maxx && miny < fpy && fpy < maxy) { // && minz<fpz && fpz<maxz){
return fp;
}
if (getDistance_ByTp(begin, trackPoint) < getDistance_ByTp(end, trackPoint)) {
return begin;
}
else {
return end;
}
}
private double getDistance_ByTp(Node tp1, Node tp2) {
double tpx = Double.parseDouble(ItemValue.getTracksPointX(tp1));
double tpy = Double.parseDouble(ItemValue.getTracksPointY(tp1));
double wpx = Double.parseDouble(ItemValue.getTracksPointX(tp2));
double wpy = Double.parseDouble(ItemValue.getTracksPointY(tp2));
return Math.sqrt( (tpx - wpx) * (tpx - wpx) + (tpy - wpy) * (tpy - wpy));
}
private void deleteExcrescentTps() {
if (this.tps == null) {
return;
}
else {
// Vector ve = new Vector();
boolean finded = false;
for (int i = 0; i < this.tps.getLength(); i++) {
if (this.tps.item(i) == this.fitPointA || this.tps.item(i) == this.fitPointB || finded) {
finded = true;
}
if (finded &&
(this.tps.item(i) == this.fitPointA ||
this.tps.item(i) == this.fitPointB)) {
finded = false;
}
if (!finded) {
ItemValue.deleteTracksPoint(this.trk, this.tps.item(i));
}
}
}
System.out.println(this.getClass().getName() +":deleteExcrescentTps!");
}
public Node createNewTrk() {
try {
this.tps = ItemValue.getTracksPoint(this.trk);
}
catch (Exception ex) {
this.tps = null;
}
this.deleteExcrescentTps();
return this.trk;
}
public static void main(String[] args) {
CutToFitTrk cuttofittrk = new CutToFitTrk();
}
public void setFitPointA(Node fitPointA) {
this.fitPointA = fitPointA;
}
public void setTrk(Node trk) {
this.trk = trk;
}
public void setFitPointB(Node fitPointB) {
this.fitPointB = fitPointB;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -