⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 unitesection.java

📁 基于Java的地图数据管理软件。使用MySQL数据库管理系统。
💻 JAVA
字号:
package net.aetherial.gis.cutAndLink.cut;

import net.aetherial.gis.surface.ItemValue;
import net.aetherial.gis.garmin.GarminGMLDoc;
import net.aetherial.gis.cutAndLink.TempDoc;
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 = 1;
  private String trackName = "合";
  private TempDoc tc = null;
  public UniteSection() {
    trackName = trackName + this.id;
  }
  public void setTempDoc(TempDoc tc){
    this.tc = tc;
  }
  public void setTracksName(String trackName) {
    this.trackName = trackName;
  }

  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");
    }
  }

  private void setOrder(String order1, String order2) {
    this.orderT1 = order1;
    this.orderT2 = order2;
  }
  public void setOrder(boolean order1, boolean order2) {
    if(order1){
      this.orderT1 = "desc";
    }else{
      this.orderT1 = "asc";
    }
    if(order2){
      this.orderT2 = "asc";
    }else{
      this.orderT2 = "desc";
    }
  }

  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 insertIntoTempDoc() {
    //this.setOrder();在这之前就要setorder
    this.id++;
    Node[] node = this.getNode();
    if ((node == null)&&(node.length==0)) {
      return;
    }else {
      Element e = tc.addTrack(this.trackName);
      for (int i = 0; i < node.length; i++) {
        tc.addTrackPoint(e, node[i]);
      }
    }
  }

  public void setTrack(int pos1, int pos2) {
    this.track1 = ItemValue.getTracksByPos(pos1);
    this.track2 = ItemValue.getTracksByPos(pos2);
  }

  public void setTrack(Node t1, Node t2) {
    this.track1 = t1;
    this.track2 = t2;
    String t1name=ItemValue.getTracksName(t1);
    String t2name=ItemValue.getTracksName(t2);
    if((t1name.length()>20)||(t2name.length()>20)){
      this.trackName = "合并的航迹"+this.id;
    }else{
      this.trackName = "合并"+t1name + "-" + t2name;
    }
  }

}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -