Browse Source

增加测试的main方法

16s01 4 years ago
parent
commit
2c8ada9f07
5 changed files with 100 additions and 49 deletions
  1. 39 39
      src/TestMeanShift.java
  2. 2 2
      src/test/Cal.java
  3. 4 8
      src/test/GetPoints.java
  4. 41 0
      src/test/GpsExchange.java
  5. 14 0
      src/test/TestMain.java

+ 39 - 39
src/TestMeanShift.java

@@ -1,39 +1,39 @@
-import java.io.FileNotFoundException;
-import java.io.PrintWriter;
-import java.util.ArrayList;
-
-public class TestMeanShift {
-    public static void main(String[] args) throws FileNotFoundException {
-        ArrayList<Double> pointx_input;
-        ArrayList<Double> pointy_input;
-        ArrayList<Double> centerx_history_forArea = new ArrayList<>();
-        ArrayList<Double> centery_history_forArea = new ArrayList<>();
-        double RusedforMeanshift = 40;
-        java.io.File file2 = new java.io.File("C:\\Users\\87969\\Desktop\\test\\MeanShift.txt");
-        PrintWriter Result_OutPut = new PrintWriter(file2);
-        ReadData readData = new ReadData();
-        readData.Read();
-        MeanShift meanShift = new MeanShift();
-        meanShift.setPointxAndPointy(readData.pointx_input,readData.pointy_input);
-        meanShift.setR(RusedforMeanshift);
-        ArrayList<ResultDataType> result ;
-        result = meanShift.mainLoop();
-        for(int i = 0 ; i < result.size();i++){
-            Result_OutPut.println(result.get(i).numOfPoint);
-        }
-        Result_OutPut.close();
-        pointx_input = readData.pointx_input;
-        pointy_input = readData.pointy_input;
-        centerx_history_forArea = meanShift.centerx_history_forArea;
-        centery_history_forArea = meanShift.centery_history_forArea;
-        CalculateArea calculateArea = new CalculateArea(pointx_input,pointy_input,centerx_history_forArea,centery_history_forArea);
-        calculateArea.setRusedforMeanShift(RusedforMeanshift);
-        calculateArea.setSplitTheta(Math.PI / 180);
-        calculateArea.setSplitRadiusWidth(0.3 * RusedforMeanshift);
-        calculateArea.setIncreasingRate(1.005);
-        calculateArea.configFinalCircle();
-        calculateArea.exchange();
-        calculateArea.DktoPolar();
-        calculateArea.LoopforCalculateArea();
-    }
-}
+//import java.io.FileNotFoundException;
+//import java.io.PrintWriter;
+//import java.util.ArrayList;
+//
+//public class TestMeanShift {
+//    public static void main(String[] args) throws FileNotFoundException {
+//        ArrayList<Double> pointx_input;
+//        ArrayList<Double> pointy_input;
+//        ArrayList<Double> centerx_history_forArea = new ArrayList<>();
+//        ArrayList<Double> centery_history_forArea = new ArrayList<>();
+//        double RusedforMeanshift = 40;
+//        java.io.File file2 = new java.io.File("C:\\Users\\87969\\Desktop\\test\\MeanShift.txt");
+//        PrintWriter Result_OutPut = new PrintWriter(file2);
+//        ReadData readData = new ReadData();
+//        readData.Read();
+//        MeanShift meanShift = new MeanShift();
+//        meanShift.setPointxAndPointy(readData.pointx_input,readData.pointy_input);
+//        meanShift.setR(RusedforMeanshift);
+//        ArrayList<ResultDataType> result ;
+//        result = meanShift.mainLoop();
+//        for(int i = 0 ; i < result.size();i++){
+//            Result_OutPut.println(result.get(i).numOfPoint);
+//        }
+//        Result_OutPut.close();
+//        pointx_input = readData.pointx_input;
+//        pointy_input = readData.pointy_input;
+//        centerx_history_forArea = meanShift.centerx_history_forArea;
+//        centery_history_forArea = meanShift.centery_history_forArea;
+//        CalculateArea calculateArea = new CalculateArea(pointx_input,pointy_input,centerx_history_forArea,centery_history_forArea);
+//        calculateArea.setRusedforMeanShift(RusedforMeanshift);
+//        calculateArea.setSplitTheta(Math.PI / 180);
+//        calculateArea.setSplitRadiusWidth(0.3 * RusedforMeanshift);
+//        calculateArea.setIncreasingRate(1.005);
+//        calculateArea.configFinalCircle();
+//        calculateArea.exchange();
+//        calculateArea.DktoPolar();
+//        calculateArea.LoopforCalculateArea();
+//    }
+//}

