CreateUtilsDBMapper.xml 1.1 KB

1234567891011121314151617181920212223242526272829
  1. <?xml version="1.0" encoding="UTF-8" ?>
  2. <!DOCTYPE mapper
  3. PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
  4. "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
  5. <mapper namespace="com.onemap.analyse.mapper.CreateUtilsDBMapper">
  6. <insert id="bufferTable">
  7. CREATE TABLE "${newTableName}" AS
  8. SELECT public.ST_Buffer(geom, #{radius}) AS buffered_geom
  9. FROM "${tableName}"
  10. WHERE geom IS NOT NULL
  11. </insert>
  12. <insert id="differenceTables">
  13. CREATE TABLE "${newTableName}" AS
  14. SELECT CASE
  15. WHEN b.geom IS NOT NULL THEN public.ST_Difference(a.geom, b.geom)
  16. ELSE a.geom END AS geom_result
  17. FROM "${tableNameB}" a
  18. LEFT JOIN "${tableNameA}" b ON public.ST_Intersects(a.geom, b.geom)
  19. WHERE
  20. b.geom IS NOT NULL
  21. <if test="tableIdsB != null and tableIdsB.size() > 0">
  22. AND a.id::VARCHAR IN
  23. <foreach collection="tableIdsB" item="tableId" open="(" close=")" separator=",">
  24. #{tableId}
  25. </foreach>
  26. </if>
  27. </insert>
  28. </mapper>