浏览代码

生成交集表

gushoubang 9 月之前
父节点
当前提交
c9387df22e

+ 16 - 16
onemap-modules/onemap-analyse/src/main/java/com/onemap/analyse/controller/analyse/AnalyseUtilsDBController.java

@@ -40,22 +40,22 @@ public class AnalyseUtilsDBController extends BaseController {
     }
 
 
-    /**
-     * table中与wkt数据取交集
-     *
-     * @param inputTable          TABLE名称(vater空间中表)
-     * @param inputSRID           table
-     * @param inputIds            查询数据集ID
-     * @param intersectionWkt     wkt
-     * @param intersectionWktSRID wkt对应的坐标
-     * @param outputColumn        返回TABLE表中的字段,先已返回,ID,GEOM(交集的),geom_area (交集的)
-     * @return
-     */
-    @PostMapping("/intersection/table_wkt")
-    @Slave
-    public RequestResult intersectionTableWkt(@RequestParam(value = "inputTable") String inputTable, @RequestParam(value = "inputSRID", required = false) Integer inputSRID, @RequestParam(value = "inputIds", required = false) List<String> inputIds, @RequestParam(value = "intersectionWkt") String intersectionWkt, @RequestParam(value = "intersectionWktSRID", required = false) Integer intersectionWktSRID, @RequestParam(value = "outputColumn", required = false) List<String> outputColumn) {
-        return RequestResult.success(analyseUtilsDBService.intersectionTableWkt(inputTable, inputSRID, inputIds, intersectionWkt, intersectionWktSRID, outputColumn));
-    }
+    // /**
+    //  * table中与wkt数据取交集
+    //  *
+    //  * @param inputTable          TABLE名称(vater空间中表)
+    //  * @param inputSRID           table
+    //  * @param inputIds            查询数据集ID
+    //  * @param intersectionWkt     wkt
+    //  * @param intersectionWktSRID wkt对应的坐标
+    //  * @param outputColumn        返回TABLE表中的字段,先已返回,ID,GEOM(交集的),geom_area (交集的)
+    //  * @return
+    //  */
+    // @PostMapping("/intersection/table_wkt")
+    // @Slave
+    // public RequestResult intersectionTableWkt(@RequestParam(value = "inputTable") String inputTable, @RequestParam(value = "inputSRID", required = false) Integer inputSRID, @RequestParam(value = "inputIds", required = false) List<String> inputIds, @RequestParam(value = "intersectionWkt") String intersectionWkt, @RequestParam(value = "intersectionWktSRID", required = false) Integer intersectionWktSRID, @RequestParam(value = "outputColumn", required = false) List<String> outputColumn) {
+    //     return RequestResult.success(analyseUtilsDBService.intersectionTableWkt(inputTable, inputSRID, inputIds, intersectionWkt, intersectionWktSRID, outputColumn));
+    // }
 
     // /**
     //  * table中与wkt数据取交集

+ 19 - 4
onemap-modules/onemap-analyse/src/main/java/com/onemap/analyse/controller/analyse/CreateUtilsDBController.java

@@ -2,15 +2,14 @@ package com.onemap.analyse.controller.analyse;
 
 import com.onemap.analyse.domain.vo.BufferTablesVo;
 import com.onemap.analyse.domain.vo.DifferenceTablesVo;
+import com.onemap.analyse.domain.vo.IntersectsTableWktVo;
+import com.onemap.analyse.service.AnalyseUtilsDBService;
 import com.onemap.analyse.service.CreateUtilsDBService;
 import com.onemap.common.core.web.controller.BaseController;
 import com.onemap.common.core.web.domain.RequestResult;
 import com.onemap.common.datasource.annotation.Slave;
 import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.web.bind.annotation.PostMapping;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RequestParam;
-import org.springframework.web.bind.annotation.RestController;
+import org.springframework.web.bind.annotation.*;
 
 import java.util.HashMap;
 import java.util.List;
@@ -63,4 +62,20 @@ public class CreateUtilsDBController extends BaseController {
         result.put("tableName", newTable);
         return RequestResult.success(newTable);
     }
+
+    /**
+     * table中与wkt数据取交集
+     *
+     * @param intersectsTableWktVo
+
+     * @return
+     */
+    @PostMapping("/intersection/table_wkt")
+    @Slave
+    public RequestResult intersectionTableWkt(@RequestBody IntersectsTableWktVo intersectsTableWktVo) {
+        return RequestResult.success(createUtilsDBService.intersectionTableWkt(
+                intersectsTableWktVo.getTableName(),
+                intersectsTableWktVo.getTableIds(),
+                intersectsTableWktVo.getEwkt()));
+    }
 }

