16s01 4 سال پیش
والد
کامیت
e0c642d238
6فایلهای تغییر یافته به همراه247 افزوده شده و 34 حذف شده
  1. 9 0
      meanshift.iml
  2. 48 7
      src/test/Cal.java
  3. 2 2
      src/test/GetPoints.java
  4. 118 23
      src/test/Split.java
  5. 4 1
      src/test/Tool.java
  6. 66 1
      src/test/entity/WholeIndexOccupy.java

+ 9 - 0
meanshift.iml

@@ -7,5 +7,14 @@
     </content>
     <orderEntry type="inheritedJdk" />
     <orderEntry type="sourceFolder" forTests="false" />
+    <orderEntry type="module-library" exported="">
+      <library>
+        <CLASSES>
+          <root url="jar://$MAVEN_REPOSITORY$/jdbc8/ojdbc8.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES />
+      </library>
+    </orderEntry>
   </component>
 </module>

+ 48 - 7
src/test/Cal.java

@@ -21,6 +21,8 @@ public class Cal {
 
 
 
+
+
 //        GetPoints getPoints = new GetPoints();//所有待计算点
         ArrayList<Point> allPoints = getPoints.allPoints;//所有待计算点,铲车作业平面坐标
         Split split = new Split();
@@ -29,6 +31,9 @@ public class Cal {
         ArrayList<Double> xIndexCorList = split.xIndexCorList;//格点横坐标List
         ArrayList<Double> yIndexCorList = split.yIndexCorList;//格点纵坐标List
         WholeIndexOccupy wholeIndexOccupy = split.wholeIndexOccupy;//初始垛位的占用情况
+
+//        wholeIndexOccupy.printOccupy();
+
         Double xGap = split.xGap;//横向上采用的间隔
         Double yGap = split.yGap;//纵向上采用的间隔
 
@@ -36,6 +41,7 @@ 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<>();//过滤后的所有点的坐标
@@ -60,12 +66,18 @@ public class Cal {
         ArrayList<ArrayList<Integer>> occupyList = changeWholeIndexOccupyToList(wholeIndexOccupy);
 
 
+        System.out.println("print all points---------------" );
 
         for (int i = 0; i < pointAfterExclude.size();i++){
 
             Point point = pointAfterExclude.get(i);
             Double x = point.getColX();
             Double y = point.getColY();
+
+
+            System.out.println( x + " " + y);
+
+
             Integer xIndex = split.identifyXIndex(x);
             Integer yIndex = split.identifyYIndex(y);
 
@@ -81,6 +93,7 @@ public class Cal {
 
 
         }
+        System.out.println("print all points end -----------");
 
 
 
@@ -90,8 +103,33 @@ public class Cal {
         for (int i = 0 ; i < occupyList.size();i++){
 
             ArrayList<Integer> arrayList = occupyList.get(i);
-            String arrayListString = arrayList.toString();
-            String[] arrays = arrayListString.split("0");
+
+            StringBuffer sb = new StringBuffer();
+            for (int jj = 0 ; jj < arrayList.size();jj++){
+
+
+                if (arrayList.get(jj).toString().equals("0")){
+                    sb.append(" ");
+                }
+                else {
+                    sb.append(arrayList.get(jj).toString());
+                }
+
+
+            }
+
+
+            String arrayListString = sb.toString();
+
+            System.out.println("print string----------" + arrayListString);
+            String[] arrays = arrayListString.split("\\s+");
+//
+//            for (int k = 0;k < arrays.length;k++){
+//
+//                System.out.println(arrays[k]);
+//
+//            }
+
             String maxString ="";
 
 
@@ -123,7 +161,7 @@ public class Cal {
             OccupyPerX occupyPerX = occupyPerXArrayList.get(i);
             Double xCor = minX + i * xGap + 0.5 * xGap;
             Integer yIndex = occupyPerX.maxYIndex;
-            Double yCor = minY + i * yGap + 0.5 * yGap;
+            Double yCor = minY + yIndex * yGap + 0.5 * yGap;
             Point point = new Point();
             point.setColX(xCor);
             point.setColY(yCor);
@@ -131,12 +169,12 @@ public class Cal {
             shape.add(point);
         }
 
-        for (int i = 0 ; i < occupyPerXArrayList.size();i++){
+        for (int i = (occupyPerXArrayList.size() -1) ; i >=0;i--){
 
             OccupyPerX occupyPerX = occupyPerXArrayList.get(i);
             Double xCor = minX + i * xGap + 0.5 * xGap;
             Integer yIndex = occupyPerX.minYIndex;
-            Double yCor = minY + i * yGap + 0.5 * yGap;
+            Double yCor = minY + yIndex * yGap + 0.5 * yGap;
             Point point = new Point();
             point.setColX(xCor);
             point.setColY(yCor);
@@ -144,11 +182,14 @@ public class Cal {
             shape.add(point);
         }
 
+        shape.add(shape.get(0));
+
 
+//        System.out.println(shape.size());
         for (int i = 0 ; i < shape.size() ; i++){
 
-            System.out.println(shape.get(i).getColX());
-            System.out.println(shape.get(i).getColY());
+            System.out.println(shape.get(i).getColX() + " " + shape.get(i).getColY() );
+//            System.out.println(shape.get(i).getColY());
 
         }
         return shape;

+ 2 - 2
src/test/GetPoints.java

@@ -35,10 +35,10 @@ public class GetPoints {
 
 
         String realShapeBeginTime = "2020-07-09 15:06:00.000000";
-        String realShapeEndTime = "2020-07-09 15:07: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:40:00.000000";
+        String allPointsEndTime = "2020-07-12 06:41: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')";

+ 118 - 23
src/test/Split.java

@@ -26,8 +26,22 @@ public class Split {
     //输入垛位的初始实际形状,形成网格
     public void cal(ArrayList<Point> pointsList){
 
+
+
+
         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());
+
+        }
+
+        System.out.println("print initial points end--------------");
+
+
         Point point0 = pointsList.get(0);
 
         double minX = point0.getColX();
@@ -113,6 +127,16 @@ 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");
+
         Point pointA = fourPointsList.get(0);
         Point pointB = fourPointsList.get(1);
         Point pointC = fourPointsList.get(2);
@@ -164,11 +188,29 @@ public class Split {
 
 
 
-        for (int i = 0 ; i< pointsList.size() - 1;i++){
+        for (int i = 0 ; i < (pointsList.size() - 1);i++){
 
             //两个点形成直线
             Point pointI = pointsList.get(i);
             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;
+
+            }
+
+
 
             //直线一般式相关的参数,A,B,C
             ArrayList<Double> lineParamList  = tool.calLineabc(pointI,pointJ);
@@ -183,9 +225,9 @@ public class Split {
 //            Double pointJy = pointJ.getColY();
 
             //该直线起始点的网格位置
-            Index indexI = identifyIndex(pointI);
-            Index indexJ = identifyIndex(pointJ);
-            lineOccupy(pointI,pointJ,lineParamList);
+//            Index indexI = identifyIndex(pointI);
+//            Index indexJ = identifyIndex(pointJ);
+            lineOccupy(pointI,pointJ,lineParamList,isTest);
 
 
 
@@ -196,12 +238,19 @@ public class Split {
     }
 
     //计算直线在各个网格内的占据情况
-    public void lineOccupy(Point pointI,Point pointJ,ArrayList<Double> lineParamList){
+    public void lineOccupy(Point pointI,Point pointJ,ArrayList<Double> lineParamList,Boolean isTest){
 
         Double xMin = xIndexCorList.get(0);
         Double yMin = yIndexCorList.get(0);
 
 
+
+
+
+
+        ///
+
+
         //该直线起始点的网格位置
         Index indexI = identifyIndex(pointI);
         Index indexJ = identifyIndex(pointJ);
@@ -217,11 +266,45 @@ public class Split {
         Integer lineYIndexMin = Math.min(yIndexBegin,yIndexEnd);
 
 
+        Integer lineXIndexMax = Math.max(xIndexBegin,xIndexEnd);
+        Integer lineXIndexMin = Math.min(xIndexBegin,xIndexEnd);
+
+
+        //
+        if (xIndexBegin > xIndexEnd){
+
+            Integer temp;
+            temp = xIndexBegin;
+            xIndexBegin = xIndexEnd;
+            xIndexEnd = temp;
+
+        }
+
+        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++){
 
+
+
             //计算该直线(线段)在当前横向的网格内,在纵向的占据情况
 
             Integer minYIndex;
@@ -240,39 +323,32 @@ public class Split {
 
             xInputBegin = xMin + xGap * i;//当前网格的起始横坐标
             xInputEnd = xInputBegin + xGap;//当前网格的终止横坐标
+
+
+
+//            if (isTest){
+//
+//                System.out.println("当前网格的起始横坐标:" + xInputBegin);
+//                System.out.println("当前网格的终止横坐标:" + xInputEnd);
+//
+//            }
+
             OccupyPerX occupyPerX =  new OccupyPerX();
 
 //            if ((Double.POSITIVE_INFINITY == lineParamList.get(0) || Double.NEGATIVE_INFINITY == lineParamList.get(0))){
 //
 //                System.out.println(111111);
 //            }
+
             if ((lineParamList.size()!=0) && !(Double.POSITIVE_INFINITY == lineParamList.get(0) || Double.NEGATIVE_INFINITY == lineParamList.get(0))){
 
                 yOutBegin = tool.getLineYValue(xInputBegin,lineParamList);//当前网格的起始纵坐标
-//                if (yOutBegin > lineYIndexMax){
-//
-//                    yOutBegin = lineYIndexMax;
-//                }
 
                 yOutEnd = tool.getLineYValue(xInputEnd,lineParamList);//当前网格的终止纵坐标
-//                System.out.println(lineParamList);
-//                System.out.println("begin x: " + xInputBegin + " y: " + yOutBegin);
-//                System.out.println("end x: " + xInputEnd + " y: " + yOutEnd);
 
                 Integer yBeginIndex = identifyYIndex(yOutBegin);
                 Integer yEndIndex = identifyYIndex(yOutEnd);
 
-//                if (yBeginIndex > lineYIndexMax){
-//
-//                    yBeginIndex = lineYIndexMax;
-//
-//                }
-//
-//                if (yBeginIndex < lineYIndexMin){
-//
-//                    yBeginIndex = ;
-//
-//                }
 
                 yBeginIndex = Math.min(yBeginIndex,lineYIndexMax);
                 yBeginIndex = Math.max(yBeginIndex,lineYIndexMin);
@@ -299,6 +375,25 @@ public class Split {
                 occupyPerX.setMaxYIndex(yIndexMax);
                 occupyPerX.setMinYIndex(yIndexMin);
 
+
+                if (isTest){
+
+                    System.out.println("当前横向网格序号" + i);
+//                    System.out.println("当前纵向网格序号" + );
+
+                    System.out.println(xInputBegin + " " + yOutBegin);
+
+//                    System.out.println("当前网格的起始横坐标:" + xInputBegin);
+//                    System.out.println("当前网格的终止横坐标:" + xInputEnd);
+//                    System.out.println("当前网格的起始纵坐标:" + yOutBegin);
+//                    System.out.println("当前网格的终止纵坐标:" + yOutEnd);
+//
+//
+//                    System.out.println("直线在当前网格内的纵向最小网格号:" + yIndexMin);
+//                    System.out.println("直线在当前网格内的纵向最大网格号:" + yIndexMax);
+
+                }
+
             }
 
             else {

+ 4 - 1
src/test/Tool.java

@@ -27,7 +27,7 @@ public class Tool {
 
             lineA = (y1 - y2) / (x1 - x2);
             lineB = -1.0;
-            lineC = y1 - lineA * x2;
+            lineC = y1 - lineA * x1;
             lineParamList.add(lineA);
             lineParamList.add(lineB);
             lineParamList.add(lineC);
@@ -57,6 +57,9 @@ public class Tool {
 
         Double lineA = lineParamList.get(0);
         Double lineC = lineParamList.get(2);
+
+        System.out.println();
+
         Double y = lineA * x + lineC;
         return y;
 

+ 66 - 1
src/test/entity/WholeIndexOccupy.java

@@ -69,6 +69,71 @@ public class WholeIndexOccupy {
 
     }
 
+    public void printOccupy(Double minX,Double minY,Double xGap,Double yGap){
+
+        System.out.println("print REAL-----------------------");
+
+        ArrayList<Point> printPointList = new ArrayList<>();
+
+        for (int i = 0 ; i < occupyPerXArrayList.size();i++){
+
+            OccupyPerX occupyPerX = occupyPerXArrayList.get(i);
+            Integer minYIndex = occupyPerX.getMinYIndex();
+            Integer maxYIndex = occupyPerX.getMaxYIndex();
+            if (maxYIndex != -1 && minYIndex !=1000){
+
+                Double xCor = minX + i * xGap + 0.5 * xGap;
+                Double yCor = minY + maxYIndex * yGap + 0.5 * yGap;
+
+                Point point = new Point();
+                point.setColX(xCor);
+                point.setColY(yCor);
+                printPointList.add(point);
+//                System.out.println(xCor + " " + yCor);
+
+
+            }
+
+            }
+
+        for (int i = occupyPerXArrayList.size() -1 ; i >=0 ;i--){
+
+            OccupyPerX occupyPerX = occupyPerXArrayList.get(i);
+            Integer minYIndex = occupyPerX.getMinYIndex();
+            Integer maxYIndex = occupyPerX.getMaxYIndex();
+            if (maxYIndex != -1 && minYIndex !=1000){
+
+                Double xCor = minX + i * xGap + 0.5 * xGap;
+                Double yCor = minY + minYIndex * yGap + 0.5 * yGap;
+
+                Point point = new Point();
+                point.setColX(xCor);
+                point.setColY(yCor);
+                printPointList.add(point);
+
+//                System.out.println(xCor + " " + yCor);
+            }
+
+        }
+
+        printPointList.add(printPointList.get(0));
+
+        for (int i =0;i< printPointList.size();i++){
+
+            Point point = printPointList.get(i);
+            System.out.println(point.getColX() + " " + point.getColY());
+
+        }
+
+
+
+
+        System.out.println("print REAL end-----------");
+
+
+        }
+
+    }
 
 //    public void cleanDirtyData(){
 //
@@ -83,4 +148,4 @@ public class WholeIndexOccupy {
 //    }
 
 
-}
+//}