📄 unitesection.java
字号:
package net.aetherial.gis.our.cut;
import net.aetherial.gis.surface.ItemValue;
import net.aetherial.gis.garmin.GarminGMLDoc;
import org.w3c.dom.*;
/**
* <p>Title: </p>
*
* <p>Description: </p>
*
* <p>Copyright: Copyright (c) 2004</p>
*
* <p>Company: </p>
*
* @author not attributable
* @version 1.0
*/
public class UniteSection {
private Node track1 =null,track2 =null;
private String orderT1 = "",orderT2 = "";
private boolean t1first = true;
private static int id =0;
private String trackName ="合并的航迹";
public UniteSection() {
trackName = trackName +this.id;
}
private double getDistance(Node tp1,Node tp2){
double distance = ItemValue.calculateDistanceBetween2Nodes1(tp1,tp2);
return distance;
}
private void setOrder(){
Node t1p1 = ItemValue.getTracksPoint(this.track1).item(0);
Node t1p2 = ItemValue.getTracksPoint(this.track1).item(ItemValue.getTracksPoint(this.track1).getLength()-1);
Node t2p1 = ItemValue.getTracksPoint(this.track2).item(0);
Node t2p2 = ItemValue.getTracksPoint(this.track2).item(ItemValue.getTracksPoint(this.track2).getLength()-1);
double d1= this.getDistance(t1p1,t2p1);
double d2= this.getDistance(t1p1,t2p2);
double d3= this.getDistance(t1p2,t2p1);
double d4= this.getDistance(t1p2,t2p2);
double test = this.getMin(d1,d2,d3,d4);
if(test == d1){
this.setOrder("desc","asc");
}else if(test == d2){
this.setOrder("desc","desc");
}else if(test == d3){
this.setOrder("asc","asc");
}else if(test == d4){
this.setOrder("asc","desc");
}
}
public void setTracksName(String trackName){
this.trackName = trackName;
}
private void setOrder(String order1,String order2){
this.orderT1 = order1;
this.orderT2 = order2;
}
private void setFirst(boolean first){
this.t1first = first;
}
private double getMin(double d1,double d2,double d3,double d4){
double test = d1;
if(test>d2){
test = d2;
}
if(test>d3){
test = d3;
}
if(test>d4){
test = d4;
}
return test;
}
private Node[] getNode(){
NodeList nl1 = ItemValue.getTracksPoint(this.track1);
NodeList nl2 = ItemValue.getTracksPoint(this.track2);
Node[] node = new Node[nl1.getLength()+nl2.getLength()];
if(this.orderT1.equals("asc")){
for(int i = 0;i<nl1.getLength();i++){
node[i] = nl1.item(i);
}
}else{
for(int i = 0;i<nl1.getLength();i++){
node[nl1.getLength()-i-1] = nl1.item(i);
}
}
if(this.orderT2.equals("asc")){
for(int i = 0;i<nl2.getLength();i++){
node[i+nl1.getLength()] = nl2.item(i);
}
}else{
for(int i = 0;i<nl2.getLength();i++){
node[nl1.getLength()+nl2.getLength()-i-1] = nl2.item(i);
}
}
return node;
}
public void insertIntoGarminDoc(){
this.setOrder();
this.id++;
Node[] node = this.getNode();
if(node==null){
return;
}else{
Element e = GarminGMLDoc.addTrack(this.trackName,this.track1);
for(int i = 0;i<node.length;i++){
GarminGMLDoc.addTrackPoint(e,node[i]);
}
}
}
public void setTrack(int pos1,int pos2){
this.track1 = ItemValue.getTracksByPos(pos1);
this.track2 = ItemValue.getTracksByPos(pos2);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -