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

📄 cuttosection.java

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

import org.w3c.dom.*;
import net.aetherial.gis.surface.ItemValue;
import net.aetherial.gis.garmin.GarminGMLDoc;
import net.aetherial.gis.cutAndLink.TempDoc;
/**
 * <p>Title: </p>
 *
 * <p>Description: </p>
 *
 * <p>Copyright: Copyright (c) 2004</p>
 *
 * <p>Company: </p>
 *
 * @author not attributable
 * @version 1.0
 */
public class CutToSection {
  private Node track = null;
  private static int id = 0;
  private String trackName = "分割的航迹";
  private Node start = null,end = null;
  public CutToSection() {
    try {
      jbInit();
    }
    catch (Exception ex) {
      ex.printStackTrace();
    }
  }

  public void setTrack(Node trackNode){
    this.track = trackNode;
  }

  public void setStartEnd(Node start,Node end){
    this.start = start;
    this.end = end;
  }

  private double getDistance(Node tp,Node wp){
    double tpx = Double.parseDouble(ItemValue.getTracksPointX(tp));
    double tpy = Double.parseDouble(ItemValue.getTracksPointY(tp));
    double wpx = Double.parseDouble(ItemValue.getWaypointX(wp));
    double wpy = Double.parseDouble(ItemValue.getWaypointY(wp));
    return Math.sqrt((tpx-wpx)*(tpx-wpx)+(tpy-wpy)*(tpy-wpy));
  }
  private Node getNearpoint(Node track,Node waypoint){
    double distance = 0.0;
    double minDis = 0.5;
    Node minTp = null;
    NodeList nl = ItemValue.getTracksPoint(track);
    for(int i = 0;i<nl.getLength();i++){
      distance = this.getDistance(nl.item(i),waypoint);
      if(minDis>distance){
        minDis = distance;
        minTp = nl.item(i);
      }
    }
    if(minDis == 0.5){
      System.out.println("没有发现与"+ItemValue.getWaypointName(waypoint)+"相近的点!");
    }
    return minTp;
  }

  private Node getFirstNode(Node startWaypoint){
    return this.getNearpoint(this.track,startWaypoint);
  }
  private Node getlastNode(Node endWaypoint){
    return this.getNearpoint(this.track,endWaypoint);
  }
  private Node[] getCuttedTrackPoint(Node start,Node end){
    this.trackName = ItemValue.getWaypointName(start)+"-"+ItemValue.getWaypointName(end);
    Node s = this.getFirstNode(start);
    Node e = this.getlastNode(end);
    NodeList nl = ItemValue.getTracksPoint(this.track);
    java.util.Vector team = new java.util.Vector();
    boolean findStart = false;
    boolean findEnd = false;
    for(int i =0;i<nl.getLength();i++){
      //////////////////////////
      if(findStart == false){
        if(nl.item(i).equals(s)){
          findStart = true;
          team.add(start);//加上一个起点(航点)
          team.add(nl.item(i));
          System.out.println("发现起点  || at line 80 in CutToSection");
        }
      }else{
        team.add(nl.item(i));
        System.out.println("发现一个点,添加进去  || at line 84 in CutToSection");
      }
      //////////////////////
      if(nl.item(i).equals(e)){
        findEnd = true;
        team.add(end);//加上一个终点(航点)
        System.out.println("到达终点--break  || at line 88 in CutToSection");
        break;
      }
    }
    Node[] node = null;
    if(team.size() == 0){
      System.out.println("team.size() == 0  || at line 94 in CutToSection");
      return null;
    }else{
      if(findEnd){
        node = new Node[team.size()];
        for (int i = 0; i < node.length; i++) {
          node[i] = (Node) team.get(i);
        }
        return node;
      }else{
        return null;
      }
    }
  }
  public void insertIntoGarminDoc(){

    this.id++;
    Node[] node = this.getCuttedTrackPoint(start,end);
    System.out.println(node.length);
    if(node==null){
      return;
    }else{
      Element e = GarminGMLDoc.addTrack(this.trackName+"(分"+this.id+")",this.track);
      for(int i = 0;i<node.length;i++){
        GarminGMLDoc.addTrackPoint(e,node[i]);
      }
    }
  }
  public void insertIntoTempDoc(){//添加到CutAndLink.TempDoc.tadded里面去

    this.id++;
    Node[] node = this.getCuttedTrackPoint(start,end);
    System.out.println(node.length);
    if(node==null){
      return;
    }else{
     // Element e = TempDoc.addTrack(this.trackName+"(分割"+this.id+")");
      for(int i = 0;i<node.length;i++){
       // TempDoc.addTrackPoint(e,node[i]);
      }
    }

  }



  public static void main(String[] args) {
    CutToSection cs= new CutToSection();
  }

  private void jbInit() throws Exception {
  }
}

class NoElementException extends Exception {
  public NoElementException(){

  }
}



⌨️ 快捷键说明

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