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

📄 readtocut.java

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

import java.util.Vector;
import java.io.File;
import org.w3c.dom.Node;
import net.aetherial.gis.jiaotongbu.input.type.Luduan;
import net.aetherial.gis.jiaotongbu.input.analyse.OpenDirect;
import net.aetherial.gis.jiaotongbu.input.jxl.ReadLuduan;
import net.aetherial.gis.our.FrameOur;
import net.aetherial.gis.surface.ItemValue;
import net.aetherial.gis.jiaotongbu.input.analyse.UniteTrack;
import net.aetherial.gis.jiaotongbu.input.analyse.CutByZhuanghao;
import net.aetherial.gis.surface.CreateFile;
import net.aetherial.gis.jiaotongbu.input.analyse.ScaleLuduan;
import net.aetherial.gis.jiaotongbu.input.publicuse.Permanence;
/**
 * <p>Title: </p>
 *
 * <p>Description: </p>
 *
 * <p>Copyright: Copyright (c) 2004</p>
 *
 * <p>Company: </p>
 *
 * @author not attributable
 * @version 1.0
 */
public class ReadToCut {
  private String inputPath = "";
  private String outputPath = "";
  public ReadToCut() {
  }

  public void run() {
    OpenDirect od = new OpenDirect();
    File ldExcel = od.getLuduanExcel(this.inputPath);
    if (ldExcel == null) {
      Permanence.addLog("[文件错误]\t1_路段比较表.xls 不存在。");
      return;
    }
    ReadLuduan read = new ReadLuduan(ldExcel.getAbsolutePath());
    read.read();
    Permanence.printHeduidata_LD();
//    System.exit(0);
    File[] gpsFiles = od.getAllGPSFiles(this.inputPath);
    if (gpsFiles == null) {
      Permanence.addLog("[文件错误]\t没有GPS文件。");
      return;
    }
    FrameOur fo = new FrameOur();
    ItemValue.setShowDialogMessage(false);
    for (int i = 0; gpsFiles != null && i < gpsFiles.length; i++) {
      Permanence.addLog("__________________________");
      Permanence.addLog("[" + gpsFiles[i].getName() +"]");
      fo.openFile(gpsFiles[i]);
      this.cutAFile();
      fo.saveFile(getNewOutputFileReplaceInput(gpsFiles[i]));
      fo.reset();
    }
    if (!(Permanence.log.trim().equals(""))) {
      this.openLog(this.createLogFile());
    }

  }

  private void cutAFile() {
    UniteTrack unite = new UniteTrack();
    unite.unite();
    if (unite.isPrepareOK()) {
      Node[] trks = ItemValue.getTracks();
      if (trks == null || trks[0] == null) {
        return;
      }else{
        Vector lds = this.findLxArray(ItemValue.getTracksNumber(trks[0]).trim());
        ScaleLuduan scale = null;
        if (lds.size() > 0) {
          scale = new ScaleLuduan();
          scale.setTrack(trks[0]);
          scale.setLuduans(lds);
          scale.scanToGetScale();
          if (scale.isScaleChenged()) {
            Permanence.addLog("[桩号调整]\t" + "桩号调整比例为:" + scale.getScale()+ "\t里程为:" + ItemValue.getTracksStringDistance(trks[0]));
            scale.refreshLuduan();
          }
          lds = scale.getNewLuduans();
          CutByZhuanghao cut = new CutByZhuanghao();
          cut.setLuduan(lds);
          cut.cut(trks[0]);
        }else{
          Permanence.addLog("[表格错误]\t路段对比表中没有路线" +ItemValue.getTracksNumber(trks[0]).trim()+"数据");
        }

      }
    }
  }

  private String createLogFile(){
    File f = new File(this.getSplashPath(this.outputPath) + "log.txt");
    CreateFile cf = new CreateFile(f);
    cf.memoryToFile(Permanence.log);
    return f.getAbsolutePath();
  }

  private void openLog(String file) {
    try {
      Runtime.getRuntime().exec("cmd /c notepad " + file);
    }
    catch (Exception ex) {
      ex.printStackTrace();
    }
  }

  private File getNewOutputFileReplaceInput(File inputFile){
    String inputFilePath = inputFile.getAbsolutePath();
    String except = inputFilePath.substring(this.getSplashPath(this.inputPath).length(),inputFilePath.length());
    String outFilePath  = this.getSplashPath(this.outputPath) + except;
    return new File(outFilePath);
  }

  private String getSplashPath(String path){
    if (path.endsWith("\\")) {
      return path;
    }
    else {
      if (path.endsWith("/")) {
        return path.substring(0,path.length() -1) + "\\";
      }
      else {
        return path + "\\";
      }

    }
  }
  public void setInputPath(String inputPath) {
    this.inputPath = inputPath;
  }

  public void setOutputPath(String outputPath) {
    this.outputPath = outputPath;
  }

  private Vector findLxArray(String lxShortNumber) {
    Vector lds = new Vector();
    Luduan temp = null;
    for (int i = 0; i < Permanence.heduidata_LD.size(); i++) {
      temp = (Luduan) Permanence.heduidata_LD.get(i);
      if (temp.getLuxianDaima().indexOf(lxShortNumber) != -1) {
        lds.add(temp);
      }
    }
    return lds;
  }

  public static void main(String args[]) {
    ReadToCut readcut = new ReadToCut();
    readcut.setInputPath(args[0]);
    readcut.setOutputPath(args[1]);
    readcut.run();
  }

}

⌨️ 快捷键说明

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