|
@@ -0,0 +1,67 @@
|
|
|
+<?xml version="1.0" encoding="UTF-8" ?>
|
|
|
+<!DOCTYPE mapper
|
|
|
+ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|
|
+ "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
|
|
+<mapper namespace="com.onemap.analyse.mapper.vector.TableDataMapper">
|
|
|
+
|
|
|
+ <select id="getRawTable" resultType="Map">
|
|
|
+ SELECT
|
|
|
+ <foreach item="column" collection="columns" separator=",">
|
|
|
+ <choose>
|
|
|
+ <when test="column == 'geom'">
|
|
|
+ public.st_asewkt(${column}) AS geom
|
|
|
+ </when>
|
|
|
+ <otherwise>
|
|
|
+ ${column}
|
|
|
+ </otherwise>
|
|
|
+ </choose>
|
|
|
+ </foreach>
|
|
|
+ <choose>
|
|
|
+ <when test="siweiArea == true">
|
|
|
+ , public.st_area(geom::public.geography) AS siweiArea
|
|
|
+ </when>
|
|
|
+ </choose>
|
|
|
+ FROM
|
|
|
+ "${rawTableName}"
|
|
|
+ WHERE
|
|
|
+ id IN
|
|
|
+ <foreach item="id" collection="ids" open="(" separator="," close=")">
|
|
|
+ #{id}
|
|
|
+ </foreach>
|
|
|
+ </select>
|
|
|
+
|
|
|
+ <select id="getTargetTable" resultType="Map">
|
|
|
+ DROP TABLE IF EXISTS "${temporaryTable}";
|
|
|
+
|
|
|
+ CREATE TABLE "${temporaryTable}" AS SELECT
|
|
|
+ public.ST_Union ( b.geom ) AS geomRes
|
|
|
+ FROM
|
|
|
+ "${tableNameA}" a,
|
|
|
+ "${tableNameB}" b
|
|
|
+ WHERE
|
|
|
+ public.st_intersects ( a.geom, b.geom )
|
|
|
+ <if test="tableIdsA != null and tableIdsA.size() > 0">
|
|
|
+ AND a.id IN
|
|
|
+ <foreach collection="tableIdsA" item="tableId" open="(" close=")" separator=",">
|
|
|
+ #{tableId}
|
|
|
+ </foreach>
|
|
|
+ </if>
|
|
|
+ ;
|
|
|
+
|
|
|
+ CREATE TABLE "${newTableName}" AS
|
|
|
+ SELECT a.id,public.ST_Difference ( a.geom, b.geomRes ) AS geom
|
|
|
+ FROM
|
|
|
+ "${tableNameA}" a,
|
|
|
+ "${temporaryTable}" b
|
|
|
+ WHERE 1=1
|
|
|
+ <if test="tableIdsA != null and tableIdsA.size() > 0">
|
|
|
+ AND a.id IN
|
|
|
+ <foreach collection="tableIdsA" item="tableId" open="(" close=")" separator=",">
|
|
|
+ #{tableId}
|
|
|
+ </foreach>
|
|
|
+ </if>
|
|
|
+ ;
|
|
|
+
|
|
|
+ DROP TABLE IF EXISTS "${temporaryTable}";
|
|
|
+ </select>
|
|
|
+</mapper>
|