+ 2 - 2
src/test/cal.java → src/test/Cal.java

@@ -8,11 +8,11 @@ import java.lang.reflect.Array;
 import java.sql.SQLException;
 import java.util.ArrayList;
 
-public class cal {
+public class Cal {
 
     ArrayList<OccupyPerX> occupyPerXArrayList = new ArrayList<>();//占用情况
 
-    public ArrayList<Point> countNumber() throws SQLException {
+    public ArrayList<Point> calShape() throws SQLException {
 
         GetPoints getPoints = new GetPoints();
         getPoints.getPoints();

+ 4 - 8
src/test/GetPoints.java

@@ -34,11 +34,11 @@ public class GetPoints {
 
 
 
-        String realShapeBeginTime = "2020-06-24 11:12:31.000000";
-        String realShapeEndTime = "2020-06-24 11:13:09.000000";
+        String realShapeBeginTime = "2020-07-09 15:06:00.000000";
+        String realShapeEndTime = "2020-07-09 11:13:09.000000";
 
-        String allPointsBeginTime = "2020-06-24 11:12:31.000000";
-        String allPointsEndTime = "2020-06-24 11:13:09.000000";
+        String allPointsBeginTime = "2020-07-12 06:36:00.000000";
+        String allPointsEndTime = "2020-07-12 06:40:00.000000";
 
         String sql1 = "select GPS_LAT,GPS_LON from T_LOC_APP_CLIENT_STATUS@DBLINKLOC WHERE CLIENT_RECORD_TIME between to_timestamp('" + realShapeBeginTime  + "', 'yyyy-mm-dd hh24:mi:ss.ff') and to_timestamp('" + realShapeEndTime + "', 'yyyy-mm-dd hh24:mi:ss.ff')";
         String sql2 = "select GPS_LAT,GPS_LON from T_LOC_APP_CLIENT_STATUS@DBLINKLOC WHERE CLIENT_RECORD_TIME between to_timestamp('" + allPointsBeginTime  + "', 'yyyy-mm-dd hh24:mi:ss.ff') and to_timestamp('" + allPointsEndTime + "', 'yyyy-mm-dd hh24:mi:ss.ff')";
@@ -46,10 +46,6 @@ public class GetPoints {
         realShapePoints = buildPoints(sql1);
         allPoints = buildPoints(sql2);
 
-
-
-
-
 //        Connection
 
     }

+ 41 - 0
src/test/GpsExchange.java

@@ -9,6 +9,14 @@ public class GpsExchange {
 
         Point point = new Point();
 
+        double[] array = mct84Bl2xy(lat,lon);
+
+        Double x = array[0];
+        Double y = array[1];
+
+        point.setColX(x);
+        point.setColY(y);
+
         return point;
 
 
@@ -23,4 +31,37 @@ public class GpsExchange {
 //
 //    }
 
+    //墨卡托投影
+    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;
+    }
+
+
 }

+ 14 - 0
src/test/TestMain.java

@@ -0,0 +1,14 @@
+package test;
+
+import java.sql.SQLException;
+
+public class TestMain {
+
+    public static void main(String[] args) throws SQLException {
+
+        Cal cal = new Cal();
+        cal.calShape();
+
+    }
+
+}