tracknearbe.java

来自「基于Java的地图数据管理软件。使用MySQL数据库管理系统。」· Java 代码 · 共 107 行

JAVA
107
字号
package net.aetherial.gis.jiaotongbu.outputJTB.txtOutput.module.gpsdata.lxld.lx;

import org.w3c.dom.*;
import net.aetherial.gis.surface.ItemValue;
import net.aetherial.gis.our.auto.check.repeattrk.TrackRectangle;
import net.aetherial.gis.publicuse.TrackOper;
/**
 * <p>Title: </p>
 *
 * <p>Description: 航迹的首尾非常接近</p>
 *
 * <p>Copyright: Copyright (c) 2004</p>
 *
 * <p>Company: </p>
 *
 * @author not attributable
 * @version 1.0
 */
public class TrackNearBE {
  /**
   * 给定的航迹,
   * 一般情况下指所有的航迹
   */
  private Node[] trks = null;

  public TrackNearBE(Node[] trks) {
    this.trks = trks;
    this.test();
  }

  private void test(){
    if (this.trks != null) {
      Node[] temp = null;
      for (int i = 0; i < this.trks.length; i++) {
        temp = TrackOper.getIntersectTracks(this.trks,this.trks[i]);
        if (temp != null) {
          for (int j = 0; j < temp.length; j++) {
            if (this.isNearBE(this.trks[i],temp[j])) {
//              System.out.println("首尾接近 at class TrackNearBE:" + ItemValue.getTracksName(this.trks[i]) + "   ---  " + ItemValue.getTracksName(temp[j]));
//              System.out.println("*******Can Link:" + this.isCanLink(this.trks[i],temp[j]));
              if (this.isCanLink(this.trks[i],temp[j])) {
                TracksShouldLink.addNewNodes(this.trks[i],temp[j]);
              }
            }
          }
        }

      }
    }

  }

  /**
   * 判断航迹t1 - t2的首尾是否非常接近
   * 距离为20米以内的标准
   */
  private boolean isNearBE(Node t1,Node t2){
    NodeList nl1 = ItemValue.getTracksPoint(t1);
    NodeList nl2 = ItemValue.getTracksPoint(t2);
    if ( (nl1 == null) || (nl2 == null)) {
      return false;
    }
    else {
      Node t1f = nl1.item(0);
      Node t1l = nl1.item(nl1.getLength() - 1);
      Node t2f = nl2.item(0);
      Node t2l = nl2.item(nl2.getLength() - 1);
      if (this.getDisOfTPoint(t1f,t2f) < TrackRectangle.NEAR_DISTANCE) {
        return true;
      }else if (this.getDisOfTPoint(t1f,t2l) < TrackRectangle.NEAR_DISTANCE) {
        return true;
      }else if (this.getDisOfTPoint(t1l,t2f) < TrackRectangle.NEAR_DISTANCE) {
        return true;
      }else if (this.getDisOfTPoint(t1l,t2l) < TrackRectangle.NEAR_DISTANCE) {
        return true;
      }
      return false;
    }
  }

  /**
   * 得到任何两个航迹点的距离
   */
  private double getDisOfTPoint(Node tp1,Node tp2){
    double tp1x = Double.parseDouble(ItemValue.getTracksPointX(tp1));
    double tp1y = Double.parseDouble(ItemValue.getTracksPointY(tp1));
    double tp2x = Double.parseDouble(ItemValue.getTracksPointX(tp2));
    double tp2y = Double.parseDouble(ItemValue.getTracksPointY(tp2));
    double temp = (tp1x - tp2x) * (tp1x - tp2x) + (tp1y - tp2y) * (tp1y - tp2y);
    return Math.pow(temp,0.5);
  }

  /**
   * 是否符合合并的条件
   * 1.行政等级不同的
   * 2.
   */
  private boolean isCanLink(Node t1,Node t2){
    if ((ItemValue.getTracksGrade(t1)).equals(ItemValue.getTracksGrade(t2))) {
      return true;
    }else{
      return false;
    }
  }

}

⌨️ 快捷键说明

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