📄 checkrepeat.java
字号:
package net.aetherial.gis.our.auto.check.repeattrk;
import org.w3c.dom.*;
import net.aetherial.gis.surface.ItemValue;
import java.util.Hashtable;
import java.util.Vector;
/**
* <p>Title: </p>
*
* <p>Description: </p>
*
* <p>Copyright: Copyright (c) 2004</p>
*
* <p>Company: </p>
*
* @author not attributable
* @version 1.0
*/
public class CheckRepeat {
public final double NEAR_DISTANCE = 0.0002;
public final int MIN_COUNT = 2;
private int nearCount = 0;
private int beginPoint = 0, endPoint = 0;
private Vector point = new Vector();
private Node[] alltrks = null;
private TrackRectangle[] trs = null;
private String n = "";
public CheckRepeat() {
}
/**
* 遍历所有航迹,得出初始值
*/
public void runOverAllTrk() {
alltrks = ItemValue.getTracks();
if (this.alltrks != null) {
trs = new TrackRectangle[alltrks.length];
for (int i = 0; i < alltrks.length; i++) {
trs[i] = new TrackRectangle(alltrks[i]);
}
}
}
/**
* 清零
*/
private void reset() {
this.nearCount = 0;
this.beginPoint = 0;
this.endPoint = 0;
this.point.removeAllElements();
}
/**
* 通过航迹形成的矩形,比较航迹
*/
public void compareTrack() {
if (alltrks != null) {
for (int i = 0; i < alltrks.length; i++) {
for (int j = (i + 1); j < alltrks.length; j++) {
if (trs[i].isIntersect(trs[j])) {
/**
* 比较航迹数据
*/
this.compareTrackPoint(alltrks[i], alltrks[j]);
if (this.nearCount > this.MIN_COUNT) {
if ((this.beginPoint != this.endPoint)&&(this.isTooLong())) {
/**
* 如果有两点相近,说明此路线上有重合部分
*/
this.n = this.n + "\"\",\"\",\"\",\"\",文件<" +
ItemValue.fileName + ">中<" +
ItemValue.getTracksT2(alltrks[i]) + ">县<" +
ItemValue.getTracksT3(alltrks[i]) + ">乡:航迹<" +
ItemValue.getTracksName(alltrks[i]) + ">中第<" +
this.beginPoint + ">个航迹点 至 第<" + this.endPoint +
">个航迹点 与 航迹<" + ItemValue.getTracksName(alltrks[j]) +
">重合\r\n";
}
}
this.reset();
}
}
}
}
}
/**
* 比较航迹点
*/
private void compareTrackPoint(Node trk1, Node trk2) {
NodeList nl1 = ItemValue.getTracksPoint(trk1);
NodeList nl2 = ItemValue.getTracksPoint(trk2);
net.aetherial.gis.publicuse.PointLineDistance pd = new net.aetherial.gis.
publicuse.PointLineDistance();
if ( (nl1 != null) && (nl2 != null)) {
for (int i = 0; i < nl1.getLength(); i++) {
pd.setPoint0(Double.parseDouble(ItemValue.getTracksPointX(nl1.item(i))),
Double.parseDouble(ItemValue.getTracksPointY(nl1.item(i))));
for (int j = 0; j < nl2.getLength(); j++) {
pd.setPoint1(Double.parseDouble(ItemValue.getTracksPointX(nl2.item(j))),
Double.parseDouble(ItemValue.getTracksPointY(nl2.item(j))));
if ( (j + 1) >= nl2.getLength()) {
break;
}
pd.setPoint2(Double.parseDouble(ItemValue.getTracksPointX(nl2.item(j +
1))),
Double.parseDouble(ItemValue.getTracksPointY(nl2.item(j +
1))));
if (pd.getDis() < this.NEAR_DISTANCE) {
if (this.beginPoint == 0) {
this.beginPoint = i + 1;
}
this.endPoint = i + 1;
this.nearCount++;
point.add(nl1.item(i));
}
}
}
}
}
private boolean isTooLong() {
double dis = 0.0;
double xa = 0.0, ya = 0.0, xb = 0.0, yb = 0.0;
for (int i = 0; i < point.size(); i++) {
xa = Double.parseDouble(ItemValue.getTracksPointX( (Node) point.elementAt(
i)));
ya = Double.parseDouble(ItemValue.getTracksPointY( (Node) point.elementAt(
i)));
if ( (i + 1) < point.size()) {
xb = Double.parseDouble(ItemValue.getTracksPointX( (Node) point.
elementAt(i + 1)));
yb = Double.parseDouble(ItemValue.getTracksPointY( (Node) point.
elementAt(i + 1)));
dis = dis + Math.sqrt( (xb - xa) * (xb - xa) + (yb - ya) * (yb - ya));
}
}
if (dis > this.NEAR_DISTANCE * 3) {
return true;
}else{
return false;
}
}
/**
* 得到扫描结果
*/
public String getLog() {
return this.n;
}
/**
* 清空N
*/
public void resetN() {
this.n = "";
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -