haoqianpan 4 years ago
parent
commit
78b461ac72
32 changed files with 1697 additions and 424 deletions
  1. 16 4
      meanshift.iml
  2. 39 0
      pom.xml
  3. 5 5
      src/main/java/TestMeanShift.java
  4. 4 2
      src/main/java/index/TestMain.java
  5. 230 0
      src/main/java/index/adjust/Adjust.java
  6. 43 0
      src/main/java/index/adjust/PointXYCorRevise.java
  7. 177 138
      src/main/java/index/alg/Cal.java
  8. 16 3
      src/main/java/index/alg/CurveTool.java
  9. 308 0
      src/main/java/index/alg/GetPoints.java
  10. 28 0
      src/main/java/index/alg/Special.java
  11. 20 47
      src/main/java/index/alg/Split.java
  12. 110 0
      src/main/java/index/alg/boxscan/GetAllEdge.java
  13. 293 0
      src/main/java/index/alg/boxscan/ScanOutLine.java
  14. 1 1
      src/main/java/index/db/ConnectToSourceDB.java
  15. 5 5
      src/main/java/index/db/DbOperate.java
  16. 42 0
      src/main/java/index/entity/Box.java
  17. 55 0
      src/main/java/index/entity/BoxEdge.java
  18. 8 1
      src/main/java/index/entity/GpsCor.java
  19. 1 1
      src/main/java/index/entity/Index.java
  20. 1 1
      src/main/java/index/entity/OccupyPerX.java
  21. 1 1
      src/main/java/index/entity/Point.java
  22. 56 30
      src/main/java/index/entity/WholeIndexOccupy.java
  23. 18 29
      src/main/java/index/file/OperateFile.java
  24. 207 0
      src/main/java/index/fit/Fit.java
  25. 1 1
      src/main/java/index/gps/GpsConvertMethod.java
  26. 2 3
      src/main/java/index/gps/GpsExchange.java
  27. 2 0
      src/main/java/shift/CalculateArea.java
  28. 2 0
      src/main/java/shift/DataType.java
  29. 2 0
      src/main/java/shift/MeanShift.java
  30. 2 0
      src/main/java/shift/ReadData.java
  31. 2 0
      src/main/java/shift/ResultDataType.java
  32. 0 152
      src/test/GetPoints.java

+ 16 - 4
meanshift.iml

@@ -1,9 +1,13 @@
 <?xml version="1.0" encoding="UTF-8"?>
-<module type="JAVA_MODULE" version="4">
-  <component name="NewModuleRootManager" inherit-compiler-output="true">
-    <exclude-output />
+<module org.jetbrains.idea.maven.project.MavenProjectsManager.isMavenModule="true" type="JAVA_MODULE" version="4">
+  <component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_1_7">
+    <output url="file://$MODULE_DIR$/target/classes" />
+    <output-test url="file://$MODULE_DIR$/target/test-classes" />
     <content url="file://$MODULE_DIR$">
-      <sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
+      <sourceFolder url="file://$MODULE_DIR$/src/main/java" isTestSource="false" />
+      <sourceFolder url="file://$MODULE_DIR$/src/main/resources" type="java-resource" />
+      <sourceFolder url="file://$MODULE_DIR$/src/test/java" isTestSource="true" />
+      <excludeFolder url="file://$MODULE_DIR$/target" />
     </content>
     <orderEntry type="inheritedJdk" />
     <orderEntry type="sourceFolder" forTests="false" />
@@ -16,5 +20,13 @@
         <SOURCES />
       </library>
     </orderEntry>
+    <orderEntry type="library" name="Maven: com.oracle.ojdbc:ojdbc8:19.3.0.0" level="project" />
+    <orderEntry type="library" name="Maven: com.oracle.ojdbc:ucp:19.3.0.0" level="project" />
+    <orderEntry type="library" name="Maven: com.oracle.ojdbc:oraclepki:19.3.0.0" level="project" />
+    <orderEntry type="library" name="Maven: com.oracle.ojdbc:osdt_cert:19.3.0.0" level="project" />
+    <orderEntry type="library" name="Maven: com.oracle.ojdbc:osdt_core:19.3.0.0" level="project" />
+    <orderEntry type="library" name="Maven: com.oracle.ojdbc:simplefan:19.3.0.0" level="project" />
+    <orderEntry type="library" name="Maven: com.oracle.ojdbc:ons:19.3.0.0" level="project" />
+    <orderEntry type="library" name="Maven: org.apache.commons:commons-math3:3.6.1" level="project" />
   </component>
 </module>

+ 39 - 0
pom.xml

@@ -0,0 +1,39 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+    <modelVersion>4.0.0</modelVersion>
+
+    <groupId>groupId</groupId>
+    <artifactId>meanshift</artifactId>
+    <version>1.0-SNAPSHOT</version>
+    <build>
+        <plugins>
+            <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-compiler-plugin</artifactId>
+                <configuration>
+                    <source>7</source>
+                    <target>7</target>
+                </configuration>
+            </plugin>
+        </plugins>
+    </build>
+
+    <dependencies>
+
+        <dependency>
+            <groupId>com.oracle.ojdbc</groupId>
+            <artifactId>ojdbc8</artifactId>
+            <version>19.3.0.0</version>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.commons</groupId>
+            <artifactId>commons-math3</artifactId>
+            <version>3.6.1</version>
+        </dependency>
+
+    </dependencies>
+
+    
+</project>

+ 5 - 5
src/TestMeanShift.java → src/main/java/TestMeanShift.java

@@ -9,14 +9,14 @@
 //        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");
+//        java.io.File file2 = new java.io.File("C:\\Users\\87969\\Desktop\\test\\shift.MeanShift.txt");
 //        PrintWriter Result_OutPut = new PrintWriter(file2);
-//        ReadData readData = new ReadData();
+//        shift.ReadData readData = new shift.ReadData();
 //        readData.Read();
-//        MeanShift meanShift = new MeanShift();
+//        shift.MeanShift meanShift = new shift.MeanShift();
 //        meanShift.setPointxAndPointy(readData.pointx_input,readData.pointy_input);
 //        meanShift.setR(RusedforMeanshift);
-//        ArrayList<ResultDataType> result ;
+//        ArrayList<shift.ResultDataType> result ;
 //        result = meanShift.mainLoop();
 //        for(int i = 0 ; i < result.size();i++){
 //            Result_OutPut.println(result.get(i).numOfPoint);
@@ -26,7 +26,7 @@
 //        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);
+//        shift.CalculateArea calculateArea = new shift.CalculateArea(pointx_input,pointy_input,centerx_history_forArea,centery_history_forArea);
 //        calculateArea.setRusedforMeanShift(RusedforMeanshift);
 //        calculateArea.setSplitTheta(Math.PI / 180);
 //        calculateArea.setSplitRadiusWidth(0.3 * RusedforMeanshift);

+ 4 - 2
src/test/TestMain.java → src/main/java/index/TestMain.java

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

+ 230 - 0
src/main/java/index/adjust/Adjust.java

@@ -0,0 +1,230 @@
+package index.adjust;
+
+import index.entity.Point;
+
+import index.fit.Fit;
+
+import java.util.ArrayList;
+
+import java.util.HashMap;
+
+import java.util.Map;
+
+public class Adjust {
+
+//    public ArrayList<Point> fillSmall(ArrayList<Point> pointArrayList){
+//
+//        for (int i = 0 ; i < pointArrayList.size();i++){
+//
+//            Point point = pointArrayList.get()
+//
+//        }
+//
+//    }
+
+    public ArrayList<Point> adjustShape(ArrayList<Point> initialShapeList,ArrayList<Point> changedShapeList,Integer adjustSize){
+
+//        Integer size = initialShapeList.size() - 1;
+        Integer size = initialShapeList.size();
+//
+        System.out.println(size + "size");
+
+        ArrayList<Point> afterAdjustPointsList = new ArrayList<>();
+
+        Integer round = size / adjustSize;
+
+        System.out.println(round + "round");
+
+        for (int i = 0; i < round ;i++){
+
+            Integer indexBegin = i * adjustSize;
+            Integer indexEnd = indexBegin + adjustSize;
+
+            Double avgDec = 0.0;
+            //
+            ArrayList<Point> pointArrayList = new ArrayList<>();//存放差值,借用arraylist<point>
+
+
+            for (int j = indexBegin;j < indexEnd; j++){
+                Point iniPoint = initialShapeList.get(j);
+                Point chaPoint = changedShapeList.get(j);
+                Point pointDis = new Point();
+                pointDis.setColY(chaPoint.getColY() - iniPoint.getColY());
+                pointDis.setColX(chaPoint.getColX());
+                pointArrayList.add(pointDis);
+                avgDec = avgDec + chaPoint.getColY() - iniPoint.getColY();
+                System.out.println("差值" + (chaPoint.getColY() - iniPoint.getColY()));
+            }
+
+
+//            double[] param = fit.gaussFit(pointArrayList);
+            //求高斯分布值
+//            Gaussian gaussian = new Gaussian(param[0],param[1],param[2]);
+//            ArrayList<Double> dPoint = new ArrayList<>();
+//            for (int ii = 0 ; ii < pointArrayList.size();ii++){
+//
+//                Point point = pointArrayList.get(ii);
+//                Double x = point.getColX();
+//                Double y = gaussian.value(x);
+//                dPoint.add(y);
+//
+//            }
+
+
+
+            avgDec = avgDec / adjustSize;
+//            System.out.println(avgDec + " avgdec");
+
+            for (int j = indexBegin ; j < indexEnd;j++){
+
+//                Point chaPoint = changedShapeList.get(j);
+                Point intPoint = initialShapeList.get(j);
+                Point adjustPoint = new Point();
+                adjustPoint.setColX(intPoint.getColX());
+                adjustPoint.setColY(intPoint.getColY() + avgDec);
+//                adjustPoint.setColY(intPoint.getColY() + gaussian.value(intPoint.getColX()));
+//                System.out.println(new Date());
+
+                afterAdjustPointsList.add(adjustPoint);
+            }
+            //后面扩充不整除的情况
+        }
+//        afterAdjustPointsList.add(afterAdjustPointsList.get(0));
+        return afterAdjustPointsList;
+    }
+
+    //输入的list都已经处理过,是图形的一半
+    public ArrayList<Point> fillZero(ArrayList<Point> initialShapeList,ArrayList<Point> changedShapeList,Integer scale) {
+
+        ArrayList<Double> diffValueList = new ArrayList<>();
+
+        ArrayList<Map> nonZeroDiffInfoMapList = new ArrayList<>();
+
+        for (int i = 0 ; i < changedShapeList.size();i++){
+
+            Point chaPoint = changedShapeList.get(i);
+
+            Point iniPoint = initialShapeList.get(i);
+
+            Double diff = chaPoint.getColY() - iniPoint.getColY();
+
+            diffValueList.add(diff);
+
+        }
+
+        for (int i = 0;i < diffValueList.size();i++){
+            Double diff = diffValueList.get(i);
+            if (!isCloseToZero(diff)){
+
+                System.out.println("diff: " + diff + " iszero? " + isCloseToZero(diff));
+
+                Map nonZeroInfoMap = new HashMap();
+
+                nonZeroInfoMap.put("INDEX",i);
+
+                nonZeroDiffInfoMapList.add(nonZeroInfoMap);
+
+            }
+        }
+
+        //记录下需要填充的列的信息
+        if (nonZeroDiffInfoMapList.size() >=2){
+
+            for (int i = 0 ; i < nonZeroDiffInfoMapList.size() - 1; i++){
+
+                Map map1 = nonZeroDiffInfoMapList.get(i);
+                Map map2 = nonZeroDiffInfoMapList.get(i+1);
+                Integer index1 = (int)map1.get("INDEX");
+                Integer index2 = (int)map2.get("INDEX");
+
+                System.out.println("index1:" + index1);
+                System.out.println("index2:" + index2);
+
+                Double beginDiff = diffValueList.get(index1);
+                Double endDiff = diffValueList.get(index2);
+
+                Double gap = (endDiff - beginDiff) / (index2 - index1);
+
+                if ((index2 - index1 <= scale) && ((index2 - index1) != 1)){
+
+                    for (int j = index1 + 1; j < index2;j++){
+
+                        diffValueList.set(j,beginDiff + (j - index1) * gap);
+
+                    }
+
+                }
+
+
+            }
+
+        }
+
+        /////
+
+        for (int i = 0 ; i < initialShapeList.size();i++){
+
+            Point point = new Point();
+
+            Point iniPoint = initialShapeList.get(i);
+
+            point.setColX(iniPoint.getColX());
+
+            point.setColY(iniPoint.getColY() + diffValueList.get(i));
+
+            changedShapeList.set(i,point);
+        }
+
+        return changedShapeList;
+
+    }
+
+    //首尾相连的list
+    public ArrayList<Point> fillArrayListPlus(ArrayList<Point> initialShapeList,ArrayList<Point> changedShapeList,Integer scale){
+
+        Fit fit = new Fit();
+        initialShapeList = removeLastPoint(initialShapeList);
+        changedShapeList = removeLastPoint(changedShapeList);
+        Integer listLength = initialShapeList.size();
+        ArrayList<Point> subInitialShapeList1 = fit.getSubArrayList(initialShapeList,0,listLength / 2);
+        ArrayList<Point> subInitialShapeList2 = fit.getSubArrayList(initialShapeList,listLength / 2,listLength);
+        ArrayList<Point> subChangedShapeList1 = fit.getSubArrayList(changedShapeList,0,listLength / 2);
+        ArrayList<Point> subChangedShapeList2 = fit.getSubArrayList(changedShapeList,listLength / 2 ,listLength);
+
+        ArrayList<Point> subChangedShapeList1New = fillZero(subInitialShapeList1,subChangedShapeList1,scale);
+        ArrayList<Point> subChangedShapeList2New = fillZero(subInitialShapeList2,subChangedShapeList2,scale);
+
+        ArrayList<Point> changedShapeListNew = new ArrayList<>();
+        changedShapeListNew.addAll(subChangedShapeList1New);
+        changedShapeListNew.addAll(subChangedShapeList2New);
+        changedShapeListNew.add(changedShapeListNew.get(0));
+        return changedShapeListNew;
+    }
+
+
+    //
+    public ArrayList<Point> removeLastPoint(ArrayList<Point> pointArrayListForRemove){
+
+        ArrayList<Point> pointArrayListAfterRemove = new ArrayList<>();
+
+        for (int i = 0 ; i < pointArrayListForRemove.size() - 1;i++){
+
+            pointArrayListAfterRemove.add(pointArrayListForRemove.get(i));
+
+        }
+
+        return pointArrayListAfterRemove;
+
+    }
+
+    public boolean isCloseToZero(Double diff){
+
+        if (Math.abs(diff) < 1){
+
+            return true;
+        }
+        else return false;
+
+    }
+
+}

