Bladeren bron

距离范围内筛选

gushoubang 1 jaar geleden
bovenliggende
commit
da746c0b97

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

@@ -114,7 +114,7 @@ public class AnalyseUtilsDBController extends BaseController {
     }
 
     /**
-     * 计算TableA包含TableB中的数据,返回tableB id
+     * 计算距离TableA小于指定距离中TableB中的数据,返回tableB id
      *
      * @param inputTableA
      * @param inputTableB

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

@@ -79,7 +79,7 @@ public interface AnalyseUtilsDBMapper {
      * @param ewkt      wkt
      * @return
      */
-    List<String> distanceTableWkt(
+    List<Integer> distanceTableWkt(
             @Param("tableName") String tableName,
             @Param("tableIds") List<String> tableIds,
             @Param("ewkt") String ewkt,
@@ -92,7 +92,7 @@ public interface AnalyseUtilsDBMapper {
      * @param tableNameB
      * @return
      */
-    List<String> distanceTables(
+    List<Integer> distanceTables(
             @Param("tableNameA") String tableNameA,
             @Param("tableNameB") String tableNameB,
             @Param("tableIdsB") List<String> tableIdsB,

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

@@ -78,7 +78,7 @@ public interface AnalyseUtilsDBService {
      * @param wkt wkt
      * @return
      */
-    List<String> distanceTableWkt(String inputTable,
+    List<Integer> distanceTableWkt(String inputTable,
                                   List<String> inputIds,
                                   String wkt,
                                   Integer distance);
@@ -89,7 +89,7 @@ public interface AnalyseUtilsDBService {
      * @param inputIdsB
      * @return
      */
-    List<String> distanceTables(
+    List<Integer> distanceTables(
             String inputTableA,
             String inputTableB,
             List<String> inputIdsB,

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

@@ -37,13 +37,13 @@ public class AnalyseUtilsDBServiceImpl implements AnalyseUtilsDBService {
     }
 
     @Override
-    public List<String> distanceTableWkt(String tableName, List<String> tableIds, String wkt, Integer distance) {
+    public List<Integer> distanceTableWkt(String tableName, List<String> tableIds, String wkt, Integer distance) {
         String ewkt=Srid4326+wkt;
         return analyseUtilsDBMapper.distanceTableWkt(tableName, tableIds, ewkt, distance);
     }
 
     @Override
-    public List<String> distanceTables(String tableNameA, String tableNameB, List<String> tableIdsB, Integer distance) {
+    public List<Integer> distanceTables(String tableNameA, String tableNameB, List<String> tableIdsB, Integer distance) {
         return analyseUtilsDBMapper.distanceTables(tableNameA, tableNameB, tableIdsB, distance);
     }
 }

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

@@ -124,7 +124,7 @@
         )
     </select>
 
-    <select id="distanceTableWkt" resultType="String">
+    <select id="distanceTableWkt" resultType="Integer">
         SELECT id
         FROM "${tableName}" inTbale
         where public.st_distance(
@@ -136,15 +136,20 @@
         </if>
     </select>
 
-    <select id="distanceTables" resultType="String">
+    <select id="distanceTables" resultType="Integer">
         SELECT id
-        FROM "${tableName}" inTbale
-        where public.st_distance(
-        inTbale.geom::public.geography,
-        public.st_geomfromewkt(#{ewkt})::public.geography) &lt; #{distance}
-        <if test="inputIds != null and inputIds.size()>0 ">
-            and (inTbale.id)::VARCHAR in
-            <foreach collection="inputIds" item="id" open="(" close=")" separator=",">#{id}</foreach>
+        FROM "${tableNameB}" tableB
+        WHERE 1=1
+        <if test="tableIdsB != null and tableIdsB.size()>0 ">
+            and (tableB.id)::VARCHAR in
+            <foreach collection="tableIdsB" item="tableId" open="(" close=")" separator=",">#{tableId}</foreach>
         </if>
+        AND EXISTS (
+        SELECT 1
+        FROM "${tableNameA}" as tableA
+        WHERE public.ST_DWithin(
+        tableA.geom::public.geography,
+        tableB.geom::public.geography,#{distance})
+        )
     </select>
 </mapper>