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

📄 ordertrack.java

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

import org.w3c.dom.Node;
import java.util.Vector;
import net.aetherial.gis.surface.ItemValue;
import net.aetherial.gis.dataType.WptType;
import net.aetherial.gis.jiaotongbu.input.type.Qiaoliang;
import net.aetherial.gis.jiaotongbu.input.publicuse.Permanence;
import net.aetherial.gis.publicuse.track.*;

/**
 * <p>Title: </p>
 *
 * <p>Description: </p>
 *
 * <p>Copyright: Copyright (c) 2004</p>
 *
 * <p>Company: </p>
 *
 * @author not attributable
 * @version 1.0
 */
public class OrderTrack {
  private Vector ConTracks = new Vector();
  private static final String NORTH_TO_SOUTH = "北 -> 南";
  private static final String SOUTH_TO_NORTH = "南 -> 北";
  private static final String EAST_TO_WEST = "东 -> 西";
  private static final String WEST_TO_EAST = "西 -> 东";
  Node qidian = null, zhidian = null;
  public OrderTrack() {
  }

  public Vector getConcatenatedTracks() {
    Vector temp = ConcatenatedTrack.addTracks(ItemValue.getTracks());
    printConTrks(temp,"getConcatenatedTracks");
    return temp;
  }

  public String[] getFangxiang() {
//    this.printConTrks(this.ConTracks,"getFangxiang");
    if (this.ConTracks.size() == 1) {
      qidian = ( (ConcatenatedTrack)this.ConTracks.get(0)).getFirstTrackPoint();
      zhidian = ( (ConcatenatedTrack)this.ConTracks.get(0)).getLastTrackPoint();
      return this.getFangxiangByPoint(qidian, zhidian);
    }
    else {
      Node t1,t2;
      t1 = ( (ConcatenatedTrack)this.ConTracks.get(0)).getFirstTrackPoint();
      t2 = ( (ConcatenatedTrack)this.ConTracks.get(0)).getLastTrackPoint();
      try {
        if (isDuandian1IsDuandian(t1, t2)) {
          qidian = t1;
        }
        else {
          qidian = t2;
        }
      }
      catch (Exception ex) {
        qidian = t1;
      }

      t1 = ( (ConcatenatedTrack)this.ConTracks.get(this.ConTracks.size() -1)).getFirstTrackPoint();
      t2 = ( (ConcatenatedTrack)this.ConTracks.get(this.ConTracks.size() -1)).getLastTrackPoint();
      try {
        if (isDuandian1IsDuandian(t1, t2)) {
          zhidian = t1;
        }
        else {
          zhidian = t2;
        }
      }
      catch (Exception ex) {
        zhidian = t2;
      }
      if (this.qidian == null) {
        System.out.println("this.qidian == null");
      }
      if (this.zhidian == null) {
        System.out.println("this.zhidian == null");
      }
      return this.getFangxiangByPoint(qidian, zhidian);
    }
  }


  private boolean isDuandian1IsDuandian(Node dd1,Node dd2) throws Exception{
    Vector allDuandians = new Vector();
    for (int i = 0; i < this.ConTracks.size(); i++) {
      allDuandians.add  (( (ConcatenatedTrack)this.ConTracks.get(i)).getFirstTrackPoint());
      allDuandians.add  (( (ConcatenatedTrack)this.ConTracks.get(i)).getLastTrackPoint());
    }
    double minDis1 = Double.MAX_VALUE,minDis2 = Double.MAX_VALUE,tempDis;
    for (int i = 0; i < allDuandians.size(); i++) {
      if ((Node)allDuandians.get(i) != dd1) {
        tempDis = this.getDisOfTp(dd1, (Node) allDuandians.get(i));
        if (minDis1 > tempDis) {
          minDis1 = tempDis;
        }
      }
      if ((Node)allDuandians.get(i) != dd2) {
        tempDis = this.getDisOfTp(dd2, (Node) allDuandians.get(i));
        if (minDis2 > tempDis) {
          minDis2 = tempDis;
        }
      }
    }
    if (minDis2 > minDis1) {
      return false;
    }else{
      return true;
    }
  }
  private String[] getFangxiangByPoint(Node tp_s, Node tp_e) {
    String[] fx = new String[2];
    double tp_s_x = Double.parseDouble(ItemValue.getTracksPointX(tp_s));
    double tp_s_y = Double.parseDouble(ItemValue.getTracksPointY(tp_s));
    double tp_e_x = Double.parseDouble(ItemValue.getTracksPointX(tp_e));
    double tp_e_y = Double.parseDouble(ItemValue.getTracksPointY(tp_e));
    if (tp_s_x > tp_e_x) {
      fx[0] = this.EAST_TO_WEST;
    }
    else {
      fx[0] = this.WEST_TO_EAST;
    }
    if (tp_s_y > tp_e_y) {
      fx[1] = this.NORTH_TO_SOUTH;
    }
    else {
      fx[1] = this.SOUTH_TO_NORTH;
    }
    return fx;
  }

  private void printConTrks(Vector conTks,String methodName){
    Node[] lll= null;
    ConcatenatedTrack ct = null;
    System.out.println("conTks.size():" + conTks.size());
    for (int i = 0; i < conTks.size(); i++) {
      System.out.println(" ******"+methodName);
      ct = (ConcatenatedTrack)conTks.get(i);
      lll = ct.getConcatenatedTrack();
      for (int j = 0; j < lll.length; j++) {
        System.out.println("    -" + ItemValue.getTracksName(lll[j])+"[" + ItemValue.getTracks_ld_original_number(lll[j])  + "]");
      }

    }

  }

