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

📄 deleterepeatewpt.java

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

import org.w3c.dom.Node;
import java.util.Vector;
import net.aetherial.gis.surface.ItemValue;

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

  private Vector sameWpts = new Vector();

  public DeleteRepeateWpt() {

  }

  /**
   * 清除重复的航点
   */
  public void cleanRepeateWpt(){
    Node[] wpts = ItemValue.getWaypoint();

    if (wpts == null) {
      return;
    }

    for (int i = 0; i < wpts.length; i++) {

      for (int j = i; j < wpts.length; j++) {
        if (i != j) {
          if (isRepeateWpt(wpts[i],wpts[j])) {
            if (sameWpts.size() == 0) {
              this.addSameWpt(wpts[i]);
            }
            this.addSameWpt(wpts[j]);
          }
        }
      }

      this.deleteGPSRepeate();
      this.removeAll();

    }
  }

  /**
   * 判断是否是重复的航点
   */
  private boolean isRepeateWpt(Node wpt1, Node wpt2) {
    if ((wpt1 == null) && (wpt2 == null)) {
      return true;
    }else if(wpt1 == null){
      return false;
    }else if(wpt2 == null){
      return false;
    }
    if (ItemValue.getWaypointKP(wpt1).equals(ItemValue.getWaypointKP(wpt2))) {
      if (ItemValue.getWaypointX(wpt1).equals(ItemValue.getWaypointX(wpt2))) {
        if (ItemValue.getWaypointY(wpt1).equals(ItemValue.getWaypointY(wpt2))) {
          return true;
        }
      }
    }
    return false;
  }

  /**
   * 得到重复的,并且应该删除的航点
   */
  private Node getRepeateWpt(Node wpt1,Node wpt2){
    boolean isRepeate = this.isRepeateWpt(wpt1,wpt2);
    if (!isRepeate) {
      return null;
    }
    if (ItemValue.getWaypointTracksID(wpt1).indexOf("-2") != -1) {
      return wpt1;
    }else{
      return wpt2;
    }
  }

  /**
   * 删除GPS数据中,重复的航点
   */
  private void deleteGPSRepeate(){
    Node keep = null;
    for (int i = 0; i < sameWpts.size(); i++) {
//    得到最应该保留的航点
        if (ItemValue.getWaypointTracksID((Node)sameWpts.elementAt(i)).equals("-2")) {
          keep = (Node)sameWpts.elementAt(i);
        }
    }
    if (keep == null) {
      for (int i = 1; i < sameWpts.size(); i++) {
        System.out.println("keep == null,Remove repeate:" + ItemValue.getWaypointName((Node)sameWpts.elementAt(i)));
        try {
          ItemValue.removeWaypoint( (Node) sameWpts.elementAt(i));
        }
        catch (Exception ex1) {
        }
      }
    }else{
      for (int i = 0; i < sameWpts.size(); i++) {
        if ((Node)sameWpts.elementAt(i) != keep) {
          System.out.println("keep != null,Remove repeate:" + ItemValue.getWaypointName((Node)sameWpts.elementAt(i)));
          try {
            ItemValue.removeWaypoint( (Node) sameWpts.elementAt(i));
          }
          catch (Exception ex) {
           // ex.printStackTrace();
          }
        }
      }
    }
  }

  /**
   * 加一个重复航点至记录中
   */
  private void addSameWpt(Node wpt){
    sameWpts.addElement(wpt);
  }

  /**
   * 删除记录的重复航点
   */
  private void removeAll(){
    sameWpts.removeAllElements();
  }

}

⌨️ 快捷键说明

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