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

📄 tracksshouldlink.java

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

import org.w3c.dom.Node;
import net.aetherial.gis.publicuse.ArrayOper;
/**
 * <p>Title: </p>
 *
 * <p>Description: 应该被合并成路线的航迹</p>
 *
 * <p>Copyright: Copyright (c) 2004</p>
 *
 * <p>Company: </p>
 *
 * @author not attributable
 * @version 1.0
 */
public class TracksShouldLink {
  /**
   * 同一路线的航迹对象数组
   */
  private static TwoNode[] sameLX = null;

  public TracksShouldLink() {
  }

  public static void addNewNodes(Node t1, Node t2){
    TracksShouldLink.addTwoNode(new TwoNode(t1,t2));
  }

  public static void addTwoNode(TwoNode sameLx){
    if (TracksShouldLink.isSameInThis(sameLx)) {
      return;
    }
    if (TracksShouldLink.sameLX == null) {
      TracksShouldLink.sameLX = new TwoNode[1];
      TracksShouldLink.sameLX[0] = sameLx;
    }else{
      TwoNode[] temp = new TwoNode[TracksShouldLink.sameLX.length + 1];
      for (int i = 0; i < TracksShouldLink.sameLX.length; i++) {
        temp[i] = TracksShouldLink.sameLX[i];
      }
      temp[temp.length -1] = sameLx;
      TracksShouldLink.sameLX = temp;
    }
  }


  /**
   * 在存储的两个节点对象数组中存在相同的两个节点
   * 如果有,返回true
   */
  private static boolean isSameInThis(TwoNode sameLx){
    if (TracksShouldLink.sameLX == null) {
      return false;
    }else{
      for (int i = 0; i < TracksShouldLink.sameLX.length; i++) {
        if (TracksShouldLink.sameLX[i].isSame(sameLx)) {
          return true;
        }
      }
      return false;
    }
  }

  /**
   * 判断一个节点在本类的公共变量中是否已经包含过了
   */
  public static boolean isNodeInThis(Node node){
    if (TracksShouldLink.sameLX == null) {
      return false;
    }else{
      for (int i = 0; i < TracksShouldLink.sameLX.length; i++) {
        if (TracksShouldLink.sameLX[i].getNode1() == node) {
          return true;
        }else if(TracksShouldLink.sameLX[i].getNode2() == node){
          return true;
        }
      }
      return false;
    }
  }

  public static Node[] removeNodeInThis(Node[] allNodes){
    if (allNodes == null) {
      return null;
    }else if(TracksShouldLink.sameLX == null){
      return allNodes;
    }
    for (int i = 0; i < allNodes.length; i++) {
      if (isNodeInThis(allNodes[i])) {
//        remove allNodes[i] in allNodes;
          allNodes = removeNode(allNodes,allNodes[i]);
          if (allNodes == null) {
            return null;
          }
          i--;
      }
    }
    return allNodes;
  }

  private static Node[] removeNode(Node[] nodes, Node node){
    Object[] temp = ArrayOper.removeObject(node,nodes);
    if (temp == null) {
      return null;
    }else{
      Node[] temp1 = new Node[temp.length];
      for (int i = 0; i < temp1.length; i++) {
        temp1[i] = (Node)temp[i];
      }
      return temp1;
    }
  }
  public static TwoNode[] getTwoNode(){
    return TracksShouldLink.sameLX;
  }

  public static void reset(){
    TracksShouldLink.sameLX = null;
  }
}

⌨️ 快捷键说明

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