  public void shunxuContracks(Vector ConTrks) {
    int size = ConTrks.size();
//    if (size == 1) {
//      return;
//    }
    ConcatenatedTrack mid = this.getYiduan(ConTrks), temp = null, temp1 = null;
    if (mid != null) {
      System.out.println(" mid != null.");
    }else{
      System.out.println(" mid == null.");
    }
    this.ConTracks.add(mid);
    ConTrks.removeElement(mid);
    size--;
    printConTrks(ConTrks,"shunxuContracks1");
    while (size > 0) {
      temp1 = mid;

      mid = this.getNearest(ConTrks, mid);

      try {
        if (this.isNeedReversePrimal(temp1, mid)) {
          temp1.reverse();
        }
      }
      catch (Exception ex1) {
      }

      try {
        if (this.isNeedReverseNext(temp1, mid)) {
          mid.reverse();
        }
      }
      catch (Exception ex) {
      }
      this.ConTracks.add(mid);
      ConTrks.removeElement(mid);
      size --;
    }
//    this.printConTrks(this.ConTracks,"shunxuContracks2");
  }

  /**
   * 得到一端的路线
   */
  private ConcatenatedTrack getYiduan(Vector ConTrks) {
    ConcatenatedTrack temp = null, temp1 = null, mid = null;
    double maxdis = 0, dis = 0;
    for (int i = 0; i < ConTrks.size(); i++) {
      temp = (ConcatenatedTrack) ConTrks.get(i);
      for (int j = 0; j < ConTrks.size(); j++) {
        temp1 = (ConcatenatedTrack) ConTrks.get(j);
        dis = ConTrkOper.getConTrksDis(temp1, temp);
        if (maxdis <= dis) {
          maxdis = dis;
          mid = temp;
        }
      }
    }
    return mid;
  }

  /**
   * 得到最近的路线
   */
  private ConcatenatedTrack getNearest(Vector ConTrks, ConcatenatedTrack contrk) {
    ConcatenatedTrack temp = null, minContrk = null;

    double mindis = Double.MAX_VALUE, dis = 0;
    for (int i = 0; i < ConTrks.size(); i++) {
      temp = (ConcatenatedTrack) ConTrks.get(i);
      if (temp != null) {
        dis = ConTrkOper.getConTrksDis(contrk, temp);
        if (mindis > dis) {
          mindis = dis;
          minContrk = temp;
        }
      }




    }

    return minContrk;
  }

  private boolean isQianmian(ConcatenatedTrack ref, ConcatenatedTrack contrk) throws
      Exception {
    Node a1 = ref.getFirstTrackPoint(), a2 = ref.getLastTrackPoint(),
        b1 = contrk.getFirstTrackPoint(), b2 = contrk.getLastTrackPoint();
    double a1b1 = this.getDisOfTp(a1, b1),
        a1b2 = this.getDisOfTp(a1, b2), a2b1 = this.getDisOfTp(a2, b1),
        a2b2 = this.getDisOfTp(a2, b2), minDis = Double.MAX_VALUE;
    minDis = Math.min(a1b1, Math.min(a1b2, Math.min(a2b1, a2b2)));
    if (minDis == a1b1 || minDis == a1b2) {
      return true;
    }
    else {
      return false;
    }
  }

  private boolean isNeedReverseNext(ConcatenatedTrack ref, ConcatenatedTrack contrk) throws
      Exception {
    Node a1 = ref.getFirstTrackPoint(), a2 = ref.getLastTrackPoint(),
        b1 = contrk.getFirstTrackPoint(), b2 = contrk.getLastTrackPoint();
    double a1b1 = this.getDisOfTp(a1, b1),
        a1b2 = this.getDisOfTp(a1, b2), a2b1 = this.getDisOfTp(a2, b1),
        a2b2 = this.getDisOfTp(a2, b2), minDis = Double.MAX_VALUE;
    minDis = Math.min(a1b1, Math.min(a1b2, Math.min(a2b1, a2b2)));
    if (minDis == a1b1 || minDis == a2b2) {
      return true;
    }
    else {
      return false;
    }
  }

  private boolean isNeedReversePrimal(ConcatenatedTrack ref, ConcatenatedTrack contrk) throws
      Exception {
    Node a1 = ref.getFirstTrackPoint(), a2 = ref.getLastTrackPoint(),
        b1 = contrk.getFirstTrackPoint(), b2 = contrk.getLastTrackPoint();
    double a1b1 = this.getDisOfTp(a1, b1),
        a1b2 = this.getDisOfTp(a1, b2), a2b1 = this.getDisOfTp(a2, b1),
        a2b2 = this.getDisOfTp(a2, b2), minDis = Double.MAX_VALUE;
    minDis = Math.min(a1b1, Math.min(a1b2, Math.min(a2b1, a2b2)));
    if (minDis == a1b1 || minDis == a1b2) {
      return true;
    }
    else {
      return false;
    }
  }


  private double getDisOfTp(Node trackpoint1, Node trackpoint2) throws
      Exception {
    double wpt_x = Double.parseDouble(ItemValue.getTracksPointX(trackpoint1));
    double wpt_y = Double.parseDouble(ItemValue.getTracksPointY(trackpoint1));
    double tp_x = Double.parseDouble(ItemValue.getTracksPointX(trackpoint2));
    double tp_y = Double.parseDouble(ItemValue.getTracksPointY(trackpoint2));
    return Math.sqrt( (wpt_x - tp_x) * (wpt_x - tp_x) +
                     (wpt_y - tp_y) * (wpt_y - tp_y));
  }

  public Vector getConTracks() {
    return ConTracks;
  }

}

⌨️ 快捷键说明

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