+ 43 - 0
src/main/java/index/adjust/PointXYCorRevise.java

@@ -0,0 +1,43 @@
+package index.adjust;
+
+import index.entity.Point;
+
+import java.util.ArrayList;
+
+public class PointXYCorRevise {
+
+    public ArrayList<Point> revise(ArrayList<Point> pointArrayListForRevise){
+
+        ArrayList<Point> arrayListAfterRevise = new ArrayList<>();
+        for (int i = 0 ; i < pointArrayListForRevise.size();i++){
+
+            Point point = pointArrayListForRevise.get(i);
+            Point point1 = new Point();
+            point1.setColX(point.getColY());
+            point1.setColY(point.getColX());
+            arrayListAfterRevise.add(point1);
+//            pointArrayListForRevise.set(i,point);
+
+        }
+
+        return arrayListAfterRevise;
+
+    }
+
+//    public ArrayList<Point> reviseBack(ArrayList<Point> pointArrayListForRevise){
+//
+//        for (int i = 0 ; i < pointArrayListForRevise.size();i++){
+//
+//            Point point = pointArrayListForRevise.get(i);
+//            Double temp = point.getColX();
+//            point.setColX(point.getColY());
+//            point.setColY(temp);
+//            pointArrayListForRevise.set(i,point);
+//
+//        }
+//
+//        return pointArrayListForRevise;
+
+//    }
+
+}

+ 177 - 138
src/test/Cal.java → src/main/java/index/alg/Cal.java

@@ -1,87 +1,89 @@
-package test;
-
-import test.entity.OccupyPerX;
-import test.entity.Point;
-import test.entity.WholeIndexOccupy;
+package index.alg;
+
+import index.adjust.Adjust;
+import index.adjust.PointXYCorRevise;
+import index.alg.analyse.CalHpTimeDistance;
+import index.entity.OccupyPerX;
+import index.entity.Point;
+import index.entity.WholeIndexOccupy;
+import index.file.OperateFile;
+import index.fit.Fit;
+import index.plot.Plot;
+import org.apache.commons.math3.analysis.function.Gaussian;
 
 import java.io.FileNotFoundException;
-import java.lang.reflect.Array;
 import java.sql.SQLException;
 import java.util.ArrayList;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.Map;
 
 public class Cal {
-
     ArrayList<OccupyPerX> occupyPerXArrayList = new ArrayList<>();//占用情况
-
     Integer numOfGaps = 100;
+    Fit fit = new Fit();
 
-    public ArrayList<Point> calShape() throws SQLException, FileNotFoundException {
-
+    public ArrayList<Point> calShape(Integer workDirection) throws SQLException, FileNotFoundException {
         GetPoints getPoints = new GetPoints();
-        getPoints.getPoints();
-
+        getPoints.getPoints(workDirection);
         ArrayList<Point> realShapePoints = getPoints.realShapePoints;//实际形状的平面坐标
-
-
-
-
-
 //        GetPoints getPoints = new GetPoints();//所有待计算点
         ArrayList<Point> allPoints = getPoints.allPoints;//所有待计算点,铲车作业平面坐标
+
+        ///
+        ArrayList<ArrayList<Date>> dateForAna = getPoints.dateForAna;
+        CalHpTimeDistance calHpTimeDistance = new CalHpTimeDistance(dateForAna);
+        calHpTimeDistance.buildDistribution(10);
+        ///
+        System.out.println("未过滤前点数量 : " + allPoints.size() );
         Split split = new Split();
         split.cal(realShapePoints);
-
         ArrayList<Double> xIndexCorList = split.xIndexCorList;//格点横坐标List
         ArrayList<Double> yIndexCorList = split.yIndexCorList;//格点纵坐标List
         WholeIndexOccupy wholeIndexOccupy = split.wholeIndexOccupy;//初始垛位的占用情况
 //        ArrayList<Point> occupyShapeList = wholeIndexOccupy.getOccupyPointsArrayList();//坐标形式的初始形状
-
         System.out.println(occupyPerXArrayList);
-
 //        wholeIndexOccupy.printOccupy();
-
         Double xGap = split.xGap;//横向上采用的间隔
         Double yGap = split.yGap;//纵向上采用的间隔
-
         Double minX = xIndexCorList.get(0);
         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> occupyShapeList = wholeIndexOccupy.getOccupyPointsArrayList();//坐标形式的初始形状
-
-
         ArrayList<Point> pointAfterExclude = new ArrayList<>();//过滤后的所有点的坐标
-
-
-
         OperateFile operateFile = new OperateFile();
-        operateFile.printPoint("Y:\\allpoints.txt",allPoints);
-
-
+        //所有的作业轨迹点,只是点,不用连成直线
+//        operateFile.printPoint("Y:\\allpoints.txt",allPoints);
+        operateFile.printPoint("/Users/haoqianpan/file/programfile/meanshift/out/allpoints.txt",allPoints);
+        operateFile.printPoint("/Users/haoqianpan/file/programfile/meanshift/out/initialcor.txt",occupyShapeList);
         //对待计算点,进行过滤,过滤掉在网格以外的,这部分后面单独写个过滤类
         for(int i = 0 ; i < allPoints.size();i++){
-
             Point point = allPoints.get(i);
             Double corX = point.getColX();
             Double corY = point.getColY();
-
             if ( (corX < maxX) && (corX > minX) && (corY < maxY) && (corY > minY)){
-
                 pointAfterExclude.add(point);
-
             }
-
         }
-
-        operateFile.printPoint("Y:\\pointsexclude.txt",pointAfterExclude);
-
+        System.out.println("过滤后点数量:" + pointAfterExclude.size());
+        //对所有的轨迹点经过排除后剩下来的点
+//        operateFile.printPoint("Y:\\pointsexclude.txt",pointAfterExclude);
+        operateFile.printPoint("/Users/haoqianpan/file/programfile/meanshift/out/pointsexclude.txt",pointAfterExclude);
 
 
 
         //占用的网格为1,不占用的网格0
         ArrayList<ArrayList<Integer>> occupyList = changeWholeIndexOccupyToList(wholeIndexOccupy);
+//        for (int i = 0; i < occupyList.size();i++){
+//
+//            System.out.println("ceshi");
+//            System.out.println(occupyList.get(i));
+//
+//
+//        }
+//        System.out.println(occupyList);
 
 
 //        System.out.println("print all points---------------" );
@@ -95,175 +97,182 @@ public class Cal {
 
 //            System.out.println( x + " " + y);
 
-
             Integer xIndex = split.identifyXIndex(x);
             Integer yIndex = split.identifyYIndex(y);
 
+            //检查占用,如果占用了就把1设置成0,
             if (yIndex < numOfGaps && yIndex >=0){
-
                 ArrayList<Integer> arrayList = occupyList.get(xIndex);
                 arrayList.set(yIndex,0);
                 occupyList.set(xIndex,arrayList);
-
-
             }
-
-
-
         }
 //        System.out.println("print all points end -----------");
 
-
-
-
-
-
         for (int i = 0 ; i < occupyList.size();i++){
-
             ArrayList<Integer> arrayList = occupyList.get(i);
 
             StringBuffer sb = new StringBuffer();
+            StringBuffer sb1 = new StringBuffer();
             for (int jj = 0 ; jj < arrayList.size();jj++){
-
-
                 if (arrayList.get(jj).toString().equals("0")){
+//                    System.out.println("该列有空格");
                     sb.append(" ");
+                    sb1.append("+");
                 }
                 else {
                     sb.append(arrayList.get(jj).toString());
+                    sb1.append(arrayList.get(jj).toString());
                 }
-
-
             }
-
-
             String arrayListString = sb.toString();
-
-            System.out.println("print string----------" + arrayListString);
+            String arrayListString1 = sb1.toString();
+            System.out.println("print string----------" + arrayListString1);
             String[] arrays = arrayListString.split("\\s+");
-//
-//            for (int k = 0;k < arrays.length;k++){
-//
-//                System.out.println(arrays[k]);
-//
-//            }
-
             String maxString ="";
-
-
             //这里需要再想想
             for (int j = 0 ; j < arrays.length;j++){
-
                     String temp = arrays[j];
                     if (temp.length() > maxString.length()){
-
                         maxString = temp;
                     }
-
             }
-
             Integer indexBegin = arrayListString.indexOf(maxString) - 1;
             Integer indexEnd = indexBegin + maxString.length();
-
             OccupyPerX occupyPerX = new OccupyPerX();
             occupyPerX.setMinYIndex(indexBegin);
             occupyPerX.setMaxYIndex(indexEnd);
             occupyPerXArrayList.add(occupyPerX);
-
         }
-
-
         ArrayList<Point> shape = new ArrayList<>();
         for (int i = 0 ; i < occupyPerXArrayList.size();i++){
-
-//            OccupyPerX occupyPerX = occupyPerXArrayList.get(i);
-//            Double xCor = minX + i * xGap + 0.5 * xGap;
-//            Integer yIndex = occupyPerX.maxYIndex;
-//            Double yCor = minY + yIndex * yGap + 0.5 * yGap;
-//            Point point = new Point();
-//            point.setColX(xCor);
-//            point.setColY(yCor);
-
-
-
             OccupyPerX occupyPerX = occupyPerXArrayList.get(i);
-            Double xCor1 = minX + i * xGap;
-            Double xCor2 = minX + i * xGap + xGap;
+            Double xCor = minX + i * xGap + 0.5 * xGap;
             Integer yIndex = occupyPerX.maxYIndex;
             Double yCor = minY + yIndex * yGap + 0.5 * yGap;
-
-            Point point1 = new Point();
-            point1.setColX(xCor1);
-            point1.setColY(yCor);
-
-            Point point2 = new Point();
-            point2.setColX(xCor2);
-            point2.setColY(yCor);
-
-
-            shape.add(point1);
-            shape.add(point2);
-        }
-
-        for (int i = (occupyPerXArrayList.size() -1) ; i >=0;i--){
-
+            Point point = new Point();
+            point.setColX(xCor);
+            point.setColY(yCor);
+            shape.add(point);
 //            OccupyPerX occupyPerX = occupyPerXArrayList.get(i);
-//            Double xCor = minX + i * xGap + 0.5 * xGap;
-//            Integer yIndex = occupyPerX.minYIndex;
+//            Double xCor1 = minX + i * xGap;
+//            Double xCor2 = minX + i * xGap + xGap;
+//            Integer yIndex = occupyPerX.maxYIndex;
 //            Double yCor = minY + yIndex * yGap + 0.5 * yGap;
-//            Point point = new Point();
-//            point.setColX(xCor);
-//            point.setColY(yCor);
-//
-//            shape.add(point);
+//            Point point1 = new Point();
+//            point1.setColX(xCor1);
+//            point1.setColY(yCor);
+//            Point point2 = new Point();
+//            point2.setColX(xCor2);
+//            point2.setColY(yCor);
+//            shape.add(point1);
+//            shape.add(point2);
+        }
 
+        for (int i = (occupyPerXArrayList.size() -1) ; i >=0;i--){
             OccupyPerX occupyPerX = occupyPerXArrayList.get(i);
-            Double xCor1 = minX + i * xGap;
-            Double xCor2 = minX + i * xGap + xGap;
+            Double xCor = minX + i * xGap + 0.5 * xGap;
             Integer yIndex = occupyPerX.minYIndex;
             Double yCor = minY + yIndex * yGap + 0.5 * yGap;
+            Point point = new Point();
+            point.setColX(xCor);
+            point.setColY(yCor);
+            shape.add(point);
+//            OccupyPerX occupyPerX = occupyPerXArrayList.get(i);
+//            Double xCor1 = minX + i * xGap;
+//            Double xCor2 = minX + i * xGap + xGap;
+//            Integer yIndex = occupyPerX.minYIndex;
+//            Double yCor = minY + yIndex * yGap + 0.5 * yGap;
+//            Point point1 = new Point();
+//            point1.setColX(xCor1);
+//            point1.setColY(yCor);
+//            Point point2 = new Point();
+//            point2.setColX(xCor2);
+//            point2.setColY(yCor);
+//            shape.add(point2);
+//            shape.add(point1);
+        }
 
-            Point point1 = new Point();
-            point1.setColX(xCor1);
-            point1.setColY(yCor);
+        //对算法结果做一些调整
 
-            Point point2 = new Point();
-            point2.setColX(xCor2);
-            point2.setColY(yCor);
 
-            shape.add(point2);
-            shape.add(point1);
+        ArrayList<Point> shapeFill = fit.allCircleFitDefault(shape);
 
-        }
 
+        //填充空值
+        Adjust adjust = new Adjust();
+//        ArrayList<Point> shapeFill = fit.allCircleFitDefault(afterAdjustPointsList);
+//        shape = fit.excludePoints(shape);
         shape.add(shape.get(0));
-        System.out.println(shape.size() + ")))))))))))))))000");
-
-
+        ArrayList<Point> afterAdjustPointsList = adjust.fillArrayListPlus(occupyShapeList,shape,5);
 //        System.out.println(shape.size());
 //        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).getColY());
-
 //        }
 
-        operateFile.printPoint("Y:\\changed.txt",shape);
+        //计算后垛位形状,已经网格化处理
+//        operateFile.printPoint("Y:\\changed.txt",shape);
+//        Special special = new Special();
+        operateFile.printPoint("/Users/haoqianpan/file/programfile/meanshift/out/changed.txt",shape);
+//        operateFile.printPoint("/Users/haoqianpan/file/programfile/meanshift/out/changedFill.txt",shapeFill);
+        //拟合
+        operateFile.printPoint("/Users/haoqianpan/file/programfile/meanshift/out/changedFill.txt",shapeFill);
+        //对计算结果进行修正,
+//        operateFile.printPoint("Y:\\adjustchanged.txt",afterAdjustPointsList);
+        operateFile.printPoint("/Users/haoqianpan/file/programfile/meanshift/out/adjustchanged.txt",afterAdjustPointsList);
+
+        ///打印,临时用的,主要是为了调整坐标
+        PointXYCorRevise pointXYCorRevise = new PointXYCorRevise();
+        //测试
+        for (int i = 0 ; i <realShapePoints.size();i++){
+
+            Point point  = realShapePoints.get(i);
+            System.out.println(point.getColX() + " " + point.getColY());
 
-        ArrayList<Point> afterAdjustPointsList = adjustShape(occupyShapeList,shape,5);
+        }
 
-        operateFile.printPoint("Y:\\adjustchanged.txt",afterAdjustPointsList);
-        return shape;
+        realShapePoints = pointXYCorRevise.revise(realShapePoints);
+        afterAdjustPointsList = pointXYCorRevise.revise(afterAdjustPointsList);
+        pointAfterExclude = pointXYCorRevise.revise(pointAfterExclude);
 
+        for (int i = 0 ; i < realShapePoints.size();i++){
 
+            Point point  = realShapePoints.get(i);
+            System.out.println(point.getColX() + " " + point.getColY());
 
+        }
 
 
+        operateFile.printPoint("/Users/haoqianpan/file/programfile/meanshift/out/revise/initial.txt",realShapePoints);
+        operateFile.printPoint("/Users/haoqianpan/file/programfile/meanshift/out/revise/adjustchanged.txt",afterAdjustPointsList);
+        operateFile.printPoint("/Users/haoqianpan/file/programfile/meanshift/out/revise/pointsexclude.txt",pointAfterExclude);
 
 
+//        Plot plot = new Plot();
+//        Map mapInitialShape = new HashMap();
+//        Map mapAdjustChanged = new HashMap();
+//        Map mapPointExclude = new HashMap();
+//
+//        mapInitialShape.put("FILE_NAME","initial.txt");
+//        mapInitialShape.put("POINTS_LIST",realShapePoints);
+//
+//        mapAdjustChanged.put("FILE_NAME","adjustchanged.txt");
+//        mapAdjustChanged.put("POINTS_LIST",afterAdjustPointsList);
+//
+//        mapPointExclude.put("FILE_NAME","pointsexclude.txt");
+//        mapPointExclude.put("POINTS_LIST",pointAfterExclude);
+//
+//        ArrayList<Map> mapArrayList = new ArrayList<>();
+//        mapArrayList.add(mapInitialShape);
+//        mapArrayList.add(mapAdjustChanged);
+//        mapArrayList.add(mapPointExclude);
+//
+//        plot.revisePlot("/Users/haoqianpan/file/programfile/meanshift/out/revise/",mapArrayList);
 
 
 
+        return shape;
 
 
 
@@ -323,9 +332,9 @@ public class Cal {
 
     public ArrayList<Point> adjustShape(ArrayList<Point> initialShapeList,ArrayList<Point> changedShapeList,Integer adjustSize){
 
-
-        Integer size = initialShapeList.size() - 1;
-
+//        Integer size = initialShapeList.size() - 1;
+        Integer size = initialShapeList.size();
+//
         System.out.println(size + "size");
 
         ArrayList<Point> afterAdjustPointsList = new ArrayList<>();
@@ -340,13 +349,38 @@ public class Cal {
             Integer indexEnd = indexBegin + adjustSize;
 
             Double avgDec = 0.0;
+            //
+            ArrayList<Point> pointArrayList = new ArrayList<>();//存放差值,借用arraylist<point>
+
             for (int j = indexBegin;j < indexEnd; j++){
                 Point iniPoint = initialShapeList.get(j);
                 Point chaPoint = changedShapeList.get(j);
+                Point pointDis = new Point();
+                pointDis.setColY(chaPoint.getColY() - iniPoint.getColY());
+                pointDis.setColX(chaPoint.getColX());
+                pointArrayList.add(pointDis);
                 avgDec = avgDec + chaPoint.getColY() - iniPoint.getColY();
+                System.out.println("差值" + (chaPoint.getColY() - iniPoint.getColY()));
             }
+
+
+//            double[] param = fit.gaussFit(pointArrayList);
+            //求高斯分布值
+//            Gaussian gaussian = new Gaussian(param[0],param[1],param[2]);
+//            ArrayList<Double> dPoint = new ArrayList<>();
+//            for (int ii = 0 ; ii < pointArrayList.size();ii++){
+//
+//                Point point = pointArrayList.get(ii);
+//                Double x = point.getColX();
+//                Double y = gaussian.value(x);
+//                dPoint.add(y);
+//
+//            }
+
+
+
             avgDec = avgDec / adjustSize;
-            System.out.println(avgDec + " avgdec");
+//            System.out.println(avgDec + " avgdec");
 
             for (int j = indexBegin ; j < indexEnd;j++){
 
@@ -355,13 +389,16 @@ public class Cal {
                 Point adjustPoint = new Point();
                 adjustPoint.setColX(intPoint.getColX());
                 adjustPoint.setColY(intPoint.getColY() + avgDec);
+//                adjustPoint.setColY(intPoint.getColY() + gaussian.value(intPoint.getColX()));
+//                System.out.println(new Date());
 
                 afterAdjustPointsList.add(adjustPoint);
             }
             //后面扩充不整除的情况
         }
 
-        afterAdjustPointsList.add(afterAdjustPointsList.get(0));
+
+//        afterAdjustPointsList.add(afterAdjustPointsList.get(0));
 
 
 
@@ -370,4 +407,6 @@ public class Cal {
 
     }
 
+
+
 }

+ 16 - 3
src/test/Tool.java → src/main/java/index/alg/CurveTool.java

@@ -1,10 +1,10 @@
-package test;
+package index.alg;
 
-import test.entity.Point;
+import index.entity.Point;
 
 import java.util.ArrayList;
 
-public class Tool {
+public class CurveTool {
 
 
     public ArrayList<Double> calLineabc(Point point1, Point point2){
@@ -64,4 +64,17 @@ public class Tool {
         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;
+    }
+    
 }

+ 308 - 0
src/main/java/index/alg/GetPoints.java

@@ -0,0 +1,308 @@
+package index.alg;
+
+
+import index.adjust.PointXYCorRevise;
+import index.gps.GpsExchange;
+import index.db.ConnectToSourceDB;
+import index.db.DbOperate;
+import index.entity.Point;
+import index.file.OperateFile;
+
+import java.io.FileNotFoundException;
+import java.sql.Connection;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.Map;
+
+//暂时先自己写connection从数据库中获取
+
+public class GetPoints {
+
+    String userName = "nps_tc01";
+    String password = "nps_tc01";
+    String driver = "oracle.jdbc.driver.OracleDriver";
+    String url = "jdbc:oracle:thin:@172.16.2.114:1521:orcl1";
+
+
+    ArrayList<Point> realShapePoints = new ArrayList<>();
+    ArrayList<Point> allPoints = new ArrayList<>();
+//    ArrayList<Map> anaMapList = new ArrayList<>();
+    ArrayList<ArrayList<Date>> dateForAna = new ArrayList<>();
+
+    public ArrayList<Point> returnPoints(){
+
+        ArrayList<Point> pointList = new ArrayList<>();
+
+        return pointList;
+
+    }
+
+    public void getPoints(Integer workDirection) throws SQLException, FileNotFoundException {
+
+
+
+        //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 whereUserName = " and login_user_id = '17332803555'";
+
+//        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') and (GPS_SOURCE_TYPE = '千寻(4)' OR '千寻(5)')";
+//        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') and (GPS_SOURCE_TYPE = '千寻(4)' OR '千寻(5)')";
+
+//        sql1 = sql1 + whereUserName;
+//        sql2 = sql2 + whereUserName;
+
+        //b32
+        //跑圈开始时间
+//        String realShapeBeginTime = "2020-08-27 10:10:30.000000";
+//        String realShapeEndTime = "2020-08-27 10:13:15.000000";
+//        String realShapeBeginTime = "2020-08-29 12:11:00.000000";
+//        String realShapeEndTime = "2020-08-29 12:14:00.000000";
+
+        //b15
+//        跑圈开始结束时间
+//        String realShapeBeginTime = "2020-09-01 10:54:00.000000";
+//        String realShapeEndTime = "2020-09-01 10:56:00.000000";
+
+        //a30
+////        String realShapeBeginTime = "2020-09-02 14:27:30.000000";
+////        String realShapeEndTime = "2020-09-02 14:30:00.000000";
+
+//        a30
+        String realShapeBeginTime = "2020-09-02 18:06:42.000000";
+        String realShapeEndTime = "2020-09-02 18:08:18.000000";
+
+
+
+
+
+
+
+//        String queryShapeSql = sqlFactory(realShapeBeginTime,realShapeEndTime,"港装K438");
+//        String queryShapeSql = sqlFactory(realShapeBeginTime,realShapeEndTime,"港装K121");
+//        realShapePoints = buildPoints(queryShapeSql,workDirection);
+        realShapePoints = buildPointsFromFile("/Users/haoqianpan/file/programfile/gpsexc/in/a30.txt",workDirection);
+
+        //
+        ArrayList<String> userNameArrayList = new ArrayList<>();
+        ArrayList<String> machineIdList = new ArrayList<>();
+        ArrayList<String> allPointsBeginTimeList = new ArrayList<>();
+        ArrayList<String> allPointsEndTimeList = new ArrayList<>();
+//        userNameArrayList.add("testApp1");
+
+        //438第一次上下垛时间
+//        machineIdList.add("港装K438");
+//        allPointsBeginTimeList.add("2020-08-27 11:05:00.000000");
+//        allPointsEndTimeList.add("2020-08-27 19:33:00.000000");
+////        438第二次上下垛时间
+//        machineIdList.add("港装K438");
+//        allPointsBeginTimeList.add("2020-08-27 20:25:00.000000");
+//        allPointsEndTimeList.add("2020-08-28 07:15:00.000000");
+//
+////        438第三次上下垛时间
+//        machineIdList.add("港装K438");
+//        allPointsBeginTimeList.add("2020-08-28 08:35:00.000000");
+//        allPointsEndTimeList.add("2020-08-28 21:24:00.000000");
+//
+////        438第四次上下垛时间
+//        machineIdList.add("港装K438");
+//        allPointsBeginTimeList.add("2020-08-29 08:29:00.000000");
+//        allPointsEndTimeList.add("2020-08-29 20:29:00.000000");
+
+//        121第一次上下垛时间
+//        machineIdList.add("港装K121");
+//        allPointsBeginTimeList.add("2020-09-01 10:06:00.000000");
+//        allPointsEndTimeList.add("2020-09-01 10:50:00.000000");
+
+        //a30第一次上下垛时间
+        machineIdList.add("港装K121");
+        allPointsBeginTimeList.add("2020-09-01 12:11:00.000000");
+        allPointsEndTimeList.add("2020-09-02 11:00:00.000000");
+
+        machineIdList.add("港装K438");
+        allPointsBeginTimeList.add("2020-09-02 14:30:00.000000");
+        allPointsEndTimeList.add("2020-09-02 18:06:00.000000");
+
+
+
+
+
+        for (int i  = 0 ; i < (machineIdList.size());i++){
+
+            String machineId = machineIdList.get(i);
+            String beginTime = allPointsBeginTimeList.get(i);
+            String endTime = allPointsEndTimeList.get(i);
+            String allPointsQuerySql = sqlFactory(beginTime,endTime,machineId);
+//            String allPointsQuerySql = sqlFactoryTemp(beginTime,endTime,machineId);
+            ArrayList<Point> pointsTemp = buildPoints(allPointsQuerySql,workDirection);
+            allPoints.addAll(pointsTemp);
+
+        }
+
+
+
+
+
+
+
+
+
+//        realShapePoints = buildPoints(sql1);
+//        allPoints = buildPoints(sql2);
+//        realShapePoints = buildPointsFromFile("Y:\\programresult\\dbdiff\\points\\shape.txt");
+
+//        allPoints = buildPointsFromFile("Y:\\programresult\\dbdiff\\points\\allpoints.txt");
+//        realShapePoints = buildPointsFromFile("/Users/haoqianpan/file/programfile/meanshift/in/initial_data.txt");
+//        allPoints = buildPointsFromFile("/Users/haoqianpan/file/programfile/meanshift/in/working_data_x_0.33333.txt");
+//        allPoints = buildPointsFromFile("/Users/haoqianpan/file/programfile/meanshift/in/working_data_x_0.0333.txt");
+//        allPoints = buildPointsFromFile("/Users/haoqianpan/file/programfile/meanshift/in/working_data_x_0.66666.txt");
+//        allPoints = buildPointsFromFile("/Users/haoqianpan/file/programfile/meanshift/in/working_data_y_0.33333.txt");
+//        allPoints = buildPointsFromFile("/Users/haoqianpan/file/programfile/meanshift/in/working_data_y_0.66666.txt");
+//        allPoints = buildPointsFromFile("/Users/haoqianpan/file/programfile/meanshift/in/working_data_y_0.99999.txt");
+//        Connection
+
+    }
+
+    public ArrayList<Point> buildPoints(String sql,Integer workDirection) throws SQLException {
+        ArrayList<Point> pointArrayList = new ArrayList<>();
+        ConnectToSourceDB connectToSourceDB = new ConnectToSourceDB();
+        connectToSourceDB.setConnPara(userName,password,driver,url);
+        Connection connection = connectToSourceDB.getConnection();
+        DbOperate dbOperate = new DbOperate();
+
+        ResultSet resultSet = dbOperate.runQuerySql(connection,sql);
+
+        GpsExchange gpsExchange = new GpsExchange();
+
+        ArrayList<Date> dateArrayList = new ArrayList<>();
+
+        while (resultSet.next()){
+
+            Double lat = resultSet.getDouble(1);
+            Double lon = resultSet.getDouble(2);
+            Date date = resultSet.getDate(3);
+//            Map mapTemp = new HashMap();
+//            mapTemp.put("date",date);
+            dateArrayList.add(date);
+            Point point = gpsExchange.gpsToPoints(lat,lon);
+            pointArrayList.add(point);
+
+        }
+        dateForAna.add(dateArrayList);
+        System.out.println("sql: " + sql);
+        System.out.println("pointsize " + pointArrayList.size());
+
+        PointXYCorRevise pointXYCorRevise = new PointXYCorRevise();
+        if (workDirection == 1){
+
+            pointArrayList = pointXYCorRevise.revise(pointArrayList);
+
+
+        }
+
+        return pointArrayList;
+    }
+//    public ArrayList<Point> buildPointsFromFile(String filePath) throws FileNotFoundException {
+//        ArrayList<Point> pointArrayList = new ArrayList<>();
+//        OperateFile operateFile = new OperateFile();
+//        ArrayList<Map> pointsMapList = operateFile.readPoints(filePath);
+//        for (int i = 0 ; i < pointsMapList.size();i++){
+//            Map mapTemp = pointsMapList.get(i);
+//            Double lat = (Double) mapTemp.get("lat");
+//            Double lon = (Double) mapTemp.get("lon");
+//            GpsExchange gpsExchange = new GpsExchange();
+//            Point point = gpsExchange.gpsToPoints(lat,lon);
+//            pointArrayList.add(point);
+//        }
+//        return pointArrayList;
+//    }
+
+    public ArrayList<Point> buildPointsFromFile(String filePath,Integer workDirection) throws FileNotFoundException {
+        OperateFile operateFile = new OperateFile();
+
+        ArrayList<Point> pointArrayList  = operateFile.readPointsFromFile(filePath);
+
+        GpsExchange gpsExchange = new GpsExchange();
+        for (int i = 0 ; i < pointArrayList.size();i++){
+
+            Point point = pointArrayList.get(i);
+            point = gpsExchange.gpsToPoints(point.getColX(),point.getColY());
+            pointArrayList.set(i,point);
+
+        }
+
+        PointXYCorRevise pointXYCorRevise = new PointXYCorRevise();
+        if (workDirection == 1){
+
+            pointArrayList = pointXYCorRevise.revise(pointArrayList);
+
+        }
+
+        return pointArrayList;
+
+    }
+
+    public String sqlFactory(String beginTime,String endTime,String machineId){
+
+        String sql = "select GPS_LAT,GPS_LON,CLIENT_RECORD_TIME from T_LOC_APP_CLIENT_STATUS@DBLINKLOC WHERE CLIENT_RECORD_TIME between to_timestamp('" + beginTime  + "', 'yyyy-mm-dd hh24:mi:ss.ff') and to_timestamp('" + endTime + "', 'yyyy-mm-dd hh24:mi:ss.ff') and (GPS_SOURCE_TYPE = '千寻(4)' OR GPS_SOURCE_TYPE = '千寻(5)') and MACHINE_ID = '" + machineId +"' order by CLIENT_RECORD_TIME asc"  ;
+//        String sql = "select GPS_LAT,GPS_LON from T_LOC_APP_CLIENT_STATUS@DBLINKLOC WHERE CLIENT_RECORD_TIME between to_timestamp('" + beginTime  + "', 'yyyy-mm-dd hh24:mi:ss.ff') and to_timestamp('" + endTime + "', 'yyyy-mm-dd hh24:mi:ss.ff') and GPS_SOURCE_TYPE != '千寻(4)' and GPS_SOURCE_TYPE != '千寻(5)' and MACHINE_ID = '" + machineId +"'"  ;
+//        String sql = "select GPS_LAT,GPS_LON,CLIENT_RECORD_TIME from T_LOC_APP_CLIENT_STATUS@DBLINKLOC WHERE CLIENT_RECORD_TIME between to_timestamp('" + beginTime  + "', 'yyyy-mm-dd hh24:mi:ss.ff') and to_timestamp('" + endTime + "', 'yyyy-mm-dd hh24:mi:ss.ff') and MACHINE_ID = '" + machineId +"'" ;
+        return sql;
+
+    }
+    public String sqlFactoryTemp(String beginTime,String endTime,String machineId){
+
+//        String sql = "select GPS_LAT,GPS_LON from T_LOC_APP_CLIENT_STATUS@DBLINKLOC WHERE CLIENT_RECORD_TIME between to_timestamp('" + beginTime  + "', 'yyyy-mm-dd hh24:mi:ss.ff') and to_timestamp('" + endTime + "', 'yyyy-mm-dd hh24:mi:ss.ff') and (GPS_SOURCE_TYPE = '千寻(4)' OR GPS_SOURCE_TYPE = '千寻(5)') and MACHINE_ID = '" + machineId +"'"  ;
+        String sql = "select GPS_LAT,GPS_LON,CLIENT_RECORD_TIME from T_LOC_APP_CLIENT_STATUS@DBLINKLOC WHERE CLIENT_RECORD_TIME between to_timestamp('" + beginTime  + "', 'yyyy-mm-dd hh24:mi:ss.ff') and to_timestamp('" + endTime + "', 'yyyy-mm-dd hh24:mi:ss.ff') and GPS_SOURCE_TYPE != '千寻(4)' and GPS_SOURCE_TYPE != '千寻(5)' and MACHINE_ID = '" + machineId +"' order by CLIENT_RECORD_TIME asc"  ;
+//        String sql = "select GPS_LAT,GPS_LON from T_LOC_APP_CLIENT_STATUS@DBLINKLOC WHERE CLIENT_RECORD_TIME between to_timestamp('" + beginTime  + "', 'yyyy-mm-dd hh24:mi:ss.ff') and to_timestamp('" + endTime + "', 'yyyy-mm-dd hh24:mi:ss.ff') and MACHINE_ID = '" + machineId +"'" ;
+        return sql;
+
+    }
+
+
+
+}

+ 28 - 0
src/main/java/index/alg/Special.java

@@ -0,0 +1,28 @@
+package index.alg;
+
+import index.entity.Point;
+
+import java.util.ArrayList;
+
+public class Special {
+
+    public ArrayList<Point> changeSide(ArrayList<Point> arrayListForExchange){
+
+        Integer length = arrayListForExchange.size() -1;
+        ArrayList<Point> arrayListAfterExchange = new ArrayList<>();
+        for (int i = length / 2 - 1;i>=0;i--){
+
+            arrayListAfterExchange.add(arrayListForExchange.get(i));
+
+        }
+
+        for (int i = length - 1; (i >= length / 2 + 12);i--){
+
+            arrayListAfterExchange.add(arrayListForExchange.get(i));
+
+        }
+
+        return arrayListAfterExchange;
+    }
+
+}

+ 20 - 47
src/test/Split.java → src/main/java/index/alg/Split.java

@@ -1,9 +1,10 @@
-package test;
+package index.alg;
 
-import test.entity.Index;
-import test.entity.OccupyPerX;
-import test.entity.Point;
-import test.entity.WholeIndexOccupy;
+import index.entity.Index;
+import index.entity.OccupyPerX;
+import index.entity.Point;
+import index.entity.WholeIndexOccupy;
+import index.file.OperateFile;
 
 import java.io.FileNotFoundException;
 import java.util.ArrayList;
@@ -15,7 +16,7 @@ public class Split {
 
     public int numOfGaps = 100;
 
-    Tool tool = new Tool();
+    CurveTool tool = new CurveTool();
 
     WholeIndexOccupy wholeIndexOccupy = new WholeIndexOccupy(numOfGaps);//初始网格占用情况
 
@@ -27,10 +28,19 @@ public class Split {
     //输入垛位的初始实际形状,形成网格
     public void cal(ArrayList<Point> pointsList) throws FileNotFoundException {
 
+        OperateFile operateFile = new OperateFile();
+
+//        pointsList.add(pointsList.get(0));
+
+        operateFile.printPoint("/Users/haoqianpan/file/programfile/meanshift/out/initial.txt",pointsList);
         pointsList.add(pointsList.get(0));
 
-        OperateFile operateFile = new OperateFile();
-        operateFile.printPoint("Y:\\initial.txt",pointsList);
+
+
+
+        //垛位的初始形状,未网格化处理
+//        operateFile.printPoint("Y:\\initial.txt",pointsList);
+//        operateFile.printPoint("/Users/haoqianpan/file/programfile/meanshift/out/initial.txt",pointsList);
 
 //        System.out.println("print initial points-----------------");
 //        for (int i = 0 ; i < pointsList.size(); i++){
@@ -254,11 +264,7 @@ public class Split {
         Double xMin = xIndexCorList.get(0);
         Double yMin = yIndexCorList.get(0);
 
-
-
         ///
-
-
         //该直线起始点的网格位置
         Index indexI = identifyIndex(pointI);
         Index indexJ = identifyIndex(pointJ);
@@ -316,17 +322,11 @@ public class Split {
                 System.out.println(xIndexEnd);
                 System.out.println(pointJ.getColX());
             }
-
-
-
             //计算该直线(线段)在当前横向的网格内,在纵向的占据情况
-
             Integer minYIndex;
             Integer maxYIndex;
-
             Double xInputBegin;//网格的起始的横坐标
             Double xInputEnd;//
-
             Double yOutBegin;//
             Double yOutEnd;//
 
@@ -340,19 +340,11 @@ public class Split {
 
 
 
-//            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))){
 
@@ -389,25 +381,6 @@ 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 {

+ 110 - 0
src/main/java/index/alg/boxscan/GetAllEdge.java

@@ -0,0 +1,110 @@
+package index.alg.boxscan;
+
+import index.entity.Box;
+import index.entity.BoxEdge;
+import index.entity.Point;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.LinkedHashSet;
+
+//输入网格,输出边(去重处理过后的)
+public class GetAllEdge {
+
+    public ArrayList<BoxEdge> cal(ArrayList<Box> allBusyBox){
+
+        ArrayList<BoxEdge> boxEdges = new ArrayList<>();
+        ArrayList<String> uidList = new ArrayList<>();
+
+        //不包含重复边
+        ArrayList<BoxEdge> boxEdgesWithOutDuplicates = new ArrayList<>();
+
+        for (int i = 0 ; i < allBusyBox.size();i++){
+
+            Box box = allBusyBox.get(i);//每个盒子里四条边
+            boxEdges.addAll(box.getBoxEdgeArrayList());//
+
+        }
+
+        //为去重比较做准备,给每条边生成一个专属的字符串
+        //把每条边的起点和终点做一下调整,相同的y值,x值小的在前,相同x值,y小的在前
+        //比如(2,1),(1,1) 这条边生成的字符串就是1-1-1-2
+        for (int i = 0 ; i < boxEdges.size();i++){
+
+            BoxEdge boxEdge = boxEdges.get(i);
+            ArrayList<Point> point12 = boxEdge.getPoint12();
+            Point point1 = point12.get(0);
+            Point point2 = point12.get(1);
+
+            String edgeUid;
+            if (point1.getColX() == point2.getColX()){
+
+                if (point1.getColY() > point2.getColY()){
+
+                    edgeUid = buildUid(point2,point1);
+
+                }
+
+                else {
+
+                    edgeUid = buildUid(point1,point2);
+                }
+
+            }
+            else if (point1.getColX() < point2.getColX()){
+
+                edgeUid = buildUid(point1,point2);
+
+            }
+            else {
+
+                edgeUid = buildUid(point2,point1);
+
+            }
+            uidList.add(edgeUid);
+            }
+
+        //
+        ArrayList<String> uidListCopy = uidList;
+        for (int i = 0;i < uidList.size();i++){
+
+            int frequency = Collections.frequency(uidListCopy,uidList.get(i));
+
+            if (frequency == 1){
+
+
+                boxEdgesWithOutDuplicates.add(boxEdges.get(i));
+                uidListCopy.remove(uidList.get(i));
+
+            }
+
+        }
+        //
+
+//        LinkedHashSet<String> uidHashSet = new LinkedHashSet<>(uidList);
+//        ArrayList<String> uidListWithoutDuplicates = new ArrayList<String>(uidHashSet);
+//
+//
+//
+//        //这些不重复的边的uid在uidList中的标号
+//        ArrayList<Integer> withOutDuplicatesUidList = new ArrayList<>();
+//
+//        for (int i = 0 ; i < uidListWithoutDuplicates.size();i++){
+//            String uid = uidListWithoutDuplicates.get(i);
+//            Integer uidIndex = uidList.indexOf(uid);
+////            withOutDuplicatesUidList.add(uidIndex);
+//            boxEdgesWithOutDuplicates.add(boxEdges.get(uidIndex));
+//        }
+        return boxEdgesWithOutDuplicates;
+    }
+
+        public String buildUid(Point point1,Point point2){
+
+            String uid = point1.getColX().toString() + "-" + point1.getColY().toString() + "-" + point2.getColX().toString() + "-" + point2.getColY();
+            return uid;
+        }
+    }
+
+
+

+ 293 - 0
src/main/java/index/alg/boxscan/ScanOutLine.java

@@ -0,0 +1,293 @@
+package index.alg.boxscan;
+
+import com.sun.org.apache.bcel.internal.generic.NEW;
+import index.entity.Box;
+import index.entity.BoxEdge;
+import index.entity.Point;
+import java.util.ArrayList;
+
+
+public class ScanOutLine {
+
+    ArrayList<String> scanPriority;
+    Integer numOfGaps;
+    ArrayList<ArrayList<BoxEdge>> shapeList = new ArrayList<>();
+    ArrayList<ArrayList<Point>> shapePointList = new ArrayList<>();
+
+    //设置扫描的优先级
+    public ScanOutLine(ArrayList<String> ScanPriority){
+
+        this.scanPriority = ScanPriority;
+
+    }
+
+
+    //设置默认的扫描的优先级
+    public ScanOutLine(){
+
+        scanPriority.add("UP");
+        scanPriority.add("RIGHT");
+        scanPriority.add("DOWN");
+        scanPriority.add("LEFT");
+
+    }
+
+    //迭代
+    public void Scan(ArrayList<Box> allBusyBoxes,Integer numOfGaps) throws Exception{
+
+        this.numOfGaps = numOfGaps;
+
+        //获取所有的不重复的边
+        GetAllEdge getAllEdge = new GetAllEdge();
+        ArrayList<BoxEdge> boxEdgeArrayList = getAllEdge.cal(allBusyBoxes);
+
+        //随机挑选一个边,然后从边中挑选一个点
+
+        //闭合轮廓list
+
+//        ArrayList<ArrayList<BoxEdge>> shapeList = new ArrayList<>();
+//        ArrayList<ArrayList<Point>> shapePointList = new ArrayList<>();
+
+        //挑边
+        Integer randomBoxEdgeIndex = (int) (Math.random() * boxEdgeArrayList.size());
+        BoxEdge initialBoxEdge = boxEdgeArrayList.get(randomBoxEdgeIndex);
+
+        //挑点,这里挑点1或者点2都可以
+        Point pointInitial = initialBoxEdge.getPoint1();
+
+        while (boxEdgeArrayList.size() !=0){
+
+            //某一个连通轮廓
+            ArrayList<BoxEdge> shapeSingle = new ArrayList<>();
+
+            //走过的点的list
+            ArrayList<Point> shapePoint = new ArrayList<>();
+
+            ArrayList<BoxEdge> matchBoxEdgeArrayList =new ArrayList<>();
+
+            Point pointNext = new Point();
+
+            //按方向去找下一个点
+            for (int i = 0; i < scanPriority.size();i++) {
+
+                String direction = scanPriority.get(i);
+
+                Point pointNextTemp = genNextStep(pointInitial, direction);
+
+                if (!isPointLegal(pointNextTemp, this.numOfGaps)) {
+
+                    continue;
+
+                }
+
+                BoxEdge boxEdgeBuild = new BoxEdge();
+
+                //构造边
+                boxEdgeBuild.setPoint1(pointInitial);
+                boxEdgeBuild.setPoint2(pointNextTemp);
+
+                //寻找和构造的边相等的边
+                ArrayList<BoxEdge> matchBoxEdgeArrayListTemp = findEqualBoxEdgeFromList(boxEdgeBuild, boxEdgeArrayList);
+
+
+                //如果找到了就跳出循环,不再从别的方向上去找下一步的点了
+                if (matchBoxEdgeArrayListTemp.size() != 0){
+
+                    matchBoxEdgeArrayList = matchBoxEdgeArrayListTemp;
+
+                    break;
+                }
+
+            }
+            //四个方向上找了一遍,都没有找到边
+                if (matchBoxEdgeArrayList.size() == 0){
+
+                    //这里要分两种情况。
+                    //没有找到边,且boxEdgeArrayList的size为0
+                    //没有找到边,且boxEdgeArrayList的size不为0
+                    shapeList.add(shapeSingle);
+                    shapePointList.add(shapePoint);
+                    //从剩下的边里产生产生一个初始点
+                    Integer randomBoxEdgeIndexNextCircle = (int) (Math.random() * boxEdgeArrayList.size());
+                    BoxEdge initialBoxEdgeNextCircle = boxEdgeArrayList.get(randomBoxEdgeIndexNextCircle);
+
+                    //挑点,这里挑点1或者点2都可以
+                    pointInitial = initialBoxEdgeNextCircle.getPoint1();
+
+
+                }
+
+                else if (matchBoxEdgeArrayList.size() > 1){
+
+                    throw new Exception("重复边未完全去除");
+
+                }else {
+                    //找到一条边,之后把连接的点存入一个list,并且把查到的那条边也存入一个数组
+
+                    //把走过的点按顺序存入list
+                    shapePoint.add(pointInitial);
+                    //
+                    BoxEdge boxEdgeFind = matchBoxEdgeArrayList.get(0);
+
+                    //把走过的边按顺序存入list
+                    shapeSingle.add(boxEdgeFind);
+
+                    //这个需要检查一下看看是不是真的能够remove,如果不行就自己写一个remove方法
+
+                    boxEdgeArrayList = removeBoxEdge(boxEdgeFind,boxEdgeArrayList);
+
+                    pointInitial = pointNext;
+
+                }
+        }
+    }
+
+    public ArrayList<BoxEdge> removeBoxEdge(BoxEdge boxEdgeForRemove,ArrayList<BoxEdge> boxEdgeArrayList){
+
+        ArrayList<BoxEdge> boxEdgeArrayList1 = new ArrayList<>();
+        for (int i = 0 ; i < boxEdgeArrayList.size();i++){
+
+            BoxEdge boxEdge = boxEdgeArrayList.get(i);
+            if (!judgeEdgeEqual(boxEdgeForRemove,boxEdge)){
+
+                boxEdgeArrayList1.add(boxEdge);
+
+            }
+
+        }
+        return boxEdgeArrayList1;
+
+    }
+
+//    public ArrayList<BoxEdge> findConnectEdge(Point point,ArrayList<BoxEdge> boxEdgeArrayList){
+//
+//        //所有与该点相连的边,一般一个,有可能没有。
+//        ArrayList<BoxEdge> boxEdgesConnected = new ArrayList<>();
+//
+//        //
+//
+//        for (int i = 0 ; i < boxEdgeArrayList.size();i++){
+//
+//
+//            BoxEdge boxEdge = boxEdgeArrayList.get(i);
+//            Point point1 = boxEdge.getPoint1();
+//            Point point2 = boxEdge.getPoint2();
+//            boolean isEqualToP1 = judgePointEqual(point,point1);
+//            boolean isEqualToP2 = judgePointEqual(point,point2);
+//
+//            if ( isEqualToP1 || isEqualToP2 ){
+//
+//                boxEdgesConnected.add(boxEdge);
+//
+//            }
+//
+//
+//
+//        }
+//
+//
+//    }
+
+    public boolean judgePointEqual(Point point1,Point point2){
+
+        boolean isEqual = false;
+
+        if ((point1.getColX().equals(point2.getColX())) && (point1.getColY().equals(point2.getColY()))){
+
+            isEqual = true;
+
+        }
+
+        return isEqual;
+
+    }
+
+    //获取下一个点
+    public Point genNextStep(Point point,String direction){
+
+        Point pointNext = new Point();
+
+        if (direction.equals("UP")){
+
+            pointNext.setColX(point.getColX());
+            pointNext.setColY(point.getColY() + 1.0);
+
+        }
+        else if (direction.equals("DOWN")){
+
+            pointNext.setColX(point.getColX());
+            pointNext.setColY(point.getColY() - 1.0);
+
+        }
+        else if (direction.equals("LEFT")){
+
+            pointNext.setColX(point.getColX() - 1);
+            pointNext.setColY(point.getColY());
+
+        }
+
+        else {
+
+            pointNext.setColX(point.getColX() + 1);
+            pointNext.setColY(point.getColY());
+
+        }
+
+        return pointNext;
+
+    }
+
+
+    public boolean isPointLegal(Point point, Integer numOfGaps){
+
+        boolean isLegal = true;
+        double x = point.getColX();
+        double y = point.getColY();
+        if (x > numOfGaps || x < 0){
+
+            isLegal = false;
+
+        }
+
+        if ( y > numOfGaps || y < 0){
+
+            isLegal = false;
+
+        }
+
+        return isLegal;
+
+    }
+
+    public boolean judgeEdgeEqual(BoxEdge boxEdge1,BoxEdge boxEdge2){
+
+        boolean isEdgeEqual = false;
+        Point boxEdge1Point1 = boxEdge1.getPoint1();
+        Point boxEdge1Point2 = boxEdge1.getPoint2();
+        Point boxEdge2Point1 = boxEdge2.getPoint1();
+        Point boxEdge2Point2 = boxEdge2.getPoint2();
+
+        if (((judgePointEqual(boxEdge1Point1,boxEdge2Point1))&&(judgePointEqual(boxEdge1Point2,boxEdge2Point2))) ||((judgePointEqual(boxEdge1Point1,boxEdge2Point2))&&(judgePointEqual(boxEdge1Point2,boxEdge2Point1)))){
+
+            isEdgeEqual = true;
+
+        }
+
+        return isEdgeEqual;
+
+    }
+
+    public ArrayList<BoxEdge> findEqualBoxEdgeFromList(BoxEdge boxEdge,ArrayList<BoxEdge> boxEdgeArrayList){
+        ArrayList<BoxEdge> equalBoxEdgeArrayList = new ArrayList<>();
+        for (int i = 0 ; i < boxEdgeArrayList.size();i++){
+            BoxEdge boxEdge1 = boxEdgeArrayList.get(i);
+            if (judgeEdgeEqual(boxEdge,boxEdge1)){
+                equalBoxEdgeArrayList.add(boxEdge1);
+            }
+        }
+        return equalBoxEdgeArrayList;
+    }
+
+
+
+}

+ 1 - 1
src/test/ConnectToSourceDB.java → src/main/java/index/db/ConnectToSourceDB.java

@@ -1,4 +1,4 @@
-package test;
+package index.db;
 
 
 import java.sql.Connection;

+ 5 - 5
src/test/DbOperate.java → src/main/java/index/db/DbOperate.java

@@ -1,4 +1,4 @@
-package test;
+package index.db;
 
 import java.sql.Connection;
 import java.sql.ResultSet;
@@ -17,10 +17,10 @@ public class DbOperate {
         return resultSet;
     }
 
-    public void runInsertSql(Connection connection,String sql) throws SQLException {
-        Statement statement = connection.createStatement();
-        statement.executeLargeUpdate(sql);
-    }
+//    public void runInsertSql(Connection connection,String sql) throws SQLException {
+//        Statement statement = connection.createStatement();
+//        statement.executeLargeUpdate(sql);
+//    }
 
     public ResultSet runQuerySqlByStatement(Statement statement, String sql) throws SQLException {
 //        Statement statement = connection.createStatement();

+ 42 - 0
src/main/java/index/entity/Box.java

@@ -0,0 +1,42 @@
+package index.entity;
+
+import java.util.ArrayList;
+
+public class Box {
+
+    //网格的四个点,point里面并非真实物理坐标,用格子标号,比如(0,1),(1,0),(0,0),(1,1)
+    ArrayList<Point> pointsList = new ArrayList<>();
+
+    //网格的标志点
+    Point pointSymbol;
+
+    //网格的四条边
+    ArrayList<BoxEdge> boxEdgeArrayList;
+
+    //盒子宽度
+
+
+    public ArrayList<Point> getPointsList() {
+        return pointsList;
+    }
+
+    public void setPointsList(ArrayList<Point> pointsList) {
+        this.pointsList = pointsList;
+    }
+
+    public Point getPointSymbol() {
+        return pointSymbol;
+    }
+
+    public void setPointSymbol(Point pointSymbol) {
+        this.pointSymbol = pointSymbol;
+    }
+
+    public ArrayList<BoxEdge> getBoxEdgeArrayList() {
+        return boxEdgeArrayList;
+    }
+
+    public void setBoxEdgeArrayList(ArrayList<BoxEdge> boxEdgeArrayList) {
+        this.boxEdgeArrayList = boxEdgeArrayList;
+    }
+}

+ 55 - 0
src/main/java/index/entity/BoxEdge.java

@@ -0,0 +1,55 @@
+package index.entity;
+
+import java.util.ArrayList;
+
+public class BoxEdge {
+
+    Point point1;
+
+    Point point2;
+
+    public ArrayList<Point> getPoint12(){
+
+        ArrayList<Point> point12 = new ArrayList<>();
+
+        point12.add(point1);
+
+        point12.add(point2);
+
+        return point12;
+
+    }
+
+    public void setPoint12(Point point1,Point point2){
+
+        this.point1 = point1;
+
+        this.point2 = point2;
+
+    }
+
+    public Point getPoint1() {
+
+        return point1;
+
+    }
+
+    public void setPoint1(Point point1) {
+
+        this.point1 = point1;
+
+    }
+
+    public Point getPoint2() {
+
+        return point2;
+
+    }
+
+    public void setPoint2(Point point2) {
+
+        this.point2 = point2;
+
+    }
+
+}

+ 8 - 1
src/test/entity/GpsCor.java → src/main/java/index/entity/GpsCor.java

@@ -1,4 +1,4 @@
-package test.entity;
+package index.entity;
 
 public class GpsCor {
 
@@ -10,14 +10,21 @@ public class GpsCor {
     }
 
     public void setLat(Double lat) {
+
         this.lat = lat;
+
     }
 
     public Double getLon() {
+
         return lon;
+
     }
 
     public void setLon(Double lon) {
+
         this.lon = lon;
+
     }
+
 }

+ 1 - 1
src/test/entity/Index.java → src/main/java/index/entity/Index.java

@@ -1,4 +1,4 @@
-package test.entity;
+package index.entity;
 
 public class Index {
 

+ 1 - 1
src/test/entity/OccupyPerX.java → src/main/java/index/entity/OccupyPerX.java

@@ -1,4 +1,4 @@
-package test.entity;
+package index.entity;
 
 public class OccupyPerX {
 

+ 1 - 1
src/test/entity/Point.java → src/main/java/index/entity/Point.java

@@ -1,4 +1,4 @@
-package test.entity;
+package index.entity;
 
 public class Point {
 

+ 56 - 30
src/test/entity/WholeIndexOccupy.java → src/main/java/index/entity/WholeIndexOccupy.java

@@ -1,6 +1,6 @@
-package test.entity;
+package index.entity;
 
-import test.OperateFile;
+import index.file.OperateFile;
 
 import java.io.FileNotFoundException;
 import java.util.ArrayList;
@@ -16,8 +16,11 @@ public class WholeIndexOccupy {
         for (int i = 0;i < numberOfGaps;i++){
 
             OccupyPerX occupyPerX = new OccupyPerX();
+
             occupyPerX.setMinYIndex(1000);
+
             occupyPerX.setMaxYIndex(-1);
+
             occupyPerXArrayList.add(occupyPerX);
 
         }
@@ -27,6 +30,7 @@ public class WholeIndexOccupy {
     public ArrayList<Point> getOccupyPointsArrayList(){
 
         return occupyPointsArrayList;
+
     }
 
 
@@ -35,12 +39,15 @@ public class WholeIndexOccupy {
         OccupyPerX occupyPerXOld = occupyPerXArrayList.get(xIndex);
 
         Integer minYIndexOld = occupyPerXOld.getMinYIndex();
+
         Integer maxYIndexOld = occupyPerXOld.getMaxYIndex();
 
         Integer minYIndexForCal = occupyPerX.getMinYIndex();
+
         Integer maxYIndexForCal = occupyPerX.getMaxYIndex();
 
         Integer minYIndexTemp;
+
         Integer maxYIndexTemp;
 
         if (minYIndexOld < minYIndexForCal){
@@ -48,18 +55,19 @@ public class WholeIndexOccupy {
             minYIndexTemp = minYIndexOld;
 
         }
+
         else{
 
             minYIndexTemp = minYIndexForCal;
 
         }
 
-
         if (maxYIndexOld > maxYIndexForCal){
 
             maxYIndexTemp = maxYIndexOld;
 
         }
+
         else{
 
             maxYIndexTemp = maxYIndexForCal;
@@ -67,8 +75,11 @@ public class WholeIndexOccupy {
         }
 
         OccupyPerX occupyPerX1 = new OccupyPerX();
+
         occupyPerX1.setMinYIndex(minYIndexTemp);
+
         occupyPerX1.setMaxYIndex(maxYIndexTemp);
+
         occupyPerXArrayList.set(xIndex,occupyPerX1);
 
     }
@@ -88,26 +99,39 @@ public class WholeIndexOccupy {
         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 xCor1 = minX + i * xGap ;
-                Double xCor2 = minX + i * xGap + 1 * xGap;
-                Double yCor = minY + maxYIndex * yGap + 0.5 * yGap;
+                Double xCor = minX + i * xGap + 0.5 * xGap;
+//                Double xCor1 = minX + i * xGap ;
+//
+//                Double xCor2 = minX + i * xGap + 1 * xGap;
 
-                Point point1 = new Point();
-                Point point2 = new Point();
-                point1.setColX(xCor1);
-                point1.setColY(yCor);
+                Double yCor = minY + maxYIndex * yGap + 0.5 * yGap;
 
-                point2.setColX(xCor2);
-                point2.setColY(yCor);
-                printPointList.add(point1);
-                printPointList.add(point2);
+//                Point point1 = new Point();
+//
+//                Point point2 = new Point();
+//
+//                point1.setColX(xCor1);
+//
+//                point1.setColY(yCor);
+//
+//                point2.setColX(xCor2);
+//                point2.setColY(yCor);
+//                printPointList.add(point1);
+//                printPointList.add(point2);
 //                System.out.println(xCor + " " + yCor);
 
+                Point point = new Point();
+                point.setColX(xCor);
+                point.setColY(yCor);
+                printPointList.add(point);
+
 
             }
 
@@ -120,22 +144,24 @@ public class WholeIndexOccupy {
             Integer maxYIndex = occupyPerX.getMaxYIndex();
             if (maxYIndex != -1 && minYIndex !=1000){
 
-//                Double xCor = minX + i * xGap + 0.5 * xGap;
-                Double xCor1 = minX + i * xGap;
-                Double xCor2 = minX + i * xGap + 1 * xGap;
+                Double xCor = minX + i * xGap + 0.5 * xGap;
+//                Double xCor1 = minX + i * xGap;
+//                Double xCor2 = minX + i * xGap + 1 * xGap;
                 Double yCor = minY + minYIndex * yGap + 0.5 * yGap;
 
-//                Point point = new Point();
-                Point point1 = new Point();
-                Point point2 = new Point();
-                point1.setColX(xCor1);
-                point1.setColY(yCor);
-
-                point2.setColX(xCor2);
-                point2.setColY(yCor);
-                printPointList.add(point2);
-                printPointList.add(point1);
-
+                Point point = new Point();
+                point.setColX(xCor);
+                point.setColY(yCor);
+//                Point point1 = new Point();
+//                Point point2 = new Point();
+//                point1.setColX(xCor1);
+//                point1.setColY(yCor);
+//
+//                point2.setColX(xCor2);
+//                point2.setColY(yCor);
+//                printPointList.add(point2);
+//                printPointList.add(point1);
+                printPointList.add(point);
 //                System.out.println(xCor + " " + yCor);
             }
 
@@ -143,7 +169,7 @@ public class WholeIndexOccupy {
 
         printPointList.add(printPointList.get(0));
 
-        System.out.println("____________________________+++++++++++==");
+//        System.out.println("____________________________+++++++++++==");
 
         occupyPointsArrayList = printPointList;
 

+ 18 - 29
src/test/OperateFile.java → src/main/java/index/file/OperateFile.java

@@ -1,7 +1,6 @@
-package test;
-
-import test.entity.Point;
+package index.file;
 
+import index.entity.Point;
 import java.io.File;
 import java.io.FileInputStream;
 import java.io.FileNotFoundException;
@@ -10,61 +9,38 @@ import java.util.HashMap;
 import java.util.Map;
 import java.util.Scanner;
 
-public class OperateFile {
 
+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();
@@ -73,9 +49,22 @@ public class OperateFile {
 
     }
 
+    public ArrayList<Point> readPointsFromFile(String filePath) throws FileNotFoundException {
+        File file = new File(filePath);
+        Scanner input = new Scanner(file);
+        ArrayList<Point> dataArrayList = new ArrayList<>();
+        while (input.hasNext()){
+            Double x = input.nextDouble();
+            Double y = input.nextDouble();
+            Point point = new Point();
+            point.setColX(x);
+            point.setColY(y);
+            dataArrayList.add(point);
+        }
+        input.close();
+        return dataArrayList;
 
-
-
+    }
 
     public ArrayList readFileStream(String filePath) throws FileNotFoundException {
 

+ 207 - 0
src/main/java/index/fit/Fit.java

@@ -0,0 +1,207 @@
+package index.fit;
+
+import org.apache.commons.math3.fitting.GaussianCurveFitter;
+import org.apache.commons.math3.fitting.PolynomialCurveFitter;
+import org.apache.commons.math3.fitting.WeightedObservedPoint;
+import index.entity.Point;
+import index.alg.CurveTool;
+import org.apache.commons.math3.fitting.WeightedObservedPoints;
+import org.omg.CORBA.ARG_IN;
+
+import java.util.ArrayList;
+
+public class Fit {
+
+    public double[] fitByPoints(ArrayList<Point> pointArrayList){
+        int fitDegree = 3;//几阶拟合
+        PolynomialCurveFitter polynomialCurveFitter = PolynomialCurveFitter.create(fitDegree);
+        ArrayList<WeightedObservedPoint> weightedObservedPoints = new ArrayList<>();
+        for (int i = 0 ; i < pointArrayList.size();i++){
+            Point point = pointArrayList.get(i);
+            Double x = point.getColX();
+            Double y = point.getColY();
+            WeightedObservedPoint weightedObservedPoint = new WeightedObservedPoint(1,x,y);
+            weightedObservedPoints.add(weightedObservedPoint);
+        }
+        return polynomialCurveFitter.fit(weightedObservedPoints);
+    }
+
+    //fitPointsNum:多少个点拟合
+    //fillScale:拟合后起始点到终点之间需要补充的点的数量,为了拟合后画出的曲线能够更加光滑
+
+    public ArrayList<Point> halfCircleFit(ArrayList<Point> pointArrayList,Integer fitPointsNum,Integer fillScale,Integer excludeModel){
+
+        ArrayList<Point> pointArrayListAfterFilled = new ArrayList<>();
+        Integer pointsListLength = pointArrayList.size();
+        Integer roundNumber = pointsListLength / fitPointsNum;
+        Integer remainNumber = pointsListLength - roundNumber * fitPointsNum;
+        CurveTool curveTool = new CurveTool();
+
+        for (int i = 0 ; i < roundNumber; i++){
+
+            Integer jBegin = fitPointsNum * i;
+            Integer jEnd = jBegin + fitPointsNum;
+//            ArrayList<Point> subArrayListForFit = (ArrayList<Point>) pointArrayList.subList(jBegin,jEnd);
+            ArrayList<Point> subArrayListForFit = getSubArrayList(pointArrayList,jBegin,jEnd);
+            //
+//            subArrayListForFit = excludePoints(subArrayListForFit,excludeModel);//过滤点
+            //
+            double[] curveParam = fitByPoints(subArrayListForFit);
+            Point pointBegin = subArrayListForFit.get(0);
+            Point pointEnd = subArrayListForFit.get(subArrayListForFit.size() - 1);
+            Double xBegin = pointBegin.getColX();//子list的起点的横坐标
+            Double xEnd = pointEnd.getColX();//子list的终点的横坐标
+            Double indexLength = (xEnd - xBegin)/(fillScale + 1);
+
+            for (int k = 0 ; k < (fillScale + 2);k++){
+                Double xForCal = xBegin + k * indexLength;
+                Double y = curveTool.getCurveValue(xForCal,curveParam);
+                Point point = new Point();
+                point.setColX(xForCal);
+                point.setColY(y);
+                pointArrayListAfterFilled.add(point);
+            }
+
+        }
+        if (remainNumber != 0){
+
+            Point pointLeftBegin = pointArrayList.get(roundNumber * fitPointsNum);
+            Point pointLeftEnd = pointArrayList.get(pointArrayList.size() - 1);
+//        ArrayList<Point> subArrayListForFitLeft = (ArrayList<Point>) pointArrayList.subList(roundNumber * fitPointsNum,pointArrayList.size());
+            ArrayList<Point> subArrayListForFitLeft = getSubArrayList(pointArrayList,roundNumber * fitPointsNum,pointArrayList.size());
+//            subArrayListForFitLeft = excludePoints(subArrayListForFitLeft,excludeModel);
+            double[] curveParamLeft = fitByPoints(subArrayListForFitLeft);
+            Double xLeftBegin = pointLeftBegin.getColX();
+            Double xLeftEnd = pointLeftEnd.getColX();
+            Double indexLeftLength = (xLeftEnd - xLeftBegin)/(fillScale + 1);
+            for (int k = 0 ; k < (fillScale + 2);k++){
+                Double xForCal = xLeftBegin + k * indexLeftLength;
+                Double y = curveTool.getCurveValue(xForCal,curveParamLeft);
+                Point point = new Point();
+                point.setColX(xForCal);
+                point.setColY(y);
+                pointArrayListAfterFilled.add(point);
+            }
+
+        }
+
+
+        return pointArrayListAfterFilled;
+
+    }
+
+    public ArrayList<Point> allCircleFit(ArrayList<Point> pointArrayList,Integer fitPointsNum,Integer fillScale){
+
+        ArrayList<Point> pointsAfterFill = new ArrayList<>();
+        Integer length = pointArrayList.size();
+
+//        ArrayList<Point> subList1 = (ArrayList<Point>) pointArrayList.subList(0,length / 2);
+
+        ArrayList<Point> subList1 = getSubArrayList(pointArrayList,0,length / 2);
+
+//        ArrayList<Point> subList2 = (ArrayList<Point>) pointArrayList.subList(length / 2,length);
+
+        ArrayList<Point> subList2 = getSubArrayList(pointArrayList,length / 2,length);
+        ArrayList<Point> subPointsAfterFill1 = halfCircleFit(subList1,fitPointsNum,fillScale,0);
+        ArrayList<Point> subPointsAfterFill2 = halfCircleFit(subList2,fitPointsNum,fillScale,1);
+        pointsAfterFill.addAll(subPointsAfterFill1);
+        pointsAfterFill.addAll(subPointsAfterFill2);
+        pointsAfterFill.add(pointsAfterFill.get(0));
+        return pointsAfterFill;
+    }
+
+    public ArrayList<Point> allCircleFitDefault(ArrayList<Point> pointArrayList){
+
+        ArrayList<Point> pointsAfterFill = allCircleFit(pointArrayList,20,10);
+        return pointsAfterFill;
+    }
+
+    public ArrayList<Point> getSubArrayList(ArrayList<Point> parentArrayList,Integer beginIndex,Integer endIndex){
+
+        ArrayList<Point> subArrayList = new ArrayList<>();
+        for (int i = beginIndex ; i < endIndex ; i++ ){
+
+            Point pointTemp = parentArrayList.get(i);
+            subArrayList.add(pointTemp);
+        }
+
+        return subArrayList;
+
+    }
+
+    public ArrayList<Point> excludePoints(ArrayList<Point> pointsListForExclude,Integer excludeModel){
+
+        ArrayList<Point> pointsArraListAfterExclude = new ArrayList<>();
+        Point pointBegin = pointsListForExclude.get(0);
+        Point pointEnd = pointsListForExclude.get(pointsListForExclude.size() - 1);
+        pointsArraListAfterExclude.add(pointBegin);
+
+        for (int i = 1 ; i < pointsListForExclude.size() - 1;i++){
+
+            Point lastPoint = pointsListForExclude.get(i - 1);
+            Point nextPoint = pointsListForExclude.get(i + 1);
+            Point thisPoint = pointsListForExclude.get(i);
+            Double lastPointY = lastPoint.getColY();
+            Double nextPointY = nextPoint.getColY();
+            Double thisPointY = thisPoint.getColY();
+
+            if (excludeModel == 0){
+
+                if (!(thisPointY < nextPointY && thisPointY < lastPointY)){
+
+                    pointsArraListAfterExclude.add(thisPoint);
+
+                }
+            }else if (excludeModel == 1){
+
+                if (!(thisPointY > nextPointY && thisPointY > lastPointY)){
+
+                    pointsArraListAfterExclude.add(thisPoint);
+
+                }
+
+            }
+
+
+
+
+        }
+
+        pointsArraListAfterExclude.add(pointEnd);
+
+        return pointsArraListAfterExclude;
+
+    }
+
+    public ArrayList<Point> excludePoints(ArrayList<Point> pointsArrayList){
+
+        Integer pointsLength = pointsArrayList.size();
+        ArrayList<Point> pointArrayListAfterExclude = new ArrayList<>();
+        ArrayList<Point> subpointsArrayList1 = getSubArrayList(pointsArrayList,0,pointsLength / 2);
+        ArrayList<Point> subpointsArrayList2 = getSubArrayList(pointsArrayList,pointsLength / 2,pointsLength);
+        pointArrayListAfterExclude.addAll(excludePoints(subpointsArrayList1,0));
+        pointArrayListAfterExclude.addAll(excludePoints(subpointsArrayList2,1));
+        pointArrayListAfterExclude.add(pointArrayListAfterExclude.get(pointArrayListAfterExclude.size() - 1));
+        return pointArrayListAfterExclude;
+
+    }
+
+    public double[] gaussFit(ArrayList<Point> pointArrayList){
+
+        WeightedObservedPoints guassWeightObservedPoint = new WeightedObservedPoints();
+        for (int i = 0 ; i < pointArrayList.size();i++){
+            Point point = pointArrayList.get(i);
+            guassWeightObservedPoint.add(point.getColX(),point.getColY());
+
+        }
+        double[] parameters = GaussianCurveFitter.create().fit(guassWeightObservedPoint.toList());
+        System.out.println("高斯拟合");
+        for (int i = 0 ; i < parameters.length;i++){
+            System.out.println(parameters[i]);
+        }
+        System.out.println("高斯拟合结束");
+        return parameters;
+    }
+
+
+}

+ 1 - 1
src/test/GPS/GpsConvertMethod.java → src/main/java/index/gps/GpsConvertMethod.java

@@ -1,4 +1,4 @@
-package test.GPS;
+package index.gps;
 
 /**
  * @创建人 ccj

+ 2 - 3
src/test/GpsExchange.java → src/main/java/index/gps/GpsExchange.java

@@ -1,8 +1,7 @@
-package test;
+package index.gps;
 
 //import test.entity.GpsCor;
-import test.GPS.GpsConvertMethod;
-import test.entity.Point;
+import index.entity.Point;
 
 public class GpsExchange {
 

+ 2 - 0
src/CalculateArea.java → src/main/java/shift/CalculateArea.java

@@ -1,3 +1,5 @@
+package shift;
+
 import java.io.FileNotFoundException;
 import java.io.PrintWriter;
 import java.util.ArrayList;

+ 2 - 0
src/DataType.java → src/main/java/shift/DataType.java

@@ -1,3 +1,5 @@
+package shift;
+
 import java.util.ArrayList;
 
 public class DataType<T> {

+ 2 - 0
src/MeanShift.java → src/main/java/shift/MeanShift.java

@@ -1,3 +1,5 @@
+package shift;
+
 import java.io.FileNotFoundException;
 import java.io.PrintWriter;
 import java.util.ArrayList;

+ 2 - 0
src/ReadData.java → src/main/java/shift/ReadData.java

@@ -1,3 +1,5 @@
+package shift;
+
 import java.io.FileNotFoundException;
 import java.util.ArrayList;
 import java.util.Scanner;

+ 2 - 0
src/ResultDataType.java → src/main/java/shift/ResultDataType.java

@@ -1,3 +1,5 @@
+package shift;
+
 import java.util.ArrayList;
 
 public class ResultDataType {

+ 0 - 152
src/test/GetPoints.java

@@ -1,152 +0,0 @@
-package test;
-
-
-import test.entity.Point;
-
-import java.io.FileNotFoundException;
-import java.sql.Connection;
-import java.sql.ResultSet;
-import java.sql.SQLException;
-import java.util.ArrayList;
-import java.util.Map;
-
-//暂时先自己写connection从数据库中获取
-
-public class GetPoints {
-
-    String userName = "nps_tc01";
-    String password = "nps_tc01";
-    String driver = "oracle.jdbc.driver.OracleDriver";
-    String url = "jdbc:oracle:thin:@172.16.2.114:1521:orcl1";
-
-
-    ArrayList<Point> realShapePoints = new ArrayList<>();
-    ArrayList<Point> allPoints = new ArrayList<>();
-
-    public ArrayList<Point> returnPoints(){
-
-        ArrayList<Point> pointList = new ArrayList<>();
-
-        return pointList;
-
-    }
-
-    public void getPoints() throws SQLException, FileNotFoundException {
-
-
-
-        //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')";
-
-//        realShapePoints = buildPoints(sql1);
-//        allPoints = buildPoints(sql2);
-        realShapePoints = buildPointsFromFile("Y:\\programresult\\dbdiff\\points\\shape.txt");
-        allPoints = buildPointsFromFile("Y:\\programresult\\dbdiff\\points\\allpoints.txt");
-
-
-
-//        Connection
-
-    }
-
-    public ArrayList<Point> buildPoints(String sql) throws SQLException {
-
-
-        ArrayList<Point> pointArrayList = new ArrayList<>();
-
-        ConnectToSourceDB connectToSourceDB = new ConnectToSourceDB();
-        connectToSourceDB.setConnPara(userName,password,driver,url);
-        Connection connection = connectToSourceDB.getConnection();
-
-
-        DbOperate dbOperate = new DbOperate();
-
-        ResultSet resultSet = dbOperate.runQuerySql(connection,sql);
-
-        GpsExchange gpsExchange = new GpsExchange();
-
-        while (resultSet.next()){
-
-            Double lat = resultSet.getDouble(1);
-            Double lon = resultSet.getDouble(2);
-            Point point = gpsExchange.gpsToPoints(lat,lon);
-            pointArrayList.add(point);
-
-        }
-
-        return pointArrayList;
-
-
-    }
-
-
-    public ArrayList<Point> buildPointsFromFile(String filePath) throws FileNotFoundException {
-
-        ArrayList<Point> pointArrayList = new ArrayList<>();
-        OperateFile operateFile = new OperateFile();
-        ArrayList<Map> pointsMapList = operateFile.readPoints(filePath);
-
-        for (int i = 0 ; i < pointsMapList.size();i++){
-
-            Map mapTemp = pointsMapList.get(i);
-            Double lat = (Double) mapTemp.get("lat");
-            Double lon = (Double) mapTemp.get("lon");
-            GpsExchange gpsExchange = new GpsExchange();
-            Point point = gpsExchange.gpsToPoints(lat,lon);
-            pointArrayList.add(point);
-
-        }
-
-
-
-        return pointArrayList;
-
-
-    }
-
-
-
-}