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

📄 wptsofar.java

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

import org.w3c.dom.Node;
import net.aetherial.gis.surface.ItemValue;
import net.aetherial.gis.our.auto.check.repeattrk.TrackRectangle;
import org.w3c.dom.NodeList;
import net.aetherial.gis.our.auto.check.repeattrk.PointLineDistance;

/**
 * <p>Title: </p>
 *
 * <p>Description: 检查航点关联的航迹是否超出航迹的范围,NEAR_DISTANCE = 30M</p>
 *
 * <p>Copyright: Copyright (c) 2004</p>
 *
 * <p>Company: </p>
 *
 * @author not attributable
 * @version 1.0
 */
public class WptSoFar {
  private final double NEAR_DISTANCE = 0.0018;
  private String n = "";
  public WptSoFar() {
  }

  /**
   * 检查文件中的所有航点
   */
  public void checkAll() {

    Node[] wpts = ItemValue.getWaypoint();
    Node trk = null;
    if (wpts == null) {
      return;
    }
    for (int i = 0; i < wpts.length; i++) {
      //得到该航点关联的航迹
      trk = ItemValue.getWaypointHisTrack(wpts[i]);
      if (trk != null) {
        if (! (this.isInConfine(wpts[i], trk))) {
          this.n = n + "\"\",\"\",\"\",\"\",文件<" + ItemValue.fileName + ">里有" + "航点:[" + (i + 1) + "][" +
              ItemValue.getWaypointName(wpts[i]) + "]离与其关联的航迹:[" +
              ItemValue.getTracksName(trk) + "]太远\r\n";
        }
//        else{
//          if (!(this.canGetNearLine(wpts[i], trk))) {
//            this.n = n + "\"\",\"\",\"\",\"\",CHECK2:文件<" + ItemValue.fileName + ">里有" + "航点:[" + (i + 1) + "][" +
//                ItemValue.getWaypointName(wpts[i]) + "]离与其关联的航迹:[" +
//                ItemValue.getTracksName(trk) + "]太远\r\n";
//          }
//        }
      }
    }
  }

  /**
   * 检查该航点是否包含在指定的航迹边界范围之内
   * 先让航迹自身遍历一次,得到两个最远的点,构成正方形;
   * 判断该航点是否在此正方型内。
   * 如果不在返回false;
   */
  protected boolean isInConfine(Node wpt, Node track) {
    TrackRectangle tr = new TrackRectangle(track);
    double x = Double.parseDouble(ItemValue.getWaypointX(wpt));
    double y = Double.parseDouble(ItemValue.getWaypointY(wpt));
    return tr.isPointInIt(x, y, tr);
  }

  /**
   * 遍历每两个连续的航迹点组成的线段,
   * 计算航点和每条线段之间的距离,
   * 如果永远找不到一条在距离范围内的线段,
   * 返回false;
   */
  protected boolean canGetNearLine(Node wpt, Node tracks) {
    /**
     *
     */
    Node p1 = null, p2 = null;
    NodeList nl = ItemValue.getTracksPoint(tracks);
    double dis = 0.0;
    double temp = 1000.0;
    if (nl == null) {
      return false;
    }
    for (int i = 0; i < nl.getLength(); i++) {
      /**
       *
       */
      if (i == 0) {
        p1 = nl.item(0);
      }
      else {
        p2 = nl.item(i);
        dis = this.getDistanceOfPoint(wpt, p1, p2);
        if (dis < temp) {
          temp = dis;
        }
        if (dis < this.NEAR_DISTANCE) {
          return true;
        }
        p1 = p2;
      }
    }
    System.out.println("航点:" + ItemValue.getWaypointName(wpt));
    System.out.println("最短距离:" + temp);
    return false;
  }

  private double getDistanceOfPoint(Node wpt, Node tp1, Node tp2) {
    PointLineDistance ps = new PointLineDistance();
    ps.setPoint0(Double.parseDouble(ItemValue.getWaypointX(wpt)),
                 Double.parseDouble(ItemValue.getWaypointY(wpt)));
    ps.setPoint1(Double.parseDouble(ItemValue.getTracksPointX(tp1)),
                 Double.parseDouble(ItemValue.getTracksPointY(tp1)));
    ps.setPoint2(Double.parseDouble(ItemValue.getTracksPointX(tp2)),
                 Double.parseDouble(ItemValue.getTracksPointY(tp2)));
    return ps.getDistance();
  }

  /**
   * 通过航点的ID得到
   * 关联的航迹
   */
  protected Node getHisTrack(Node wpt) {
    return ItemValue.getWaypointHisTrack(wpt);
  }
  public String getN() {
    return this.n;
  }

  public void reset() {
    this.n = "";
  }

}

⌨️ 快捷键说明

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