+ 1 - 1
onemap-modules/onemap-analyse/src/main/java/com/onemap/analyse/domain/vo/DifferenceTablesVo.java

@@ -7,6 +7,6 @@ import java.util.List;
 @Data
 public class DifferenceTablesVo {
     String tableNameA;
-    List<String> tableIdsA;
+    List<Integer> tableIdsA;
     String tableNameB;
 }

+ 1 - 6
onemap-modules/onemap-analyse/src/main/java/com/onemap/analyse/domain/vo/IntersectsTableWktVo.java

@@ -7,11 +7,6 @@ import java.util.List;
 @Data
 public class IntersectsTableWktVo {
     private String tableName;
-    private List<String> tableIds;
+    private List<Integer> tableIds;
     private String ewkt;
-
-    // private Integer inputSRID;
-    // private String analyseType;
-    // // private Integer analyseWktSRID;
-    // List<String> outputColumn;
 }

+ 1 - 1
onemap-modules/onemap-analyse/src/main/java/com/onemap/analyse/mapper/AnalyseUtilsDBMapper.java

@@ -19,7 +19,7 @@ public interface AnalyseUtilsDBMapper {
      */
     List<Integer> intersectsTableWkt(
             @Param("tableName") String tableName,
-            @Param("tableIds") List<String> tableIds,
+            @Param("tableIds") List<Integer> tableIds,
             @Param("ewkt") String ewkt);
 
     /**

+ 13 - 1
onemap-modules/onemap-analyse/src/main/java/com/onemap/analyse/mapper/CreateUtilsDBMapper.java

@@ -26,8 +26,20 @@ public interface CreateUtilsDBMapper {
      * @return
      */
     void differenceTables(@Param("tableNameA") String tableNameA,
-                          @Param("tableIdsA") List<String> tableIdsA,
+                          @Param("tableIdsA") List<Integer> tableIdsA,
                           @Param("tableNameB") String tableNameB,
                           @Param("newTableName") String newTableName,
                           @Param("temporaryTable")String temporaryTable);
+
+    /**
+     * 计算tableName 空间数据的缓冲区,并存储成新的表
+     *
+     * @param tableName
+     * @param tableIds
+     * @return
+     */
+    void intersectionTableWkt(@Param("tableName") String tableName,
+                     @Param("tableIds") List<Integer> tableIds,
+                     @Param("ewkt") String ewkt,
+                     @Param("newTableName") String newTableName);
 }

+ 2 - 19
onemap-modules/onemap-analyse/src/main/java/com/onemap/analyse/service/AnalyseUtilsDBService.java

@@ -20,27 +20,10 @@ public interface AnalyseUtilsDBService {
      */
     List<Integer> intersectsTableWkt(
             String tableName,
-            List<String> tableIds,
+            List<Integer> tableIds,
             String ewkt);
 
-    /**
-     * table中与wkt数据取交集
-     *
-     * @param inputTable          TABLE名称(vater空间中表)
-     * @param inputSRID           table
-     * @param inputIds            查询数据集ID
-     * @param intersectionWkt     wkt
-     * @param intersectionWktSRID wkt对应的坐标
-     * @param outputColumn        返回TABLE表中的字段,先已返回,ID,GEOM(交集的),geom_area (交集的)
-     * @return
-     */
-    List<Map> intersectionTableWkt(
-            String inputTable,
-            Integer inputSRID,
-            List<String> inputIds,
-            String intersectionWkt,
-            Integer intersectionWktSRID,
-            List<String> outputColumn);
+
 
     /**
      * 计算wkt包含table中的数据,返回table id

+ 16 - 1
onemap-modules/onemap-analyse/src/main/java/com/onemap/analyse/service/CreateUtilsDBService.java

@@ -23,5 +23,20 @@ public interface CreateUtilsDBService {
      * @param tableNameB
      * @return
      */
-    String differenceTables(String tableNameA, List<String> tableIdsA, String tableNameB);
+    String differenceTables(String tableNameA,
+                            List<Integer> tableIdsA,
+                            String tableNameB);
+
+    /**
+     * table中与wkt数据取交集
+     *
+     * @param tableName TABLE名称(vater空间中表)
+     * @param tableIds  table
+     * @param ewkt      wkt
+     * @return
+     */
+    String intersectionTableWkt(
+            String tableName,
+            List<Integer> tableIds,
+            String ewkt);
 }

+ 5 - 5
onemap-modules/onemap-analyse/src/main/java/com/onemap/analyse/service/impl/AnalyseUtilsDBServiceImpl.java

