📄 twonode.java
字号:
package net.aetherial.gis.jiaotongbu.outputJTB.txtOutput.module.gpsdata.lxld.lx;
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 TwoNode {
private Node n1 = null,n2 = null;
public TwoNode(Node n1,Node n2) {
this.n1 = n1;
this.n2 = n2;
}
public Node getNode1(){
return this.n1;
}
public Node getNode2(){
return this.n2;
}
/**
* 判断给定的两个节点是否与该节点相同
*/
public boolean isSame(Node n1,Node n2){
if ((this.n1 == n1) &&(this.n2 == n2)) {
return true;
}
else if ((this.n2 == n1) &&(this.n1 == n2)) {
return true;
}
else {
return false;
}
}
/**
* 判断给定对象的两个节点是否与该节点相同
*/
public boolean isSame(TwoNode tn){
if ((this.n1 == tn.n1) &&(this.n2 == tn.n2)) {
return true;
}
else if ((this.n2 == tn.n1) &&(this.n1 == tn.n2)) {
return true;
}
else {
return false;
}
}
/**
* 两节点顺序的关系
* 0 代表首1 首2相连
* 1 代表首1 尾2相连
* 2 代表尾1 首2相连
* 3 代表尾1 尾2相连
*/
public int getNodesShunxu(){
NodeList nl1 = ItemValue.getTracksPoint(this.n1);
NodeList nl2 = ItemValue.getTracksPoint(this.n2);
double b1b2 = getDisOfTwoTP(nl1.item(0),nl2.item(0));
double b1e2 = getDisOfTwoTP(nl1.item(0),nl2.item(nl2.getLength()-1));
double e1b2 = getDisOfTwoTP(nl1.item(nl1.getLength() -1),nl2.item(0));
double e1e2 = getDisOfTwoTP(nl1.item(nl1.getLength() -1),nl2.item(nl2.getLength()-1));
if ((b1b2 < b1e2)&&(b1b2 < e1b2)&&(b1b2 < e1e2)) {
return 0;
}else if((b1e2 < b1b2)&&(b1e2 < e1b2)&&(b1e2 < e1e2)){
return 1;
}else if((e1b2 < b1b2)&&(e1b2 < b1e2)&&(e1b2 < e1e2)){
return 2;
}else{
return 3;
}
}
private double getDisOfTwoTP(Node tp1,Node tp2){
double tp1x = Double.parseDouble(ItemValue.getTracksPointX(tp1));
double tp1y = Double.parseDouble(ItemValue.getTracksPointY(tp1));
double tp2x = Double.parseDouble(ItemValue.getTracksPointX(tp2));
double tp2y = Double.parseDouble(ItemValue.getTracksPointY(tp2));
return Math.pow((tp1x - tp2x)*(tp1x - tp2x) +(tp1y - tp2y)*(tp1y - tp2y),0.5);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -