Bladeren bron

first commit

haoqianpan 4 jaren geleden
commit
8e61cc08f2

+ 35 - 0
src/main/java/BuildShape.java

@@ -0,0 +1,35 @@
+import com.google.gson.Gson;
+
+import java.io.FileNotFoundException;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.Map;
+
+public class BuildShape {
+
+    public void build(String fileName) throws FileNotFoundException {
+
+        Change change = new Change();
+        OperateFile operateFile = new OperateFile();
+        String filePath = "/Users/haoqianpan/file/programfile/meanshift/out/";
+//        String fileName = "";
+        ArrayList<Map> resultMapList = new ArrayList<>();
+        ArrayList<Point> pointArrayList = operateFile.readXYCor(filePath + fileName);
+
+        for (int i = 0 ; i < pointArrayList.size();i++){
+
+            Point point = pointArrayList.get(i);
+            Double x = point.getColX();
+            Double y = point.getColY();
+            Map mapTemp = new HashMap();
+            mapTemp.put("x",x.toString());
+            mapTemp.put("y",y.toString());
+            resultMapList.add(mapTemp);
+        }
+
+        Gson gson = new Gson();
+        String str = gson.toJson(resultMapList);
+        System.out.println(str);
+    }
+
+}

+ 139 - 0
src/main/java/BuildYardFast.java

@@ -0,0 +1,139 @@
+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));
+
+    }
+
+
+
+
+}

+ 38 - 0
src/main/java/Change.java

@@ -0,0 +1,38 @@
+import java.io.FileNotFoundException;
+import java.util.ArrayList;
+import java.util.Map;
+
+public class Change {
+    public  void gpsCortoXYList(String fileName) throws FileNotFoundException {
+        ArrayList<GpsCor> pointArrayList;
+        ArrayList<Point> dataList = new ArrayList<>();
+        OperateFile operateFile = new OperateFile();
+        String fileInputPath = "/Users/haoqianpan/file/programfile/gpsexc/in/";
+        String fileOutPath = "/Users/haoqianpan/file/programfile/gpsexc/out/";
+
+        pointArrayList = operateFile.readlatlonCor(fileInputPath + fileName);
+        ArrayList<Map> mapArrayList = new ArrayList<>();
+        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);
+        }
+
+        operateFile.printPoint(fileOutPath + fileName,dataList);
+
+    }
+}

+ 76 - 0
src/main/java/CurveTool.java

@@ -0,0 +1,76 @@
+import java.util.ArrayList;
+
+public class CurveTool {
+
+
+    public ArrayList<Double> calLineabc(Point point1, Point point2){
+
+        Double x1 = point1.getColX();
+        Double y1 = point1.getColY();
+        Double x2 = point2.getColX();
+        Double y2 = point2.getColY();
+
+
+        //////////
+        Double lineA;
+        Double lineB;
+        Double lineC;
+        ArrayList<Double> lineParamList = new ArrayList<>();
+
+        /////////
+
+        if (! x1.equals(x2)){
+
+            lineA = (y1 - y2) / (x1 - x2);
+            lineB = -1.0;
+            lineC = y1 - lineA * x1;
+            lineParamList.add(lineA);
+            lineParamList.add(lineB);
+            lineParamList.add(lineC);
+        }
+
+        return  lineParamList;
+    }
+
+    public Double distanceFromPointToLine(ArrayList<Double> lineParamList,Point point){
+
+        Double x = point.getColX();
+        Double y = point.getColY();
+
+        Double lineA = lineParamList.get(0);
+        Double lineB = lineParamList.get(1);
+        Double lineC = lineParamList.get(2);
+
+
+        Double value1 = lineA * x + lineB * y + lineC;
+        Double value2 = Math.sqrt(Math.pow(lineA,2) + Math.pow(lineB,2));
+        Double dis = Math.abs(value1 / value2);
+
+        return dis;
+    }
+
+    public Double getLineYValue(Double x,ArrayList<Double> lineParamList){
+
+        Double lineA = lineParamList.get(0);
+        Double lineC = lineParamList.get(2);
+
+//        System.out.println();
+
+        Double y = lineA * x + lineC;
+        return y;
+
+    }
+
+    //多阶
+    public Double getCurveValue(Double x,double[] curveParamList){
+
+        Integer degree = curveParamList.length;
+        Double y = 0.0;
+        for (int i = 0 ;i < degree;i++){
+            Double param = curveParamList[i];
+            y = y + Math.pow(x,i) * param;
+        }
+        return y;
+    }
+    
+}

+ 465 - 0
src/main/java/ExchaneMain.java

@@ -0,0 +1,465 @@
+//import com.google.gson.Gson;
+//
+//import java.io.FileNotFoundException;
+//import java.util.ArrayList;
+//import java.util.HashMap;
+//import java.util.List;
+//import java.util.Map;
+//
+//public class ExchaneMain {
+//
+//    static Map minXYMap;
+//
+//    static List<Map> areaList = new ArrayList<>();
+//
+//    public static void main(String[] args) throws FileNotFoundException {
+//
+////        getTransDistance("C:\\Users\\16s01\\Desktop\\GPS\\trans\\text.txt");
+//        getTransDistance("/Users/haoqianpan/file/programfile/gpsexchange/GPS/trans/text.txt");
+//
+//        printArea();
+//
+//        printYard();
+//
+//        printTml();
+//
+//        printBaiscCor();
+//
+//        calTemp();
+//
+//
+//
+//
+//    }
+//
+//    public static void getTransDistance(String dataInputFilePath) throws FileNotFoundException {
+//        ReadData readData = new ReadData();
+//        readData.setFilePath(dataInputFilePath);
+//        List<Map> gpsCorList = readData.readData();
+//
+//        int pointsNum = gpsCorList.size();
+//
+//
+//        int xm = Integer.MAX_VALUE;
+//        int ym = Integer.MAX_VALUE;
+//
+//        for (int i = 0 ; i < pointsNum;i++){
+//            Map map;
+//            map = gpsCorList.get(i);
+//            double lat = Double.parseDouble(map.get("lat").toString());
+//            double lon = Double.parseDouble(map.get("lon").toString());
+//
+////            System.out.println("lat: " + lat + " lon: " + lon);
+//            //墨卡托转换为平面坐标.
+//            double[] corArray = new double[2];
+//            corArray = GpsConvertMethod.MCT84Bl2xy(lon,lat);
+//            System.out.println(corArray[0] + " " + corArray[1]);
+//
+//            Map mapTemp = new HashMap();
+//            mapTemp.put("x",(int)corArray[0]);
+//            mapTemp.put("y",(int)corArray[1]);
+//
+//
+//            //平面坐标旋转
+//            double[] normalcorArray = new double[2];
+//            normalcorArray = GpsConvertMethod.xy2normalxy(corArray[0],corArray[1]);
+//
+//
+//            //旋转以后的坐标
+//            double normalX = normalcorArray[0];
+//            double normalY = normalcorArray[1];
+//
+//            System.out.println(normalX + "  " + normalY);
+//
+//            //找到最小值
+//
+//            if (normalX < xm) {
+//
+//                xm = (int)Math.ceil(normalX);
+//
+//            }
+//
+//            if (normalY < ym) {
+//
+//                ym = (int)Math.ceil(normalY);
+//
+//            }
+//
+//            Map normalmapTemp = new HashMap();
+//
+//            normalmapTemp.put("x",normalX);
+//
+//            normalmapTemp.put("y",normalY);
+//        }
+//
+//        Map resultMap = new HashMap();
+//
+//        resultMap.put("minX",xm - 121);
+//
+//        resultMap.put("minY",ym - 12);
+//
+//        minXYMap = resultMap;
+//
+//    }
+//
+//    public static void printArea() throws FileNotFoundException {
+//        String sgAName = "首钢A区";
+//        String sgBName = "首钢B区";
+//        String sgCName = "首钢C区";
+//        String sgDBName = "首钢待磅区";
+//
+//        String[] areaFileInputPath = new String[4];
+//
+//        String[] areaFileOutPutPath = new String[4];
+//
+//        String[] areaName = new String[4];
+//
+//        String areaFileInputBasicPath ="/Users/haoqianpan/file/programfile/gpsexchange/GPS/area/areaIn";
+//
+//        String areaFileOutputBasicPath ="/Users/haoqianpan/file/programfile/gpsexchange/GPS/area/out/areaOut";
+//
+//        for (int i = 0 ; i < 4;i++){
+//
+//            areaFileInputPath[i] = areaFileInputBasicPath + "-" + (i+1) + ".txt";
+//
+//            areaFileOutPutPath[i] = areaFileOutputBasicPath + "-" + (i+1) + ".txt";
+//
+//        };
+//
+//        areaName[0] = sgAName;
+//        areaName[1] = sgBName;
+//        areaName[2] = sgCName;
+//        areaName[3] = sgDBName;
+//
+//
+//        for (int i = 0 ; i < 4 ; i++){
+//
+//            Exchange exchange = new Exchange();
+//            exchange.setDataInputFilePath(areaFileInputPath[i]);
+//            exchange.setMinXY(minXYMap);
+//            exchange.setDataOutPutFilePath(areaFileOutPutPath[i]);
+//            exchange.execute();
+//            Map areaMap = exchange.printArea(areaName[i]);
+//            areaList.add(areaMap);
+//
+//        }
+//    }
+//
+//    public static void printYard() throws FileNotFoundException {
+//
+//        String[] yardName = {"BY01","BY02","BY03","BY04","BY05","BY06","AY01","AY02","AY03","AY04","AY05","AY06","AY07","CY01","DY01"};
+//        String[] yardId = {"首钢B区-Y01","首钢B区-Y02","首钢B区-Y03","首钢B区-Y04","首钢B区-Y05","首钢B区-Y06","首钢A区-Y01","首钢A区-Y02","首钢A区-Y03","首钢A区-Y04","首钢A区-Y05","首钢A区-Y06","首钢A区-Y07","首钢C区-Y01","首钢待磅区-Y01"};
+//        String[] yardInputPath = new String[15];
+//        String[] yardOutputPath = new String[15];
+//        String yardBasicInPutPath = "/Users/haoqianpan/file/programfile/gpsexchange/GPS/yard/yardIn";
+//        String yardBasicOutPutPath = "/Users/haoqianpan/file/programfile/gpsexchange/GPS/yard/out/yardOut";
+//
+//        for (int i = 0 ; i < 15;i++){
+//            yardInputPath[i] = yardBasicInPutPath + "-" + (i+1) + ".txt";
+//            yardOutputPath[i] = yardBasicOutPutPath + "-" + (i+1) + ".txt";
+//        };
+//
+//        for (int i = 0 ; i < 15; i++){
+//            Exchange exchange = new Exchange();
+//            exchange.setMinXY(minXYMap);
+//            exchange.setDataInputFilePath(yardInputPath[i]);
+//            exchange.setDataOutPutFilePath(yardOutputPath[i]);
+//            exchange.execute();
+//            Map yardMap = exchange.printYard(yardName[i],yardId[i]);
+//            areaList.add(yardMap);
+//        }
+//    }
+//
+//
+//    public static void printBaiscCor() throws FileNotFoundException {
+//        String basicCorOutPutPath = "/Users/haoqianpan/file/programfile/gpsexchange/GPS/basic/out/basicOut.txt";
+//
+//        Map basicCor =new HashMap();
+//
+//        basicCor.put("angle",55.5);
+//
+//        basicCor.put("corRevise",minXYMap);
+//
+//        Exchange exchange = new Exchange();
+//
+//        exchange.setDataOutPutFilePath(basicCorOutPutPath);
+//
+//        exchange.printCor(basicCor);
+//
+//
+//    }
+//
+//
+//    public static void printTml() throws FileNotFoundException {
+//
+//
+//        ////////////////////////////////////
+//
+//        String tmlBasicInPutPath = "/Users/haoqianpan/file/programfile/gpsexchange/GPS/tml/in/tmlIn.txt";
+//
+//        String tmlBasicOutPutPath = "/Users/haoqianpan/file/programfile/gpsexchange/GPS/tml/out/tmlOut.txt";
+//
+//        Exchange exchange = new Exchange();
+//
+//        exchange.setMinXY(minXYMap);
+//
+//        exchange.setDataInputFilePath(tmlBasicInPutPath);
+//
+//        exchange.setDataOutPutFilePath(tmlBasicOutPutPath);
+//
+//        exchange.execute();
+//
+//        List<Map> tmlCorList = exchange.corAfterTransList;
+//
+//        ////////////////////////////////////
+//
+//        List<Map> roadInfoMapList = getRoadData();
+//
+//        List<Map> trackInfoMapList = getTrackData();
+//
+//        List<Map> buildingInfoMapList = getBuildingData();
+//
+//        Map resultMap = new HashMap();
+//
+//        resultMap.put("TRACK",trackInfoMapList);
+//
+//        resultMap.put("ROAD",roadInfoMapList);
+//
+//        resultMap.put("BUILDING",buildingInfoMapList);
+//
+//        resultMap.put("POINTS",tmlCorList);
+//
+//        ////////////////////
+//        exchange.printTml(resultMap);
+//        ////////////////////
+//
+//    }
+//
+//    public static List<Map> getRoadData() throws FileNotFoundException {
+//
+//        String[] roadName = {"R01","R02","R03","R04","R05","R06","R07","R08","R09","R10"};
+//        String[] roadDirection = {"DOWN","UP","UP","UP","UP","UP","UP","UP","LEFT","RIGHT"};
+//        String[] roadInputPath = new String[10];
+//        String[] roadOutputPath = new String[10];
+//        String roadBasicInPutPath = "/Users/haoqianpan/file/programfile/gpsexchange/GPS/road/in/roadIn";
+//        String roadBasicOutPutPath = "/Users/haoqianpan/file/programfile/gpsexchange/GPS/road/out/roadOut";
+//
+//        List<Map> roadInfoMapList = new ArrayList<>();
+//
+//        for (int i = 0 ; i < 10;i++){
+//            roadInputPath[i] = roadBasicInPutPath + "-" + (i+1) + ".txt";
+//            roadOutputPath[i] = roadBasicOutPutPath + "-" + (i+1) + ".txt";
+//        };
+//
+//        for (int i = 0 ; i < 10; i++){
+//
+//            Exchange exchange = new Exchange();
+//
+//            exchange.setMinXY(minXYMap);
+//
+//            exchange.setDataInputFilePath(roadInputPath[i]);
+//
+//            exchange.setDataOutPutFilePath(roadOutputPath[i]);
+//
+//            try {
+//                exchange.execute();
+//            }
+//            catch (Exception e){
+////                throw new Exception("eee");
+//                System.out.println(i);
+//            }
+//
+//
+//            Map tempMap = exchange.getRoadData(roadName[i],roadDirection[i]);
+//
+//            roadInfoMapList.add(tempMap);
+//
+//        }
+//
+//        return roadInfoMapList;
+//
+//    }
+//
+//
+//    public static List<Map> getTrackData() throws FileNotFoundException {
+//
+//        String[] trackName = {"track01","track02","track03","track04","track05","track06"};
+//        String[] trackInputPath = new String[6];
+//        String[] trackOutputPath = new String[6];
+//        String trackBasicInPutPath = "/Users/haoqianpan/file/programfile/gpsexchange/GPS/track/in/trackIn";
+//        String trackBasicOutPutPath = "/Users/haoqianpan/file/programfile/gpsexchange/GPS/track/out/trackOut";
+//
+//        List<Map> trackInfoMapList = new ArrayList<>();
+//
+//        for (int i = 0 ; i < 6;i++){
+//            trackInputPath[i] = trackBasicInPutPath + "-" + (i+1) + ".txt";
+//            trackOutputPath[i] =  trackBasicOutPutPath + "-" + (i+1) + ".txt";
+//        };
+//
+//        for (int i = 0 ; i < 6 ; i++){
+//
+//            Exchange exchange = new Exchange();
+//
+//            exchange.setMinXY(minXYMap);
+//
+//            exchange.setDataInputFilePath(trackInputPath[i]);
+//
+//            exchange.setDataOutPutFilePath(trackOutputPath[i]);
+//
+//            exchange.execute();
+//
+//            Map tempMap = exchange.getTrackData(trackName[i]);
+//
+//            trackInfoMapList.add(tempMap);
+//
+//        }
+//
+//        return  trackInfoMapList;
+//
+//    }
+//
+//
+//    public static List<Map> getBuildingData() throws FileNotFoundException {
+//
+//        String[] buildingName = {"中检公司(北)","中检公司(南)","中控室","矿石1#变电站","洗车房","食堂","候工厅","港机公司","库房(北)","库房(南)","污水处理厂","喷淋泵房","矿石4#变电站","矿石2#变电所","矿石5#变电所"};
+//
+//        String[] buildingInputPath = new String[15];
+//
+//        String[] buildingOutputPath = new String[15];
+//
+//        String buildingBasicInPutPath = "/Users/haoqianpan/file/programfile/gpsexchange/GPS/building/in/buildingIn";
+//
+//        String buildingBasicOutPutPath = "/Users/haoqianpan/file/programfile/gpsexchange/GPS/building/out/buildingOut";
+//
+//        List<Map> buildingInfoMapList = new ArrayList<>();
+//
+//        for (int i = 0 ; i < 15;i++){
+//            buildingInputPath[i] = buildingBasicInPutPath + "-" + (i+1) + ".txt";
+//            buildingOutputPath[i] =  buildingBasicOutPutPath + "-" + (i+1) + ".txt";
+//        };
+//
+//        for (int i = 0 ; i < 15; i++){
+//
+//            Exchange exchange = new Exchange();
+//
+//            exchange.setMinXY(minXYMap);
+//
+//            exchange.setDataInputFilePath(buildingInputPath[i]);
+//
+//            exchange.setDataOutPutFilePath(buildingOutputPath[i]);
+//
+//            exchange.execute();
+//
+//            Map tempMap = exchange.getBuildingData(buildingName[i]);
+//
+//            buildingInfoMapList.add(tempMap);
+//
+//        }
+//
+//        return  buildingInfoMapList;
+//
+//    }
+//
+//    public static ArrayList<Map> cal(Double xStart,Double yStart,Double xEnd,Double yEnd){
+//
+//
+//
+//
+//        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(25/(Math.pow(k,2) + 1));
+//        ArrayList<Map> rulerPointsList = new ArrayList<>();
+//
+//        if (xStart >= xEnd){
+//
+//            for(int i = 0 ; i < 207; i++){
+//
+//                double xTemp = xStart - i * counterValue;
+//                double yTemp = curveTool.getLineYValue(xTemp,lineParamList);
+////                Point point = new Point();
+//
+//                Map map = new HashMap();
+//                map.put("x",xTemp);
+//                map.put("y",yTemp);
+////                point.setColX(xTemp);
+////                point.setColY(yTemp);
+//                rulerPointsList.add(map);
+//
+//            }
+//
+//        }
+//
+//        if (xStart < xEnd){
+//
+//            for(int i = 0 ; i < 207; i++){
+//
+//                double xTemp = xStart + i * counterValue;
+//                double yTemp = curveTool.getLineYValue(xTemp,lineParamList);
+//                Map map = new HashMap();
+//                map.put("x",xTemp);
+//                map.put("y",yTemp);
+////                point.setColX(xTemp);
+////                point.setColY(yTemp);
+//                rulerPointsList.add(map);
+//            }
+//
+//        }
+//        return rulerPointsList;
+//    }
+//
+//    public static void calTemp() throws FileNotFoundException {
+//
+//        String rulerInputFilePathe = "/Users/haoqianpan/file/programfile/gpsexchange/GPS/ruler/in/sr6ein.txt";
+//        String rulerInputFilePathw = "/Users/haoqianpan/file/programfile/gpsexchange/GPS/ruler/in/sr6win.txt";
+//        ArrayList<String> inputFilePathList = new ArrayList<>();
+//        inputFilePathList.add(rulerInputFilePathe);
+//        inputFilePathList.add(rulerInputFilePathw);
+//
+//        for (int i = 0 ; i < inputFilePathList.size();i++){
+//            String rulerName = "";
+//            if (i == 0){
+//                rulerName = "SR6东";
+//            }
+//            else if (i ==1){
+//
+//                rulerName = "SR6西";
+//            }
+//
+//            String filePathTemp = inputFilePathList.get(i);
+//            Exchange exchange = new Exchange();
+//            exchange.setDataInputFilePath(filePathTemp);
+//            exchange.setMinXY(minXYMap);
+//            exchange.execute();
+//            ArrayList<Map> corAfterTransList = exchange.corAfterTransList;
+//            Map mapStart = corAfterTransList.get(0);
+//            Map mapEnd = corAfterTransList.get(1);
+//            Double xStart = Double.parseDouble(mapStart.get("x").toString());
+//            Double yStart = Double.parseDouble(mapStart.get("y").toString());
+//
+//            Double xEnd = Double.parseDouble(mapEnd.get("x").toString());
+//            Double yEnd = Double.parseDouble(mapEnd.get("y").toString());
+//            ArrayList<Map> points = cal(xStart,yStart,xEnd,yEnd);
+//            Map map1 = new HashMap();
+//            map1.put("TYPE","标尺");
+//            map1.put("NAME",rulerName);
+//            map1.put("POINTS",points);
+//            Gson gson = new Gson();
+//            String str = gson.toJson(map1);
+//            System.out.println("打印ruler");
+//            System.out.println(str);
+//            System.out.println("打印完毕");
+//        }
+//
+//
+//    }
+//}