@@ -16,14 +16,14 @@ public class AnalyseUtilsDBServiceImpl implements AnalyseUtilsDBService {
     private AnalyseUtilsDBMapper analyseUtilsDBMapper;
 
     @Override
-    public List<Integer> intersectsTableWkt(String tableName, List<String> tableIds, String ewkt) {
+    public List<Integer> intersectsTableWkt(String tableName, List<Integer> tableIds, String ewkt) {
         return analyseUtilsDBMapper.intersectsTableWkt(tableName, tableIds, ewkt);
     }
 
-    @Override
-    public List<Map> intersectionTableWkt(String inputTable, Integer inputSRID, List<String> inputIds, String intersectionWkt, Integer intersectionWktSRID, List<String> outputColumn) {
-        return analyseUtilsDBMapper.intersectionTableWkt(inputTable, inputSRID, inputIds, intersectionWkt, intersectionWktSRID, outputColumn);
-    }
+    // @Override
+    // public List<Map> intersectionTableWkt(String inputTable, Integer inputSRID, List<String> inputIds, String intersectionWkt, Integer intersectionWktSRID, List<String> outputColumn) {
+    //     return analyseUtilsDBMapper.intersectionTableWkt(inputTable, inputSRID, inputIds, intersectionWkt, intersectionWktSRID, outputColumn);
+    // }
 
     @Override
     public List<Integer> containsTableWkt(String tableName, List<String> tableIds, String ewkt) {

+ 12 - 4
onemap-modules/onemap-analyse/src/main/java/com/onemap/analyse/service/impl/CreateUtilsDBServiceImpl.java

@@ -21,11 +21,19 @@ public class CreateUtilsDBServiceImpl implements CreateUtilsDBService {
     }
 
     @Override
-    public String differenceTables(String tableNameA, List<String> tableIdsA, String tableNameB) {
+    public String differenceTables(String tableNameA, List<Integer> tableIdsA, String tableNameB) {
         long timestamp = System.currentTimeMillis();
-        String newDiffName = tableNameA + "_diff_" + tableNameB+"_" + timestamp;
+        String newTableName = tableNameA + "_diff_" + tableNameB+"_" + timestamp;
         String temporaryTable = "temporaryTable_" + timestamp;
-        createUtilsDBMapper.differenceTables(tableNameA, tableIdsA, tableNameB, newDiffName, temporaryTable);
-        return newDiffName;
+        createUtilsDBMapper.differenceTables(tableNameA, tableIdsA, tableNameB, newTableName, temporaryTable);
+        return newTableName;
+    }
+
+    @Override
+    public String intersectionTableWkt(String tableName, List<Integer> tableIds, String ewkt) {
+        long timestamp = System.currentTimeMillis();
+        String newTableName = tableName + "_inter_" +  timestamp;
+        createUtilsDBMapper.intersectionTableWkt(tableName, tableIds, ewkt,newTableName);
+        return newTableName;
     }
 }

+ 1 - 1
onemap-modules/onemap-analyse/src/main/resources/mapper/oracle/raster/AnalyseUtilsDBMapper.xml

@@ -12,7 +12,7 @@
         inTbale.geom
         )
         <if test="tableIds != null and tableIds.size()>0 ">
-            and (inTbale.id)::VARCHAR in
+            and (inTbale.id) in
             <foreach collection="tableIds" item="id" open="(" close=")" separator=",">#{id}</foreach>
         </if>
     </select>

+ 15 - 2
onemap-modules/onemap-analyse/src/main/resources/mapper/oracle/raster/CreateUtilsDBMapper.xml

@@ -20,14 +20,14 @@
         WHERE
         public.st_intersects ( a.geom, b.geom )
         <if test="tableIdsA != null and tableIdsA.size() > 0">
-            AND a.id::VARCHAR IN
+            AND a.id IN
             <foreach collection="tableIdsA" item="tableId" open="(" close=")" separator=",">
                 #{tableId}
             </foreach>
         </if>;
 
         CREATE TABLE "${newTableName}" AS
-        SELECT id,public.ST_Difference ( a.geom, b.geomRes ) AS geom
+        SELECT a.id,public.ST_Difference ( a.geom, b.geomRes ) AS geom
         FROM
         "${tableNameA}" a,
         "${temporaryTable}" b
@@ -41,4 +41,17 @@
 
         DROP TABLE IF EXISTS "${temporaryTable}";
     </insert>
+
+    <insert id="intersectionTableWkt" >
+        CREATE TABLE "${newTableName}" AS
+        SELECT id,public.ST_Intersection(inTbale.geom, public.st_geomfromewkt(#{ewkt})) AS geom
+        FROM "${tableName}" inTbale
+        WHERE 1=1
+        <if test="tableIds != null and tableIds.size() > 0">
+            AND inTbale.id IN
+            <foreach collection="tableIds" item="tableId" open="(" close=")" separator=",">
+                #{tableId}
+            </foreach>
+        </if>;
+    </insert>
 </mapper>