gushoubang 1 жил өмнө
parent
commit
d36a49b749

+ 6 - 0
onemap-modules/onemap-analyse/src/main/java/com/onemap/analyse/mapper/vector/CreateUtilsDBMapper.java

@@ -29,6 +29,12 @@ public interface CreateUtilsDBMapper {
     void bufferColumnTable(@Param("tableName") String tableName,
                            @Param("column") String column,
                            @Param("newTableName") String newTableName);
+    /**
+     * 计算ewkt 空间数据的缓冲区,并返回新的ewkt
+     */
+    @Slave
+    void bufferEwkt(@Param("newTableName") String newTableName,
+                    @Param("radius") float radius);
 
     /**
      * 生成表tableNameB空间数据的差集,B-ST_Intersection(A,B)

+ 14 - 13
onemap-modules/onemap-analyse/src/main/java/com/onemap/analyse/service/CreateUtilsDBService.java

@@ -24,6 +24,15 @@ public interface CreateUtilsDBService {
      */
     String bufferTable(String tableName, String column);
 
+    /**
+     * 生成ewkt的缓冲区
+     *
+     * @param ewkt
+     * @param radius
+     * @return
+     */
+    String bufferEekt(String ewkt, float radius);
+
     /**
      * 生成表tableNameB空间数据的差集,B-ST_Intersection(A,B)
      *
@@ -32,9 +41,7 @@ public interface CreateUtilsDBService {
      * @param tableNameB
      * @return
      */
-    String differenceTables(String tableNameA,
-                            List<String> tableIdsA,
-                            String tableNameB);
+    String differenceTables(String tableNameA, List<String> tableIdsA, String tableNameB);
 
     /**
      * 生成表tableName空间数据的差集,tableName-ewkt
@@ -44,9 +51,7 @@ public interface CreateUtilsDBService {
      * @param ewkt
      * @return
      */
-    String differenceTableWkt(String tableName,
-                            List<String> tableIds,
-                            String ewkt);
+    String differenceTableWkt(String tableName, List<String> tableIds, String ewkt);
 
     /**
      * table中与wkt数据取交集
@@ -56,19 +61,15 @@ public interface CreateUtilsDBService {
      * @param ewkt      wkt
      * @return
      */
-    String intersectionTableWkt(
-            String tableName,
-            List<String> tableIds,
-            String ewkt);
+    String intersectionTableWkt(String tableName, List<String> tableIds, String ewkt);
 
     /**
      * 生成表tableNameA与表tableNameB的空间交集
+     *
      * @param tableNameA
      * @param tableIdsA
      * @param tableNameB
      * @return
      */
-    String intersectionTables(String tableNameA,
-                            List<String> tableIdsA,
-                            String tableNameB);
+    String intersectionTables(String tableNameA, List<String> tableIdsA, String tableNameB);
 }

+ 9 - 1
onemap-modules/onemap-analyse/src/main/java/com/onemap/analyse/service/impl/CreateUtilsDBServiceImpl.java

@@ -31,11 +31,19 @@ public class CreateUtilsDBServiceImpl implements CreateUtilsDBService {
         String[] tableNames = Strings.split(tableName, '_');
 
         String newTableName = TEMPORARY + "_" + timestamp + "_buffer_" + tableNames[tableNames.length - 1];
-        ;
+
         createUtilsDBMapper.bufferColumnTable(tableName, column, newTableName);
         return newTableName;
     }
 
