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

📄 scanall.java

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

import org.w3c.dom.Node;
import java.util.Vector;
import net.aetherial.gis.surface.ItemValue;
import net.aetherial.gis.dataType.WptType;
import net.aetherial.gis.our.FrameOur;
import java.io.File;
import net.aetherial.gis.our.auto.Auto;
import java.io.IOException;
import net.aetherial.gis.surface.CreateFile;
import net.aetherial.gis.table.WuWei;
import net.aetherial.gis.jiaotongbu.output.number.NameNumber;
import net.aetherial.gis.publicuse.StringOper;
import java.io.*;
import net.aetherial.gis.output.toLd.cut.RelateWPTAfterCut;

/**
 * <p>Title: </p>
 *
 * <p>Description: </p>
 *
 * <p>Copyright: Copyright (c) 2004</p>
 *
 * <p>Company: </p>
 *
 * @author not attributable
 * @version 1.0
 */
public class ScanAll
    extends Auto {
  protected String nql = "";
  protected String ndk = "";
  protected String nsd = "";
  protected String njzc = "";
  protected String outpath = "";
  protected WptToJTB[] dukou = null;
  protected WptToJTB[] suidao = null;
  protected WptToJTB[] qiaoliang = null;
  protected WptToJTB[] jianzhicun = null;
  /**
   * 表1中的建制村
   */
  protected WptToJTB[] jianzhicun_array = null;
  /**
   * 与表1比较,能发现的建制村
   */
  protected WptToJTB[] jianzhicun_canFind = null;
  /**
   * 与表1比较,不能发现的建制村
   */
  protected WptToJTB[] jianzhicun_canNotFind = null;

  public ScanAll(FrameOur fo) {
    this.setFrameOur(fo);
  }

  public void scanAllFile() {
    if (this.input != null) {
      for (int i = 0; i < this.input.length; i++) {
        this.open(this.input[i]);
        this.reRelateWaypointToTrack();
        this.getArray();

        this.setMemoryReset();
      }
//      this.Save("D:\\test.csv", this.n)
      this.output();
      this.outpath = this.getWithSplash(this.output.getAbsolutePath());
      this.saveQiaoliang();
      this.saveDukou();
      this.saveSuidao();
      this.saveJianzhicun();
      this.saveXiangzhen();
    }

    System.out.println("out path:" + this.output.getAbsolutePath());
  }

  protected void reRelateWaypointToTrack(){
    Node[] allwpts = ItemValue.getWaypoint();
    for (int i = 0;allwpts != null && i < allwpts.length; i++) {
      ItemValue.setWaypointTracksID(allwpts[i],"-2");
    }
    RelateWPTAfterCut relate = new RelateWPTAfterCut();
    allwpts = relate.getNoRepeatWpts(allwpts);
    Node[] alltrks = ItemValue.getTracks();
    for (int i = 0;alltrks != null && i < alltrks.length; i++) {
      relate.relateWptToTrk(allwpts,alltrks[i]);
    }
    allwpts = ItemValue.getWaypoint();
    for (int i = 0;allwpts != null && i < allwpts.length; i++) {
      if (ItemValue.getWaypointTracksID(allwpts[i]).equals("-2")) {
        ItemValue.removeWaypoint(allwpts[i]);
      }
    }
  }

  protected void saveDukou(){
    this.Save(this.outpath+"渡口.csv",Dukou.getHead() + this.ndk);
  }

  protected void saveQiaoliang(){
    this.Save(this.outpath+"桥梁.csv",Qiaoliang.getHead() + this.nql);
  }

  protected void saveSuidao(){
    this.Save(this.outpath+"隧道.csv",Suidao.getHead() + this.nsd);
  }

  protected void saveJianzhicun(){
    this.Save(this.outpath+"建制村.csv",Jianzhicun.getHead() + this.njzc);
  }

  protected void saveXiangzhen(){
    this.Save(this.outpath+"乡镇.csv",Xiangzhen.getAllContent());
  }

  protected String getWithSplash(String path){
    if (path.endsWith("\\")) {
      return path;
    }else if(path.endsWith("/")){
      return path;
    }else{
      return path+"\\";
    }
  }

  public void Save(String file, String content) {
//    System.out.println(content);
    if (content.trim().equals("")) {
      return;
    }
    File f = new File(file);
    if (!(f.getParentFile().exists())) {
      f.getParentFile().mkdirs();
    }
    try {
      f.createNewFile();
    }
    catch (IOException ex) {
      ex.printStackTrace();
    }
    CreateFile cf = new CreateFile(f);

    cf.setEncode(System.getProperty("file.encoding"));
    cf.memoryToFile(content);
//    try {
//      cf.setEncode("unicode");
//      cf.memoryToFile(content);
//    }
//    catch (Exception ex1) {
//      cf.setEncode("GB2312");
//      cf.memoryToFile(content);
//    }
  }


  protected void getArray() {
    Node[] wpts = ItemValue.getWaypoint();
//    WptToJTB dk = null;
    if (wpts == null) {
      return;
    }
    WptToJTB wtj = null;
    for (int i = 0; i < wpts.length; i++) {
      if (ItemValue.getWaypointKP(wpts[i]).equals(WptType.W6DuKou)) {
        wtj = new Dukou(wpts[i]);
        wtj.setValue();
        this.dukou = this.addWTJ(wtj, this.dukou);
      }
      else if (ItemValue.getWaypointKP(wpts[i]).equals(WptType.W1XingZhengCun)) {
        wtj = new Jianzhicun(wpts[i]);
        wtj.setValue();
        this.jianzhicun = this.addWTJ(wtj, this.jianzhicun);
      }
      else if (ItemValue.getWaypointKP(wpts[i]).equals(WptType.W3QiaoLiang)) {
        wtj = new Qiaoliang(wpts[i]);
        wtj.setValue();
        this.qiaoliang = this.addWTJ(wtj, this.qiaoliang);
      }
      else if (ItemValue.getWaypointKP(wpts[i]).equals(WptType.W4SuiDao)) {
        wtj = new Suidao(wpts[i]);
        wtj.setValue();
        this.suidao = this.addWTJ(wtj, this.suidao);
      }
    }
  }
  protected void scanMinzheng(){
    WuWei ww = new WuWei();
    Jianzhicun jzc = null;
    if (this.jianzhicun == null) {
      return;
    }
    for (int i = 0; i < this.jianzhicun.length; i++) {
      jzc = (Jianzhicun)jianzhicun[i];
      if (jzc != null) {
        int pos = ww.find(jzc.getHisName(), jzc.getHisXiangzhen());
        if (pos == -1) {
          jzc.setMinzheng("没有此行政村");
          this.jianzhicun_canNotFind = this.addWTJ(jzc,
              this.jianzhicun_canNotFind);
        }
        else {
          jzc.setMinzheng("符合");
          jzc.setRK_ZRC_DX(ww.wuwei_renkou[pos], ww.wzirancun[pos], ww.wdixing[pos]);
          jzc.setBianma();
          this.jianzhicun_canFind = this.addWTJ(jzc, this.jianzhicun_canFind);
        }
      }
    }

    this.jianzhicun_array = new Jianzhicun[ww.wuwei_cun.length];
    System.out.println("this.jianzhicun_array.length:" + this.jianzhicun_array.length);
    for (int i = 0; i < this.jianzhicun_array.length; i++) {
      jzc = new Jianzhicun(null);
      jzc.setRK_ZRC_DX(ww.wuwei_renkou[i],ww.wzirancun[i],ww.wdixing[i]);
      jzc.setMinzhenCUN(ww.wuchen_xiangzhen[i],ww.wuwei_cun[i]);
      jzc.setMinzheng("没有测量的行政村");
      jzc.setBianma();
      this.jianzhicun_array[i] = jzc;
    }
    System.out.println("jianzhicun_array.length" + jianzhicun_array.length);
    for (int i = 0; i < jianzhicun_array.length; i++) {
      System.out.println(jianzhicun_array[i]);
    }

    for (int i = 0; i < this.jianzhicun_canFind.length; i++) {
      for (int j = 0; j < this.jianzhicun_array.length; j++) {
//        if ((this.jianzhicun_canFind[i] != null) && (jianzhicun_array[j] != null)) {
//          if ( (this.jianzhicun_canFind[i].getHisName()).indexOf(
//              jianzhicun_array[j].getHisName()) != -1) {

          if (this.compareArrayAndCanFind(jianzhicun_canFind[i],jianzhicun_array[j])) {
            this.jianzhicun_array = this.removeWTJ(this.jianzhicun_array[j],
                                                   this.jianzhicun_array);
            break;
          }
//          }
//        }
      }
    }

    System.out.println("jianzhicun_array.length" + jianzhicun_array.length);
    for (int i = 0; i < jianzhicun_array.length; i++) {
      System.out.println(jianzhicun_array[i]);
    }
  }

  protected boolean compareArrayAndCanFind(WptToJTB array,WptToJTB find){
    if ((find == null)||(array == null)) {
      return false;
    }

    if (StringOper.isInclude(find.getHisXiangzhen(),array.getHisXiangzhen())) {
      if (StringOper.isInclude(find.getHisName(),array.getHisName())) {
        System.out.println("find.getHisName()" + find.getHisName() + "  VS "  + array.getHisName() + " :--: " + find.getHisXiangzhen());
        return true;
      }
    }
    return false;
  }

  public void output() {
    this.qiaoliang = this.deleteRepeateWTJ(this.qiaoliang);
    this.suidao = this.deleteRepeateWTJ(this.suidao);
    this.dukou = this.deleteRepeateWTJ(this.dukou);
    this.jianzhicun = this.deleteRepeateWTJ(this.jianzhicun);
    this.scanMinzheng();
    int shunxu = 1;
    if (this.jianzhicun_canFind != null) {
      for (int i = 0; i < this.jianzhicun_canFind.length; i++) {
        try {
          this.njzc = this.njzc + "\"" + (shunxu++) + "\"," +
              ( (Jianzhicun)this.jianzhicun_canFind[i]).getValue() + "\r\n";
        }
        catch (Exception ex2) {
          System.err.println(ex2.getMessage() + " in output() this.jianzhicun_canFind class ScanAll");
        }
      }
    }

    if (this.jianzhicun_canNotFind != null) {
      for (int i = 0; i < this.jianzhicun_canNotFind.length; i++) {
        try {
          this.njzc = this.njzc + "\"" + (shunxu++) + "\"," +
              ( (Jianzhicun)this.jianzhicun_canNotFind[i]).getValue() + "\r\n";
        }
        catch (Exception ex2) {
           System.err.println(ex2.getMessage() + " in output() this.jianzhicun_canNotFind class ScanAll");
        }
      }
    }
    if (this.jianzhicun_array != null) {
      for (int i = 0; i < this.jianzhicun_array.length; i++) {
        try {
          this.njzc = this.njzc + "\"" + (shunxu++) + "\"," +
              ( (Jianzhicun)this.jianzhicun_array[i]).getValue() + "\r\n";
        }
        catch (Exception ex2) {
          System.err.println(ex2.getMessage() + " in output() this.jianzhicun_array class ScanAll");
        }
      }
    }


    shunxu = 1;
    if (this.dukou != null) {
      for (int i = 0; i < this.dukou.length; i++) {
        try {
          this.ndk = this.ndk + "\"" + (shunxu++) + "\"," +
              ( (Dukou)this.dukou[i]).getValue() + "\r\n";
        }
        catch (Exception ex2) {
        }
      }
    }
    shunxu = 1;
    if (this.suidao != null) {
      for (int i = 0; i < this.suidao.length; i++) {
        try {
          this.nsd = this.nsd + "\"" + (shunxu++) + "\"," +
              ( (Suidao)this.suidao[i]).getValue() + "\r\n";
        }
        catch (Exception ex1) {
        }
      }
    }
    shunxu = 1;
    if (this.qiaoliang != null) {
      for (int i = 0; i < this.qiaoliang.length; i++) {
        try {
          this.nql = this.nql + "\"" + (shunxu++) + "\"," +
              ( (Qiaoliang)this.qiaoliang[i]).getValue() + "\r\n";
        }
        catch (Exception ex) {
//          System.err.println(ex.getMessage());
        }
      }
    }


  }
  protected WptToJTB[] addWTJ(WptToJTB wtj,WptToJTB[] array){
    if (array == null) {
      array = new WptToJTB[1];
      array[0] = wtj;
//      wtj.setValue();
      return array;
    }
    else {
      WptToJTB[] temp = new WptToJTB[array.length + 1];
      for (int i = 0; i < temp.length; i++) {
        if (i < temp.length - 1) {
          temp[i] = array[i];
        }
        else {
          temp[i] = wtj;
//          wtj.setValue();
        }
      }
      return temp;
    }
  }

  protected WptToJTB[] removeWTJ2(WptToJTB wtj,WptToJTB[] array){
    if (array == null) {
      return null;
    }
    else {
      WptToJTB[] temp = new WptToJTB[array.length -1];
      boolean isfind = false;
      for (int i = 0; i < temp.length; i++) {
        if ((array[i] != wtj)&&(!isfind)) {
          temp[i] = array[i];
        }else if((array[i] != wtj)&&(isfind)){
          temp[i] = array[i+1];
        }else if(array[i] == wtj){
          isfind = true;
        }
      }
      if (!isfind) {
        temp = this.addWTJ(array[array.length-1],temp);
      }
      return temp;
    }

  }

   protected WptToJTB[] removeWTJ(WptToJTB wtj,WptToJTB[] array){
     if (array == null) {
      return null;
    }
    int id = -1;
    for (int i = 0; i < array.length; i++) {
      if (array[i] == wtj) {
        id = i;
        break;
      }
    }
    if (id == -1) {
      return array;
    }
    else {
      Vector ve = new Vector();
      for (int i = 0; i < array.length; i++) {
        ve.add(array[i]);
      }
      ve.removeElementAt(id);
      WptToJTB[] temp = new WptToJTB[ve.size()];
      for (int i = 0; i < temp.length; i++) {
        temp[i] = (WptToJTB)ve.elementAt(i);
      }
      return temp;
    }

   }

  protected WptToJTB[] deleteRepeateWTJ(WptToJTB[] array){
    if (array != null) {
      WptToJTB[] temp = null;
      WptToJTB[] repeate = this.getRepeateWTJ(array);
      if (repeate== null) {
        return array;
      }
      for (int i = 0; i < repeate.length; i++) {
        for (int j = 0; j < array.length; j++) {
          if (isRepeate(repeate[i],array[j]) || isWaypointNotRelate(array[j])) {
            array = this.removeWTJ(array[j],array);
            System.out.println("remove:" + repeate[i].getHisName());
            break;
          }
        }
      }
    }
    return array;
  }

  protected boolean isWaypointNotRelate(WptToJTB b){
    if (b.getTrackName().equals("未与航迹关联")) {
      return true;
    }else{
      return false;
    }
  }

  protected boolean isRepeate(WptToJTB a, WptToJTB b){
    if (a == b) {
      return true;
    }else if((a.getLongitudeX().equals(b.getLongitudeX()))&& (a.getLatitudeY().equals(b.getLatitudeY()))){
      if (a.getName().equals(b.getName())) {
        return true;
      }else{
        return false;
      }
    }else{
      return false;
    }
  }

  protected WptToJTB[] getRepeateWTJ(WptToJTB[] array){
    WptToJTB[] temp = null;
    if (array != null) {

      WptToJTB a = null,b = null;
      for (int i = 0; i < array.length; i++) {
        a = array[i];
        for (int j = i; j < array.length; j++) {
          b = array[j];
          if (i != j) {
            if (a.isEqualsXYZ(b)) {
              if (b.getHisTrackName().equals("")) {
                temp = addWTJ(b,temp);
              }else if(a.getHisTrackName().equals("")){
                temp = addWTJ(a,temp);
              }else{
                temp = addWTJ(b,temp);
              }
            }
          }
        }
      }
    }
    return temp;
  }
}

⌨️ 快捷键说明

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