123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139 |
- import java.io.FileNotFoundException;
- import java.util.ArrayList;
- import java.util.HashMap;
- import java.util.Map;
- public class BuildYardFast {
- public void buildYard(String rulerFileName,String yardFileName,Integer rulerBegin,Integer rulerEnd) throws FileNotFoundException {
- ArrayList<Point> yardPointsList = gpsExchange(yardFileName);
- ArrayList<Point> rulerPointsList = gpsExchange(rulerFileName);
- Point rulerPointBegin = rulerPointsList.get(0);
- Point rulerPointEnd = rulerPointsList.get(1);
- Point pointYardBegin = cal(rulerPointBegin,rulerPointEnd,rulerBegin);
- Point pointYardEnd = cal(rulerPointBegin,rulerPointEnd,rulerEnd);
- ArrayList<Point> result = new ArrayList<>();
- result.add(pointYardBegin);
- result.addAll(yardPointsList);
- result.add(pointYardEnd);
- OperateFile operateFile = new OperateFile();
- String fileOutPath = "/Users/haoqianpan/file/programfile/gpsexc/out/";
- operateFile.printPoint(fileOutPath + yardFileName,arrayListNeg(result));
- }
- public ArrayList<Point> gpsExchange(String fileName) throws FileNotFoundException {
- ArrayList<GpsCor> pointArrayList;
- ArrayList<Point> dataList = new ArrayList<>();
- OperateFile operateFile = new OperateFile();
- String fileInputPath = "/Users/haoqianpan/file/programfile/gpsexc/in/";
- pointArrayList = operateFile.readlatlonCor(fileInputPath + fileName);
- for (int i = 0 ; i < pointArrayList.size();i++){
- GpsCor gpsCor = pointArrayList.get(i);
- Double lat = gpsCor.getLat();
- Double lon = gpsCor.getLon();
- GpsConvertMethod gpsConvertMethod = new GpsConvertMethod("MCT2XY",lat,lon,55.5,11789993,3128152);
- double[] xyCor = gpsConvertMethod.coordinatexy;
- Double x = xyCor[0];
- Double y = xyCor[1];
- Point point = new Point();
- point.setColX(x);
- point.setColY(y);
- dataList.add(point);
- }
- return dataList;
- }
- // public Point cal(Double xStart,Double yStart,Double xEnd,Double yEnd,Double rulerIndex){
- public Point cal(Point pointBeginInput,Point pointEndInput,Integer rulerIndex){
- Double xStart = pointBeginInput.getColX();
- Double yStart = pointBeginInput.getColY();
- Double xEnd = pointEndInput.getColX();
- Double yEnd = pointEndInput.getColY();
- //////
- Point pointStart = new Point();
- pointStart.setColX(xStart);
- pointStart.setColY(yStart);
- Point pointEnd = new Point();
- pointEnd.setColX(xEnd);
- pointEnd.setColY(yEnd);
- /////
- CurveTool curveTool = new CurveTool();
- ArrayList<Double> lineParamList = curveTool.calLineabc(pointStart,pointEnd);
- Double k = lineParamList.get(0);
- Double counterValue = Math.sqrt(Math.pow(rulerIndex,2)/(Math.pow(k,2) + 1));
- Point point = new Point();
- if (xStart >= xEnd){
- double xTemp = xStart - counterValue;
- double yTemp = curveTool.getLineYValue(xTemp,lineParamList);
- point.setColX(xTemp);
- point.setColY(yTemp);
- }
- if (xStart < xEnd){
- double xTemp = xStart + counterValue;
- double yTemp = curveTool.getLineYValue(xTemp,lineParamList);
- point.setColX(xTemp);
- point.setColY(yTemp);
- }
- System.out.println(pointDistance(point,pointStart));
- return point;
- }
- public ArrayList<Point> arrayListNeg(ArrayList<Point> arrayList){
- for (int i = 0 ; i < arrayList.size();i++){
- Point pointOld = arrayList.get(i);
- Point pointNew = new Point();
- pointNew.setColX(pointOld.getColX());
- pointNew.setColY( 0 - pointOld.getColY());
- arrayList.set(i,pointNew);
- }
- return arrayList;
- }
- public double pointDistance(Point point1 ,Point point2){
- Double x1 = point1.getColX();
- Double y1 = point1.getColY();
- Double x2 = point2.getColX();
- Double y2 = point2.getColY();
- return Math.sqrt(Math.pow(x1 - x2,2) + Math.pow(y1 - y2,2));
- }
- }
|