+    @Override
+    public String bufferEekt(String ewkt, float radius) {
+        long timestamp = System.currentTimeMillis();
+        String newTableName = TEMPORARY + "_" + timestamp + "_buffer";
+        createUtilsDBMapper.bufferEwkt(newTableName, radius);
+        return newTableName;
+    }
+
     @Override
     public String differenceTableWkt(String tableName, List<String> tableIds, String ewkt) {
         long timestamp = System.currentTimeMillis();

+ 46 - 36
onemap-modules/onemap-analyse/src/main/java/com/onemap/analyse/service/impl/FzssServiceImpl.java

@@ -274,6 +274,34 @@ public class FzssServiceImpl implements IFzssService {
         return RequestResult.success(resMap);
     }
 
+    /**
+     * 花落去因子的大地块
+     */
+    private String getFactorEwkt(String tableName, String ewkt, float factorRadius, float ewktRadius) {
+        // 0.生成范围的缓冲区
+        if (ewktRadius != 0) {
+            ewkt = createUtilsDBService.bufferEekt(ewkt, ewktRadius);
+        }
+
+        // 1.查询因子地块
+        String tempTable = createUtilsDBService.intersectionTableWkt(tableName, null, ewkt);
+        Integer integer = ghdkaMapper.getTableCount(tempTable);
+        if (integer == 0) return "";
+        // 2.生成因子地块缓冲区
+        if (factorRadius != 0) {
+            tempTable = createUtilsDBService.bufferTable(tempTable, factorRadius);
+        }
+        // 3.生成因子地块ewkt
+        TableNameIdsVo tableNameIdsVo = new TableNameIdsVo();
+        tableNameIdsVo.setTableName(tempTable);
+        String calculateEwkt = tableDateService.getGeomUnion(tableNameIdsVo);
+        return calculateEwkt;
+    }
+
+
+    // iLogService.saveLog(taskId, "辅助选址", factorUseDTO.getFactorName() + "因子影响分析完成", "info");
+    // iLogService.saveLog(taskId, "辅助选址", factorUseDTO.getFactorName() + "因子影响分析完成", "info");
+
     /**
      * 根据因子筛选地块
      *
@@ -283,57 +311,39 @@ public class FzssServiceImpl implements IFzssService {
      * @param ewkt
      */
     private String factorFilter(String taskId, String rawTable, List<FactorUseDTO> factorUseDTOS, String ewkt) {
-
         for (FactorUseDTO factorUseDTO : factorUseDTOS) {
             if (factorUseDTO.getSpatialType().equals("intersect")) {
-                // 相交判断
                 // 1.先切割因子地块
-                String tempTable = createUtilsDBService.intersectionTableWkt(factorUseDTO.getFactorBsm(), null, ewkt);
-                Integer integer = ghdkaMapper.getTableCount(tempTable);
-                if (integer == 0) {
-                    // TODO 再定
-                    iLogService.saveLog(taskId, "辅助选址", factorUseDTO.getFactorName() + "因子影响分析完成", "info");
-                    continue;
-                }
-                // 2.生成因子地块缓冲区
-                if (factorUseDTO.getDefaultValue() != 0) {
-                    // 没有值直接计算
-                    tempTable = createUtilsDBService.bufferTable(tempTable, factorUseDTO.getDefaultValue());
-
-                    integer = ghdkaMapper.getTableCount(tempTable);
-                    if (integer == 0) {
-                        // TODO 再定
-                        iLogService.saveLog(taskId, "辅助选址", factorUseDTO.getFactorName() + "因子影响分析完成", "info");
-                        continue;
-                    }
-                }
-                // 3.地块切割
-                // 3.1查询需要切割的地块
-                TableNameIdsVo tableNameIdsVo = new TableNameIdsVo();
-                tableNameIdsVo.setTableName(tempTable);
-                String calculateEwkt = tableDateService.getGeomUnion(tableNameIdsVo);
-
-                // 3.2切割
+                String calculateEwkt = getFactorEwkt(factorUseDTO.getFactorName(), ewkt, factorUseDTO.getDefaultValue());
+                // 2.切割地块
                 if (factorUseDTO.getDefaultType().equals("intersect")) {
-                    // 相交判断
+                    // 地块与因子求交集
                     rawTable = createUtilsDBService.intersectionTableWkt(rawTable, null, calculateEwkt);
                 } else {
-                    // 不相交判断
+                    // 地块与因子求差集
                     rawTable = createUtilsDBService.differenceTableWkt(rawTable, null, calculateEwkt);
                 }
             } else if (factorUseDTO.getSpatialType().equals("contain")) {
+                // TODO 计算地块缓冲区可能有问题,但是现在包含没有缓冲区
+                // 1.先切割因子地块
+                String calculateEwkt = getFactorEwkt(factorUseDTO.getFactorName(), ewkt, factorUseDTO.getDefaultValue(), 0);
                 // 包含判断
-                if (factorUseDTO.getDefaultValue() == 0) {
-
+                if (factorUseDTO.getDefaultType().equals("contain")) {
+                    // 地块与因子求差集
+                    rawTable = createUtilsDBService.intersectionTableWkt(rawTable, null, calculateEwkt);
                 } else {
-
+                    // 地块与因子求差集
+                    rawTable = createUtilsDBService.differenceTableWkt(rawTable, null, calculateEwkt);
                 }
             } else if (factorUseDTO.getSpatialType().equals("distance")) {
+                String calculateEwkt = getFactorEwkt(factorUseDTO.getFactorName(), ewkt, factorUseDTO.getDefaultValue(), factorUseDTO.getDefaultValue());
                 // 距离判断
-                if (factorUseDTO.getDefaultValue() == 0) {
-
+                if (factorUseDTO.getDefaultType().equals("lt") || factorUseDTO.getDefaultType().equals("let")) {
+                    // 地块与因子求差集
+                    rawTable = createUtilsDBService.intersectionTableWkt(rawTable, null, calculateEwkt);
                 } else {
-
+                    // 地块与因子求差集
+                    rawTable = createUtilsDBService.differenceTableWkt(rawTable, null, calculateEwkt);
                 }
             }
             if (0 == 0) {

+ 5 - 0
onemap-modules/onemap-analyse/src/main/resources/mapper/oracle/vector/CreateUtilsDBMapper.xml

@@ -15,6 +15,11 @@
         FROM "${tableName}"
         WHERE geom IS NOT NULL
     </insert>
+
+    <select id="bufferEwkt" resultType="String">
+        SELECT public.ST_AsEWKT(public.ST_Buffer(public.ST_GeomFromEWKT(#{ewkt})::public.geography, #{radius}) ::public.geometry) AS ewkt
+    </select>
+
     <insert id="differenceTables">
         DROP TABLE IF EXISTS "${temporaryTable}";