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

📄 referencepoint.java

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

import net.aetherial.gis.our.FrameOur;
import org.w3c.dom.*;
import net.aetherial.gis.surface.ItemValue;
import net.aetherial.gis.dataType.WptType;
import net.aetherial.gis.table.WuWei;
import java.io.File;
import net.aetherial.gis.surface.CreateFile;
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 ReferencePoint {
  //private Node[] referencePoint = new Node[5];
  public String[][] rpString = new String[5][3];

  public ReferencePoint() {
  }
  public void setTracks(Node track){
    getReferencePoint(track);
    this.paixu();
  }
  private void remove(int i){
    String[][] rp = new String[this.rpString.length-1][3];
    if ((i<0)||(i>=this.rpString.length)) {
      return;
    }else{
      for (int j = 0; j < this.rpString.length-1; j++) {
        if (j<i) {
          rp[j] = this.rpString[j];
        }else{
          rp[j] = this.rpString[j+1];
        }
      }
      this.rpString = rp;
    }
  }
  private Node[] getReferencePoint(Node track){
    NodeList nl =ItemValue.getTracksPoint(track);
    Node[] points = new Node[nl.getLength()];
    for(int i = 0;i<nl.getLength();i++){
      points[i] = nl.item(i);
    }
    //
    Node[] node = new Node[5];
    Node[] hisWpt = ItemValue.getTracksWaypoint(track);
    node[0] = this.getReferenceStartPoint(points,hisWpt);
    hisWpt = this.getRidOfWpt(hisWpt,node[0]);
    node[1] = this.getReferenceLastPoint(points,hisWpt);
    hisWpt = this.getRidOfWpt(hisWpt,node[1]);
    node[2] = this.getReference1Point(points,hisWpt);
    hisWpt = this.getRidOfWpt(hisWpt,node[2]);
    node[3] = this.getReference2Point(points,hisWpt);
    hisWpt = this.getRidOfWpt(hisWpt,node[3]);
    node[4] = this.getReference3Point(points,hisWpt);
    hisWpt = this.getRidOfWpt(hisWpt,node[4]);
    //
    return node;
  }
  private Node getReferenceStartPoint(Node[] points,Node[] hisWpt){

    Node start = null;
    try {
      start = ItemValue.getMostNearWaypoint(points[0], hisWpt);
      if (start == null) {
        rpString[0][0] = "航迹点";
        rpString[0][1] = "" + ItemValue.getTracksPointX(points[0]);
        rpString[0][2] = "" + ItemValue.getTracksPointY(points[0]);
      }
      else {
        rpString[0][0] = ItemValue.getWaypointShortName(start);
        rpString[0][1] = getShort(ItemValue.getWaypointX(start));
        rpString[0][2] = getShort(ItemValue.getWaypointY(start));
      }
    }
    catch (Exception ex) {
    }
    return start;
  }
  private Node getReferenceLastPoint(Node[] points,Node[] hisWpt){
    Node last = ItemValue.getMostNearWaypoint(points[points.length-1],hisWpt);
    if(last == null){
      rpString[1][0] = "航迹点";
      rpString[1][1] = "" + ItemValue.getTracksPointX(points[points.length-1]);
      rpString[1][2] = "" + ItemValue.getTracksPointY(points[points.length-1]);
    }else{
      rpString[1][0] = ItemValue.getWaypointShortName(last);
      rpString[1][1] = getShort(ItemValue.getWaypointX(last));
      rpString[1][2] = getShort(ItemValue.getWaypointY(last));
    }
    return last;
  }
  private Node getReference1Point(Node[] points,Node[] hisWpt){
    int len = (int)(points.length/4);
    if(len >points.length){
      len = points.length-1;
    }
    Node wpt = ItemValue.getMostNearWaypoint(points[len],hisWpt);
    if(wpt == null){
      wpt = ifThereHaveXZC(hisWpt);
    }
    if(!(this.isXZC(wpt))){
      wpt =getXZCInWPT(hisWpt,wpt);
    }
    if(wpt == null){
      rpString[2][0] = "航迹点";
      rpString[2][1] = "" + ItemValue.getTracksPointX(points[len]);
      rpString[2][2] = "" + ItemValue.getTracksPointY(points[len]);
    }else{
      rpString[2][0] = ItemValue.getWaypointShortName(wpt);
      rpString[2][1] = getShort(ItemValue.getWaypointX(wpt));
      rpString[2][2] = getShort(ItemValue.getWaypointY(wpt));
    }
    return wpt;
  }
  private Node getReference2Point(Node[] points,Node[] hisWpt){
    int len = (int)((points.length/4)*2);
    if(len >points.length){
      len = points.length-1;
    }
    Node wpt = ItemValue.getMostNearWaypoint(points[len],hisWpt);
    if(wpt == null){
      wpt = ifThereHaveXZC(hisWpt);
    }
    if(!(this.isXZC(wpt))){
      wpt =getXZCInWPT(hisWpt,wpt);
      //System.out.println("get xingzhengcun");
    }
    if(wpt == null){
      rpString[3][0] = "航迹点";
      rpString[3][1] = "" + ItemValue.getTracksPointX(points[len]);
      rpString[3][2] = "" + ItemValue.getTracksPointY(points[len]);
    }else{
      rpString[3][0] = ItemValue.getWaypointShortName(wpt);
      rpString[3][1] = getShort(ItemValue.getWaypointX(wpt));
      rpString[3][2] = getShort(ItemValue.getWaypointY(wpt));
    }
    return wpt;
  }
  private Node getReference3Point(Node[] points,Node[] hisWpt){
    int len = (int)((points.length/4)*3);
    if(len >points.length){
      len = points.length-1;
    }
    Node wpt = ItemValue.getMostNearWaypoint(points[len],hisWpt);
    if(wpt == null){
      wpt = ifThereHaveXZC(hisWpt);
    }
    if(!(this.isXZC(wpt))){
      wpt =getXZCInWPT(hisWpt,wpt);
    }
    if(wpt == null){
      rpString[4][0] = "航迹点";
      rpString[4][1] = "" + ItemValue.getTracksPointX(points[len]);
      rpString[4][2] = "" + ItemValue.getTracksPointY(points[len]);
    }else{
      rpString[4][0] = ItemValue.getWaypointName(wpt);
      rpString[4][1] = getShort(ItemValue.getWaypointX(wpt));
      rpString[4][2] = getShort(ItemValue.getWaypointY(wpt));
    }

    return wpt;
  }
  private Node[] getRidOfWpt(Node[] wpt,Node node){
    Vector ve = new Vector();
    Node[] ridWpt =null;
    if(wpt == null){
      return null;
    }
    for(int i =0;i<wpt.length;i++){
      if(!(node.equals(wpt[i]))){
        ve.add(wpt[i]);
      }
    }
    if(ve.size()>0){
      ridWpt = new Node[ve.size()];
      for(int i =0;i<ve.size();i++){
        ridWpt[i] = (Node)ve.elementAt(i);
      }
    }
    return ridWpt;
  }
  private Node ifThereHaveXZC(Node[] wpt){
    if(wpt == null){
      return null;
    }
    for(int i  = 0;i<wpt.length;i++){
      if(ItemValue.getWaypointKP(wpt[i]).equals(WptType.W1XingZhengCun)){
        return wpt[i];
      }
    }
    return null;
  }
  private boolean isXZC(Node wpt){
    if(wpt == null){
      return false;
    }
    if(ItemValue.getWaypointKP(wpt).equals(WptType.W1XingZhengCun)){
        return true;
      }else{
        return false;
    }
  }
  private Node getXZCInWPT(Node[] wpt,Node oldWpt){
    Node newWpt = this.ifThereHaveXZC(wpt);
    if(newWpt == null){
      newWpt = oldWpt;
    }
    return newWpt;
  }
  private String getShort(String doubleString){
    try {
      return doubleString.substring(0, 8);
    }
    catch (Exception ex) {
      return doubleString;
    }
  }
  /**
   * 将得到的关键点重新排序
   */
  private void paixu() {
    /**
     * {开始的航点  x,y}
     * {中间的航点  x,y}
     * {中间的航点  x,y}
     * {中间的航点  x,y}
     * {结束的航点  x,y}
     */
    if (this.rpString == null) {
      return;
    }
    //存储最大值
    String nameLarge = "";
    String xLarge = "";
    String yLarge = "";

    double xtemp = 0.0;
    int pos = -1;
    double x = 0.0;
    String[][] temp = new String[5][3];
    for (int i = 0; i < temp.length; i++) {
      for (int j = 0; j < this.rpString.length; j++) {
        x = Double.parseDouble(this.rpString[j][1]);
          if (x > xtemp) {
            xtemp = x;
            nameLarge = this.rpString[j][0];
            xLarge = this.rpString[j][1];
            yLarge = this.rpString[j][2];
            pos = j;
          }
      }
      this.remove(pos);
      xtemp = 0.0;

      temp[i][0] = nameLarge;
      temp[i][1] = xLarge;
      temp[i][2] = yLarge;
    }
    this.rpString = temp;
  }
}

⌨️ 快捷键说明

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