+ 161 - 0
src/main/java/GpsConvertMethod.java

@@ -0,0 +1,161 @@
+/**
+ * @创建人 ccj
+ * @创建时间 2020/7/25
+ * @描述
+ */
+public class GpsConvertMethod {
+
+    //首钢的角度为55.5度
+    //首钢 xShift 值为11789993,yShift 值为3128152
+
+    public  double[] coordinatexy;
+
+    public  double[] coordinatelb;
+
+    public GpsConvertMethod(String name, double x, double y, double angle, double xShift, double yShift) {
+
+        if(name == "MCT2XY"){
+
+
+            double[]  xy = new double[2];
+            xy =  MCT84Bl2xy(x,y);
+            double[] normalxy = new double[2];
+            normalxy = xy2normalxy(xy[0],xy[1], angle);
+            coordinatexy = new double[2];
+            coordinatexy = normalxyShiftToxy(normalxy[0],normalxy[1],xShift,yShift);
+
+        }
+        if(name == "XY2MCT"){
+
+
+            double[]  normalxy = new double[2];
+            normalxy =  xyShiftToNormalxy(x,y,xShift,yShift);
+            double[] xy = new double[2];
+            xy = normalxy2xy(normalxy[0],normalxy[1], angle);
+            coordinatelb = new double[2];
+            coordinatelb = xy2MCT84Bl(xy[0],xy[1]);
+
+        }
+
+
+    }
+
+    public  static double[] MCT84Bl2xy(double lat, double lon) { //墨卡托投影转换平面坐标
+        lon = lon * Math.PI / 180; //角度转弧度
+        lat = lat * Math.PI / 180; //角度转弧度
+
+        double B0 = 30 * Math.PI / 180; //角度转弧度
+
+        double N = 0, e = 0, a = 0, b = 0, e2 = 0, K = 0;
+        a = 6378137;
+        b = 6356752.3142;
+        e = Math.sqrt(1 - (b / a) * (b / a));//椭圆的第一偏心率,扁率
+        e2 = Math.sqrt((a / b) * (a / b) - 1); //椭圆的第二偏心率, 扁率
+        double CosB0 = Math.cos(B0);
+        N = (a * a / b) / Math.sqrt(1 + e2 * e2 * CosB0 * CosB0);
+        K = N * CosB0;
+
+        double Pi = Math.PI;
+        double SinB = Math.sin(lat);
+
+        double tan = Math.tan(Pi / 4 + lat / 2);//墨卡托投影的计算中间值
+        double E2 = Math.pow((1 - e * SinB) / (1 + e * SinB), e / 2);
+        double xx = tan * E2;
+
+        double xc = K * Math.log(xx);
+        double yc = K * lon;
+
+        double[] result = new double[2];
+        result[0] = (int) xc;
+        result[1] = (int) yc;
+        return result;
+
+
+    }
+
+    public  static double[] xy2normalxy(double x, double y, double angle) {
+        //首钢的角度为55.5度
+        double shouGangAngle = Math.toRadians(angle);
+        double x0,y0;
+
+        x0 = x * Math.cos(shouGangAngle) +  y * Math.sin(shouGangAngle);
+        y0 = y * Math.cos(shouGangAngle) -  x * Math.sin(shouGangAngle);
+
+
+        double[] result = new double[2];
+        result[0] = (int) x0;
+        result[1] = (int) y0;
+        return result;
+    }
+
+    public static double[] normalxyShiftToxy(double x, double y, double xShift, double yShift){
+        //首钢 xShift 值为11789993,yShift 值为3128152
+        double[] shiftedxy = new double[2];
+        shiftedxy[0] = x - xShift;
+        shiftedxy[1] = y - yShift;
+        return  shiftedxy;
+    }
+
+
+    public static double[] xyShiftToNormalxy(double x, double y, double xShift, double yShift){
+        //首钢 xShift 值为11789993,yShift 值为3128152
+        double[] shiftedxy = new double[2];
+        shiftedxy[0] = x + xShift;
+        shiftedxy[1] = y + yShift;
+        return  shiftedxy;
+    }
+
+
+    public static double[] normalxy2xy(double x, double y, double angle){
+        //首钢的角度为55.5度
+        double ShouGangAngle = Math.toRadians(angle);
+        double x0,y0;
+        x0 = x * Math.cos(ShouGangAngle) -  y * Math.sin(ShouGangAngle);
+        y0 = y * Math.cos(ShouGangAngle) +  x * Math.sin(ShouGangAngle);
+
+        double[] result = new double[2];
+        result[0] = (int) x0;
+        result[1] = (int) y0;
+        return result;
+    }
+
+
+
+    public static  double[] xy2MCT84Bl(double x, double y){
+
+        double B0 = 30 * Math.PI / 180; //角度转弧度
+
+        double N = 0, e = 0, a = 0, b = 0, e2 = 0, K = 0;
+        a = 6378137;
+        b = 6356752.3142;
+        e = Math.sqrt(1 - (b / a) * (b / a));//椭圆的第一偏心率,扁率
+        e2 = Math.sqrt((a / b) * (a / b) - 1); //椭圆的第二偏心率, 扁率
+        double CosB0 = Math.cos(B0);
+        N = (a * a / b) / Math.sqrt(1 + e2 * e2 * CosB0 * CosB0);
+        K = N * CosB0;
+        double Pi = Math.PI;
+
+
+        double[] result = new double[2];
+        result[0] = y*180 /(K*Math.PI);
+        //这里的坐标需要迭代才能求出
+        //初始值,迭代次数
+        result[1] = 0;
+        int iterativeTimes = 100;
+        double SinB = 0;
+        for (int i = 0; i <iterativeTimes ; i++) {
+            result[1] = Math.PI/2 - 2*Math.atan(Math.pow(Math.E, -x / K)*Math.pow(Math.E,(e/2)*Math.log((1 - e * SinB) / (1 + e * SinB))));
+            SinB = Math.sin(result[1]);
+        }
+        result[1] = result[1]*180/Math.PI;
+
+        double[] resultLatLon = new double[2];
+        resultLatLon[0] = result[1];
+        resultLatLon[1] = result[0];
+        return resultLatLon;
+
+    }
+
+
+
+}

+ 21 - 0
src/main/java/GpsCor.java

@@ -0,0 +1,21 @@
+public class GpsCor {
+
+    public Double lat;
+    public Double lon;
+
+    public Double getLat() {
+        return lat;
+    }
+
+    public void setLat(Double lat) {
+        this.lat = lat;
+    }
+
+    public Double getLon() {
+        return lon;
+    }
+
+    public void setLon(Double lon) {
+        this.lon = lon;
+    }
+}

+ 181 - 0
src/main/java/Main.java

@@ -0,0 +1,181 @@
+import com.google.gson.Gson;
+
+import java.io.FileNotFoundException;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.Map;
+
+public class Main {
+    public static void main(String[] args) throws FileNotFoundException {
+//        ArrayList<Point> pointArrayList;
+//        OperateFile operateFile = new OperateFile();
+//        pointArrayList = operateFile.readXYCor("/Users/haoqianpan/file/dayfile/20200811/gps/pmzbin1.txt");
+//119.073723 39.250695
+//119.073820 39.250745
+//119.080523 39.243040
+//119.080618 39.243092
+//        ArrayList<Map> mapArrayList = new ArrayList<>();
+//
+//        for (int i = 0 ; i < pointArrayList.size();i++){
+//
+//            Point point = pointArrayList.get(i);
+//
+//            Double x = point.getColX();
+//
+//            Double y = point.getColY();
+//
+//            GpsConvertMethod gpsConvertMethod = new GpsConvertMethod("XY2MCT",x,y,55.5,11789993,3128152);
+//
+//            double[] gpsCor = gpsConvertMethod.coordinatelb;
+//
+//            Double lat = gpsCor[0];
+//
+//            Double lon = gpsCor[1];
+//
+//            Map map = new HashMap();
+//            map.put("lon",lon);
+//            map.put("lat",lat);
+//            mapArrayList.add(map);
+//
+//        }
+//
+//        Gson gson = new Gson();
+//        String str = gson.toJson(mapArrayList);
+//
+//        System.out.println(str);
+
+//        ArrayList<String> fileNameList = new ArrayList<>();
+//        fileNameList.add("1e.txt");
+//        fileNameList.add("1w.txt");
+//        fileNameList.add("2e.txt");
+//        fileNameList.add("2w.txt");
+//        fileNameList.add("3e.txt");
+//        fileNameList.add("3w.txt");
+//        fileNameList.add("4e.txt");
+//        fileNameList.add("4w.txt");
+//        fileNameList.add("5e.txt");
+//        fileNameList.add("5w.txt");
+//        fileNameList.add("6e.txt");
+//        fileNameList.add("6w.txt");
+//
+//        for (int i = 0 ; i < fileNameList.size();i++){
+//
+//            String fileName = fileNameList.get(i);
+//            gpsCortoXYList(fileName);
+//
+//        }
+//        Change change = new Change();
+//        change.gpsCortoXYList("test1.txt");
+
+//        BuildShape buildShape = new BuildShape();
+//        buildShape.build("initial.txt");
+        Change change = new Change();
+        change.gpsCortoXYList("sr5900.txt");
+//        change.gpsCortoXYList("test2.txt");
+//        BuildYardFast buildYardFast = new BuildYardFast();
+//        buildYardFast.buildYard("sr3new.txt","test2.txt",390,470);
+//        gpsCortoXY("/Users/haoqianpan/file/programfile/gpsexc/in/sr3470390.txt");
+    }
+
+    public void gpsCortoXYJson(String filePath) throws FileNotFoundException {
+
+        ArrayList<GpsCor> pointArrayList;
+        OperateFile operateFile = new OperateFile();
+        pointArrayList = operateFile.readlatlonCor("/Users/haoqianpan/file/dayfile/20200811/gps/pmzbin2.txt");
+        ArrayList<Map> mapArrayList = new ArrayList<>();
+
+        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];
+
+            Map map = new HashMap();
+            map.put("lon",lon);
+            map.put("lat",lat);
+            mapArrayList.add(map);
+
+        }
+
+        Gson gson = new Gson();
+        String str = gson.toJson(mapArrayList);
+        System.out.println(str);
+
+    }
+
+    public static void gpsCortoXYList(String fileName) throws FileNotFoundException {
+
+        ArrayList<GpsCor> pointArrayList;
+        ArrayList<Point> dataList = new ArrayList<>();
+        OperateFile operateFile = new OperateFile();
+        String fileInputPath = "/Users/haoqianpan/file/programfile/bdqexchange/in/";
+        String fileOutPath = "/Users/haoqianpan/file/programfile/bdqexchange/out/";
+
+        pointArrayList = operateFile.readlatlonCor(fileInputPath + fileName);
+        ArrayList<Map> mapArrayList = new ArrayList<>();
+        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);
+        }
+
+        operateFile.printPoint(fileOutPath + fileName,dataList);
+
+    }
+
+    public static void gpsCortoXY(String filePath) throws FileNotFoundException {
+
+        ArrayList<GpsCor> pointArrayList;
+        OperateFile operateFile = new OperateFile();
+        pointArrayList = operateFile.readlatlonCor(filePath);
+        ArrayList<Point> arrayList = new ArrayList<>();
+
+        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];
+            System.out.println(x + " " + y);
+            Point point = new Point();
+            point.setColX(x);
+            point.setColY(y);
+            arrayList.add(point);
+        }
+
+
+
+    }
+
+}

+ 155 - 0
src/main/java/OperateFile.java

@@ -0,0 +1,155 @@
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Scanner;
+
+public class OperateFile {
+
+    public ArrayList<String> readData(String filePath) throws FileNotFoundException {
+
+        System.out.println("1");
+
+        File file = new File(filePath);
+
+        System.out.println(filePath);
+
+        Scanner input = new Scanner(file);
+
+        ArrayList<String> dataArrayList = new ArrayList<>();
+
+        while (input.hasNext()){
+
+            String rowData = input.nextLine();
+            System.out.println(rowData);
+
+            dataArrayList.add(rowData);
+
+        }
+
+        input.close();
+
+        return dataArrayList;
+
+    }
+
+    public ArrayList<Map> readPoints(String filePath) throws FileNotFoundException {
+
+
+        File file = new File(filePath);
+
+        System.out.println(filePath);
+
+        Scanner input = new Scanner(file);
+
+        ArrayList<Map> dataArrayList = new ArrayList<>();
+
+        while (input.hasNext()){
+
+            String latStr = input.next();
+            String lonStr = input.next();
+            System.out.println(latStr);
+            System.out.println(lonStr);
+
+            Double lat = Double.parseDouble(latStr);
+            Double lon = Double.parseDouble(lonStr);
+
+            Map mapTemp = new HashMap();
+            mapTemp.put("lat",lat);
+            mapTemp.put("lon",lon);
+            dataArrayList.add(mapTemp);
+
+        }
+
+        input.close();
+
+        return dataArrayList;
+
+    }
+
+
+
+
+
+    public ArrayList readFileStream(String filePath) throws FileNotFoundException {
+
+        FileInputStream inputStream = new FileInputStream(filePath);
+
+        ArrayList<String> dataArrayList = new ArrayList<>();
+
+        Scanner sc = new Scanner(inputStream, "UTF-8");
+
+        while (sc.hasNextLine()) {
+
+            String line = sc.nextLine();
+            dataArrayList.add(line);
+
+        }
+
+        return dataArrayList;
+    }
+
+    public void printData(String filePath,ArrayList<String> dataList) throws FileNotFoundException {
+
+        File file = new File(filePath);
+
+        java.io.PrintWriter listOutPut = new java.io.PrintWriter(file);
+
+        for (int i = 0 ; i < dataList.size();i++){
+
+            listOutPut.println(dataList.get(i).toString());
+
+        }
+
+        listOutPut.close();
+
+    }
+
+    public void printPoint(String filePath,ArrayList<Point> dataList) throws FileNotFoundException {
+
+        File file = new File(filePath);
+
+        java.io.PrintWriter listOutPut = new java.io.PrintWriter(file);
+
+        for (int i = 0 ; i < dataList.size();i++){
+            Point point = dataList.get(i);
+            listOutPut.println(point.getColX() + " " + point.getColY());
+        }
+
+        listOutPut.close();
+    }
+
+    public ArrayList<Point> readXYCor(String filePath) throws FileNotFoundException {
+
+        File file = new File(filePath);
+        Scanner input = new Scanner(file);
+        ArrayList<Point> pointArrayList = new ArrayList<>();
+        while (input.hasNext()){
+            Double x = input.nextDouble();
+            Double y = input.nextDouble();
+            Point point = new Point();
+            point.setColX(x);
+            point.setColY(y);
+            pointArrayList.add(point);
+        }
+        return pointArrayList;
+    }
+
+    public ArrayList<GpsCor> readlatlonCor(String filePath) throws FileNotFoundException {
+
+        File file = new File(filePath);
+        Scanner input = new Scanner(file);
+        ArrayList<GpsCor> pointArrayList = new ArrayList<>();
+        while (input.hasNext()){
+            Double lat = input.nextDouble();
+            Double lon = input.nextDouble();
+            GpsCor gpsCor =new GpsCor();
+            gpsCor.setLat(lat);
+            gpsCor.setLon(lon);
+            pointArrayList.add(gpsCor);
+        }
+        return pointArrayList;
+    }
+}

+ 22 - 0
src/main/java/Point.java

@@ -0,0 +1,22 @@
+public class Point {
+
+    public Double colX;
+
+    public Double colY;
+
+    public Double getColX() {
+        return colX;
+    }
+
+    public void setColX(Double colX) {
+        this.colX = colX;
+    }
+
+    public Double getColY() {
+        return colY;
+    }
+
+    public void setColY(Double colY) {
+        this.colY = colY;
+    }
+}