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

📄 cutbyrscheng.java

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

import net.aetherial.gis.our.FrameOur;
import org.w3c.dom.*;
import net.aetherial.gis.surface.ItemValue;
import java.util.Vector;
import java.io.File;
import net.aetherial.gis.dataType.WptType;
import net.aetherial.gis.surface.CreateFile;
import net.aetherial.gis.garmin.GarminGMLDoc;
import net.aetherial.gis.output.toLd.bianma.BmAtRepeate;
import net.aetherial.gis.our.auto.check.repeattrk.TrackRectangle;

/**
 * <p>Title: </p>
 *
 * <p>Description: </p>
 *
 * <p>Copyright: Copyright (c) 2004</p>
 *
 * <p>Company: </p>
 *
 * @author not attributable
 * @version 1.0
 */
public class CutByRsCheng {
  public CutByRsCheng() {
  }

  private boolean isHaveRSChengWpt() {
    Node[] wpts = ItemValue.getWaypoint();
    for (int i = 0; wpts != null && i < wpts.length; i++) {
      if (!ItemValue.getWaypointRS(wpts[i]).trim().equals("")) {
        return true;
      }
    }
    return false;
  }

  private boolean isTrkHaveRSChengWpt(Node trk) {
    Node[] wpts = ItemValue.getTracksWaypoint(trk);
    for (int i = 0; wpts != null && i < wpts.length; i++) {
      if (!ItemValue.getWaypointRS(wpts[i]).trim().equals("")) {
        return true;
      }
    }
    return false;
  }

  private Vector getRsChengedWPts(Node trk) {
    Node[] wpts = ItemValue.getTracksWaypoint(trk);
    Vector temp = new Vector();
    for (int i = 0; wpts != null && i < wpts.length; i++) {
      if (!ItemValue.getWaypointRS(wpts[i]).trim().equals("")) {
        temp.add(wpts[i]);
      }
    }
    return temp;
  }

  private Node getNearTrackPoint(Node wpt) {
    return null;
  }

  private Node getNearpoint(Node track, Node waypoint) {
    double distance = 0.0;
    double minDis = 0.1;
    Node minTp = null;
    Node fp = null;
    NodeList nl = ItemValue.getTracksPoint(track);
    for (int i = 1; i < nl.getLength(); i++) {

      distance = this.getDistance(nl.item(i - 1), nl.item(i), waypoint);
      if (minDis > distance) {
        minDis = distance;
        minTp = nl.item(i - 1);
        fp = getFootPoint(nl.item(i - 1), nl.item(i), waypoint);
      }
    }
    if (minDis == 0.1) {
      this.print("没有发现与" + ItemValue.getWaypointName(waypoint) + "相近的点!");
    }
    else {
      if (fp != null) {
        TrackRectangle tr = new TrackRectangle(track);
        if (TrackRectangle.isPointInIt(Double.parseDouble(ItemValue.
            getWaypointX(waypoint)),
                                       Double.parseDouble(ItemValue.
            getWaypointY(waypoint)), tr)) {
          return fp;
        }

      }
    }

    return minTp;
  }

  /**
   * 返回的是 新产生 的 航迹 点
   */
  private Node getFootPoint(Node begin, Node end, Node wp) {

    double bx, by, bz, ex, ey, ez, px, py, pz, fpx, fpy, fpz;
    /**
     * begin 经纬度
     */
    bx = Double.parseDouble(ItemValue.getTracksPointX(begin));
    by = Double.parseDouble(ItemValue.getTracksPointY(begin));
    bz = Double.parseDouble(ItemValue.getTracksPointZ(begin));

    /**
     * end 经纬度
     */
    ex = Double.parseDouble(ItemValue.getTracksPointX(end));
    ey = Double.parseDouble(ItemValue.getTracksPointY(end));
    ez = Double.parseDouble(ItemValue.getTracksPointZ(end));

    /**
     * 航点 经纬度
     */
    px = Double.parseDouble(ItemValue.getWaypointX(wp));
    py = Double.parseDouble(ItemValue.getWaypointY(wp));
    pz = Double.parseDouble(ItemValue.getWaypointZ(wp));

    double k = (ey - by) / (ex - bx);

    fpx = (k * k * bx + k * (py - by) + px) / (k * k + 1);
    fpy = k * (fpx - bx) + by;

    if (bz - ez > 0.00001) {
      double k1 = (ey - by) / (ez - bz);
      fpz = (k1 * k1 * bz + k1 * (py - by) + pz) / (k1 * k1 + 1);
    }
    else {
      fpz = bz;
    }
    double minx = Math.min(bx, ex);
    double miny = Math.min(by, ey);
    double minz = Math.min(bz, ez);
    double maxx = Math.max(bx, ex);
    double maxy = Math.max(by, ey);
    double maxz = Math.max(bz, ez);

    Node fp = ItemValue.getNewTrackPoint("" + fpx, "" + fpy, "" + fpz, "");
    if (minx < fpx && fpx < maxx && miny < fpy && fpy < maxy) { // && minz<fpz && fpz<maxz){
      return fp;
    }
    if (getDistance(begin, wp) < getDistance(end, wp)) {
      return begin;
    }
    else {
      return end;
    }
  }

  private double getDistance(Node begin, Node end, Node wp) {
    return getDistance(getFootPoint(begin, end, wp), wp);

  }

  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 void print(String string) {
    System.out.println(string);
  }

}

⌨️ 快捷键说明

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