16s01 пре 4 година
родитељ
комит
559cfff4cb

+ 21 - 8
src/test/Cal.java

@@ -4,6 +4,7 @@ import test.entity.OccupyPerX;
 import test.entity.Point;
 import test.entity.WholeIndexOccupy;
 
+import java.io.FileNotFoundException;
 import java.lang.reflect.Array;
 import java.sql.SQLException;
 import java.util.ArrayList;
@@ -12,7 +13,7 @@ public class Cal {
 
     ArrayList<OccupyPerX> occupyPerXArrayList = new ArrayList<>();//占用情况
 
-    public ArrayList<Point> calShape() throws SQLException {
+    public ArrayList<Point> calShape() throws SQLException, FileNotFoundException {
 
         GetPoints getPoints = new GetPoints();
         getPoints.getPoints();
@@ -41,12 +42,18 @@ public class Cal {
         Double maxX = xIndexCorList.get(xIndexCorList.size() - 1);
         Double minY = yIndexCorList.get(0);
         Double maxY = yIndexCorList.get(yIndexCorList.size() - 1);
+
         wholeIndexOccupy.printOccupy(minX,minY,xGap,yGap);
 
 
         ArrayList<Point> pointAfterExclude = new ArrayList<>();//过滤后的所有点的坐标
 
 
+
+        OperateFile operateFile = new OperateFile();
+        operateFile.printPoint("Y:\\allpoints.txt",allPoints);
+
+
         //对待计算点,进行过滤,过滤掉在网格以外的,这部分后面单独写个过滤类
         for(int i = 0 ; i < allPoints.size();i++){
 
@@ -62,11 +69,16 @@ public class Cal {
 
         }
 
+        operateFile.printPoint("Y:\\pointsexclude.txt",pointAfterExclude);
+
+
+
+
         //占用的网格为1,不占用的网格0
         ArrayList<ArrayList<Integer>> occupyList = changeWholeIndexOccupyToList(wholeIndexOccupy);
 
 
-        System.out.println("print all points---------------" );
+//        System.out.println("print all points---------------" );
 
         for (int i = 0; i < pointAfterExclude.size();i++){
 
@@ -75,7 +87,7 @@ public class Cal {
             Double y = point.getColY();
 
 
-            System.out.println( x + " " + y);
+//            System.out.println( x + " " + y);
 
 
             Integer xIndex = split.identifyXIndex(x);
@@ -93,7 +105,7 @@ public class Cal {
 
 
         }
-        System.out.println("print all points end -----------");
+//        System.out.println("print all points end -----------");
 
 
 
@@ -165,7 +177,6 @@ public class Cal {
             Point point = new Point();
             point.setColX(xCor);
             point.setColY(yCor);
-
             shape.add(point);
         }
 
@@ -186,12 +197,14 @@ public class Cal {
 
 
 //        System.out.println(shape.size());
-        for (int i = 0 ; i < shape.size() ; i++){
+//        for (int i = 0 ; i < shape.size() ; i++){
 
-            System.out.println(shape.get(i).getColX() + " " + shape.get(i).getColY() );
+//            System.out.println(shape.get(i).getColX() + " " + shape.get(i).getColY() );
 //            System.out.println(shape.get(i).getColY());
 
-        }
+//        }
+
+        operateFile.printPoint("Y:\\changed.txt",shape);
         return shape;
 
 

+ 42 - 6
src/test/GetPoints.java

@@ -33,12 +33,48 @@ public class GetPoints {
 
 
 
-
-        String realShapeBeginTime = "2020-07-09 15:06:00.000000";
-        String realShapeEndTime = "2020-07-09 15:08:00.000000";
-
-        String allPointsBeginTime = "2020-07-12 06:36:00.000000";
-        String allPointsEndTime = "2020-07-12 06:41:00.000000";
+        //B50
+//        String realShapeBeginTime = "2020-07-09 15:06:00.000000";
+//        String realShapeEndTime = "2020-07-09 15:08:00.000000";
+//
+//        String allPointsBeginTime = "2020-07-12 06:36:00.000000";
+//        String allPointsEndTime = "2020-07-12 06:41:00.000000";
+
+////        B39
+//        String realShapeBeginTime = "2020-07-13 14:09:00.000000";
+//        String realShapeEndTime = "2020-07-13 14:12:00.000000";
+//
+//        String allPointsBeginTime = "2020-07-15 11:25:00.000000";
+//        String allPointsEndTime = "2020-07-15 11:27:00.000000";
+
+        //B3
+//        String realShapeBeginTime = "2020-07-13 14:15:00.000000";
+//        String realShapeEndTime = "2020-07-13 14:20:00.000000";
+//
+//        String allPointsBeginTime = "2020-07-15 11:33:00.000000";
+//        String allPointsEndTime = "2020-07-15 11:36:00.000000";
+
+
+//        A03
+//        String realShapeBeginTime = "2020-07-13 14:27:00.000000";
+//        String realShapeEndTime = "2020-07-13 14:30:00.000000";
+//
+//        String allPointsBeginTime = "2020-07-15 11:46:00.000000";
+//        String allPointsEndTime = "2020-07-15 11:49:00.000000";
+
+//        //A17
+//        String realShapeBeginTime = "2020-07-13 14:37:00.000000";
+//        String realShapeEndTime = "2020-07-13 14:40:00.000000";
+//
+//        String allPointsBeginTime = "2020-07-15 11:41:00.000000";
+//        String allPointsEndTime = "2020-07-15 11:44:00.000000";
+
+//        A08
+        String realShapeBeginTime = "2020-07-22 14:58:00.000000";
+        String realShapeEndTime = "2020-07-22 15:04:00.000000";
+
+        String allPointsBeginTime = "2020-07-24 20:17:00.000000";
+        String allPointsEndTime = "2020-07-25 07:36: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')";

+ 97 - 0
src/test/OperateFile.java

@@ -0,0 +1,97 @@
+package test;
+
+import test.entity.Point;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.util.ArrayList;
+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 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();
+
+    }
+
+
+
+
+}

+ 100 - 65
src/test/Split.java

@@ -5,6 +5,7 @@ import test.entity.OccupyPerX;
 import test.entity.Point;
 import test.entity.WholeIndexOccupy;
 
+import java.io.FileNotFoundException;
 import java.util.ArrayList;
 
 public class Split {
@@ -24,22 +25,22 @@ public class Split {
 
 
     //输入垛位的初始实际形状,形成网格
-    public void cal(ArrayList<Point> pointsList){
-
-
-
+    public void cal(ArrayList<Point> pointsList) throws FileNotFoundException {
 
         pointsList.add(pointsList.get(0));
 
-        System.out.println("print initial points-----------------");
-        for (int i = 0 ; i < pointsList.size(); i++){
-
-            Point point = pointsList.get(i);
-            System.out.println(point.getColX() + " " + point.getColY());
-
-        }
+        OperateFile operateFile = new OperateFile();
+        operateFile.printPoint("Y:\\initial.txt",pointsList);
 
-        System.out.println("print initial points end--------------");
+//        System.out.println("print initial points-----------------");
+//        for (int i = 0 ; i < pointsList.size(); i++){
+//
+//            Point point = pointsList.get(i);
+//            System.out.println(point.getColX() + " " + point.getColY());
+//
+//        }
+//
+//        System.out.println("print initial points end--------------");
 
 
         Point point0 = pointsList.get(0);
@@ -128,14 +129,14 @@ public class Split {
     public void decideIndex(ArrayList<Point> fourPointsList){
 
 
-        System.out.println("test");
-        for (int i = 0 ; i < fourPointsList.size(); i++){
-
-            Point pointTemp = fourPointsList.get(i);
-            System.out.println(pointTemp.getColX() + " " + pointTemp.getColY());
-
-        }
-        System.out.println("test");
+//        System.out.println("test");
+//        for (int i = 0 ; i < fourPointsList.size(); i++){
+//
+//            Point pointTemp = fourPointsList.get(i);
+//            System.out.println(pointTemp.getColX() + " " + pointTemp.getColY());
+//
+//        }
+//        System.out.println("test");
 
         Point pointA = fourPointsList.get(0);
         Point pointB = fourPointsList.get(1);
@@ -150,8 +151,10 @@ public class Split {
         double maxX = pointC.getColX();
         double maxY = pointC.getColY();
 
-        xGap = distanceAB / numOfGaps;
-        yGap = distanceBC / numOfGaps;
+        xGap = (maxX - minX) / numOfGaps;
+        System.out.println("xGap is : " + xGap);
+        yGap = (maxY - minY) / numOfGaps;
+        System.out.println("yGap is : " + yGap);
 
 //        ArrayList<Double> xIndexCorList = new ArrayList<>();//格点横坐标List
 //        ArrayList<Double> yIndexCorList = new ArrayList<>();//格点纵坐标List
@@ -177,6 +180,14 @@ public class Split {
         double corY1 = point1.getColY();
         double corX2 = point2.getColX();
         double corY2 = point2.getColY();
+        System.out.println("计算距离:");
+        System.out.println("corx1:" + corX1);
+        System.out.println("cory1:" + corY1);
+        System.out.println("corx2:" + corX2);
+        System.out.println("cory2:" + corY2);
+        System.out.println("distance");
+
+
         double distance = Math.sqrt(Math.pow((corX1 - corX2),2) + Math.pow((corY1 - corY2),2));
         return distance;
 
@@ -195,20 +206,20 @@ public class Split {
             Point pointJ = pointsList.get(i + 1);
             boolean isTest = false;
 
-            if (i == (pointsList.size() - 2)){
-
-                System.out.println("这是最后那条直线pppppppppppppppppppppppppppp");
-                System.out.println("这是最后那条直线pppppppppppppppppppppppppppp");
-                System.out.println("这是最后那条直线pppppppppppppppppppppppppppp");
-                System.out.println("这是最后那条直线pppppppppppppppppppppppppppp");
-
-
-                System.out.println(pointI.getColX() + " " + pointI.getColY());
-                System.out.println(pointJ.getColX() + " " + pointJ.getColY());
-
-                isTest = true;
-
-            }
+//            if (i == (pointsList.size() - 2)){
+//
+//                System.out.println("这是最后那条直线pppppppppppppppppppppppppppp");
+//                System.out.println("这是最后那条直线pppppppppppppppppppppppppppp");
+//                System.out.println("这是最后那条直线pppppppppppppppppppppppppppp");
+//                System.out.println("这是最后那条直线pppppppppppppppppppppppppppp");
+//
+//
+//                System.out.println(pointI.getColX() + " " + pointI.getColY());
+//                System.out.println(pointJ.getColX() + " " + pointJ.getColY());
+//
+//                isTest = true;
+//
+//            }
 
 
 
@@ -245,9 +256,6 @@ public class Split {
 
 
 
-
-
-
         ///
 
 
@@ -280,29 +288,35 @@ public class Split {
 
         }
 
-        if (isTest){
-
-            System.out.println("ISTEST起始横向网格" + xIndexBegin);
-            System.out.println("ISTEST终止横向网格" + xIndexEnd);
-            System.out.println("ISTEST起始纵向网格" + lineYIndexMin);
-            System.out.println("ISTEST终止纵向网格" + lineYIndexMax);
-            System.out.println("直线参数为:" + lineParamList);
-
-            ///测试直线
-            Double xTest = pointI.getColX();
-            Double yTest = pointI.getColY();
-            Double yTestResult = tool.getLineYValue(xTest,lineParamList);
-            System.out.println("xtest:" + xTest);
-            System.out.println("ytest:" + yTest);
-            System.out.println("ytestresult:" + yTestResult);
-
-        }
+//        if (isTest){
+//
+//            System.out.println("ISTEST起始横向网格" + xIndexBegin);
+//            System.out.println("ISTEST终止横向网格" + xIndexEnd);
+//            System.out.println("ISTEST起始纵向网格" + lineYIndexMin);
+//            System.out.println("ISTEST终止纵向网格" + lineYIndexMax);
+//            System.out.println("直线参数为:" + lineParamList);
+//
+//            ///测试直线
+//            Double xTest = pointI.getColX();
+//            Double yTest = pointI.getColY();
+//            Double yTestResult = tool.getLineYValue(xTest,lineParamList);
+//            System.out.println("xtest:" + xTest);
+//            System.out.println("ytest:" + yTest);
+//            System.out.println("ytestresult:" + yTestResult);
+//
+//        }
 
 
 
         //对该格点跨越的所有横向网格序号作循环
         for (int i = xIndexBegin;i < xIndexEnd + 1; i++){
 
+            if (i == 100){
+                System.out.println(xIndexBegin);
+                System.out.println(xIndexEnd);
+                System.out.println(pointJ.getColX());
+            }
+
 
 
             //计算该直线(线段)在当前横向的网格内,在纵向的占据情况
@@ -376,12 +390,12 @@ public class Split {
                 occupyPerX.setMinYIndex(yIndexMin);
 
 
-                if (isTest){
+//                if (isTest){
 
-                    System.out.println("当前横向网格序号" + i);
+//                    System.out.println("当前横向网格序号" + i);
 //                    System.out.println("当前纵向网格序号" + );
 
-                    System.out.println(xInputBegin + " " + yOutBegin);
+//                    System.out.println(xInputBegin + " " + yOutBegin);
 
 //                    System.out.println("当前网格的起始横坐标:" + xInputBegin);
 //                    System.out.println("当前网格的终止横坐标:" + xInputEnd);
@@ -392,7 +406,7 @@ public class Split {
 //                    System.out.println("直线在当前网格内的纵向最小网格号:" + yIndexMin);
 //                    System.out.println("直线在当前网格内的纵向最大网格号:" + yIndexMax);
 
-                }
+//                }
 
             }
 
@@ -420,6 +434,7 @@ public class Split {
         //网格的起始x
         Double minX = xIndexCorList.get(0);
 
+
 //        //网格的终止x
 //        Double maxX = xIndexCorList.get(xIndexCorList.size());
 
@@ -429,16 +444,29 @@ public class Split {
         Double xIndexTemp = (pointX - minX) / xGap;
         Double yIndexTemp = (pointY - minY) / yGap;
 
+        if (xIndexTemp > 100){
 
+            System.out.println(1111111111);
+            System.out.println("x is :" + pointX);
+            System.out.println("minx is : " + minX);
+            System.out.println("xgap is :" + xGap);
+            System.out.println("x - minx = " + (pointX - minX));
+            System.out.println("result is " + (pointX - minX) / xGap);
 
-        Integer xIndex = xIndexTemp.intValue();
-        Integer yIndex = yIndexTemp.intValue();
+        }
 
-        if (xIndex == 100){
+//        System.out.println("pointx: " + pointX +" - " +"minx: " + minX + " = " + (pointX - minX));
+//        System.out.println("(pointX - minX) / xGap: " + xIndexTemp);
 
-            System.out.println(1111111 + "  " + pointX + " " + xIndexTemp);
 
-        }
+        Integer xIndex = xIndexTemp.intValue();
+        Integer yIndex = yIndexTemp.intValue();
+
+//        if (xIndex == 100){
+//
+//            System.out.println(1111111 + "  " + pointX + " " + xIndexTemp);
+//
+//        }
 
         Index index = new Index();
 
@@ -482,6 +510,13 @@ public class Split {
         Double xMin = xIndexCorList.get(0);
         Double xIndexTemp = (xCor - xMin)/xGap;
         Integer xIndex = xIndexTemp.intValue();
+
+        if (xIndex >= 100){
+
+            xIndex = 99;
+
+        }
+
         return xIndex;
 
 

+ 2 - 1
src/test/TestMain.java

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

+ 1 - 1
src/test/Tool.java

@@ -58,7 +58,7 @@ public class Tool {
         Double lineA = lineParamList.get(0);
         Double lineC = lineParamList.get(2);
 
-        System.out.println();
+//        System.out.println();
 
         Double y = lineA * x + lineC;
         return y;

+ 13 - 7
src/test/entity/WholeIndexOccupy.java

@@ -1,5 +1,8 @@
 package test.entity;
 
+import test.OperateFile;
+
+import java.io.FileNotFoundException;
 import java.util.ArrayList;
 
 public class WholeIndexOccupy {
@@ -69,9 +72,9 @@ public class WholeIndexOccupy {
 
     }
 
-    public void printOccupy(Double minX,Double minY,Double xGap,Double yGap){
+    public void printOccupy(Double minX,Double minY,Double xGap,Double yGap) throws FileNotFoundException {
 
-        System.out.println("print REAL-----------------------");
+//        System.out.println("print REAL-----------------------");
 
         ArrayList<Point> printPointList = new ArrayList<>();
 
@@ -118,17 +121,20 @@ public class WholeIndexOccupy {
 
         printPointList.add(printPointList.get(0));
 
-        for (int i =0;i< printPointList.size();i++){
+//        for (int i =0;i< printPointList.size();i++){
 
-            Point point = printPointList.get(i);
-            System.out.println(point.getColX() + " " + point.getColY());
+//            Point point = printPointList.get(i);
+////            System.out.println(point.getColX() + " " + point.getColY());
+//
+//        }
 
-        }
 
 
 
+//        System.out.println("print REAL end-----------");
 
-        System.out.println("print REAL end-----------");
+        OperateFile operateFile = new OperateFile();
+        operateFile.printPoint("Y:\\occupy.txt",printPointList);
 
 
         }