|
@@ -35,39 +35,66 @@
|
|
|
|
|
|
<select id="getDemVolume" resultType="Double">
|
|
|
SELECT (stats.count * (pixel_info.pixel_size * pixel_info.pixel_size) * (stats.mean - #{minHeight})) AS volume
|
|
|
- FROM (SELECT (ST_SummaryStats(
|
|
|
- ST_MapAlgebra(
|
|
|
- ST_Clip(rast, 1, ST_GeomFromText(#{geomWkt}, 4326)),
|
|
|
- 1,
|
|
|
+ FROM (SELECT (public.ST_SummaryStats(
|
|
|
+ public.ST_MapAlgebra(
|
|
|
+ public.ST_Clip(rast, 1, public.ST_GeomFromText(#{geomWkt}, 4326)),1,
|
|
|
'CASE WHEN [rast] >= #{minHeight} AND [rast] <= #{maxHeight} THEN [rast] ELSE NULL END',
|
|
|
'32BF')
|
|
|
)).*) AS stats,
|
|
|
- (SELECT ST_PixelWidth(ST_Clip(rast, 1, ST_GeomFromText(#{geomWkt}, 4326))) as pixel_size
|
|
|
+ (SELECT public.ST_PixelWidth(public.ST_Clip(rast, 1, public.ST_GeomFromText(#{geomWkt}, 4326))) as pixel_size
|
|
|
FROM ${tableName}
|
|
|
- WHERE ST_Intersects(rast, ST_GeomFromText(#{geomWkt}, 4326)) LIMIT 1) AS pixel_info;
|
|
|
+ WHERE public.ST_Intersects(rast, public.ST_GeomFromText(#{geomWkt}, 4326)) LIMIT 1) AS pixel_info;
|
|
|
</select>
|
|
|
- <select id="getFillVolume" resultType="Double">
|
|
|
- SELECT SUM((#{height} - stats.mean) * stats.count *
|
|
|
- (pixel_info.pixel_size * pixel_info.pixel_size)) AS fill_volume
|
|
|
- FROM (SELECT (ST_SummaryStats(
|
|
|
- ST_MapAlgebra(
|
|
|
- ST_Clip(rast, 1, ST_GeomFromText(#{geomWkt}, 4326)),
|
|
|
- 1,
|
|
|
- 'CASE WHEN [rast] < #{height} THEN [rast] ELSE NULL END',
|
|
|
- '32BF'
|
|
|
- )
|
|
|
- )).*) AS stats,
|
|
|
- (SELECT ST_PixelWidth(ST_Clip(rast, 1, ST_GeomFromText(#{geomWkt}, 4326))) as pixel_size
|
|
|
- FROM ${tableName}
|
|
|
- WHERE ST_Intersects(rast, ST_GeomFromText(#{geomWkt}, 4326)) LIMIT 1) AS pixel_info;
|
|
|
+
|
|
|
+ <select id="getFillVolume" parameterType="map" resultType="Double">
|
|
|
+ WITH geom AS (
|
|
|
+ SELECT PUBLIC.st_transform(PUBLIC.ST_GeomFromText('${geomWkt}', 4326), 3857) AS geom
|
|
|
+ ),
|
|
|
+ pixel AS (
|
|
|
+ SELECT (PUBLIC.ST_MetaData(rast)).scalex AS pixel_width FROM ${tableName} LIMIT 1
|
|
|
+ ),
|
|
|
+ clipped_raster AS (
|
|
|
+ SELECT PUBLIC.ST_Clip(rast, 1, geom.geom, FALSE) AS rast FROM ${tableName}, geom
|
|
|
+ WHERE PUBLIC.ST_Intersects(rast, geom.geom)
|
|
|
+ ),
|
|
|
+ stats AS (
|
|
|
+ SELECT (PUBLIC.ST_SummaryStats(PUBLIC.ST_MapAlgebraExpr(
|
|
|
+ rast, 1, '32BF',
|
|
|
+ 'CASE WHEN [rast] < ${height} THEN [rast] ELSE NULL END'
|
|
|
+ ), 1)).*
|
|
|
+ FROM clipped_raster
|
|
|
+ )
|
|
|
+ SELECT SUM((#{height} - stats.mean) * stats.count * (pixel.pixel_width * pixel.pixel_width)) AS fill_volume
|
|
|
+ FROM stats, pixel;
|
|
|
</select>
|
|
|
|
|
|
+<!-- <select id="getFillVolume" parameterType="map" resultType="Double">-->
|
|
|
+<!-- WITH geom AS (-->
|
|
|
+<!-- SELECT PUBLIC.st_transform(PUBLIC.ST_GeomFromText('${geomWkt}', 4326), 3857) AS geom-->
|
|
|
+<!-- ),-->
|
|
|
+<!-- pixel AS (-->
|
|
|
+<!-- SELECT (PUBLIC.ST_MetaData(rast)).scalex AS pixel_width FROM ${tableName} LIMIT 1-->
|
|
|
+<!-- ),-->
|
|
|
+<!-- clipped_raster AS (-->
|
|
|
+<!-- SELECT PUBLIC.ST_Clip(rast, 1, geom.geom, FALSE) AS rast FROM ${tableName}, geom-->
|
|
|
+<!-- WHERE PUBLIC.ST_Intersects(rast, geom.geom)-->
|
|
|
+<!-- ),-->
|
|
|
+<!-- stats AS (-->
|
|
|
+<!-- SELECT (PUBLIC.ST_SummaryStats(PUBLIC.ST_MapAlgebra(-->
|
|
|
+<!-- rast, 1, '32BF',-->
|
|
|
+<!-- 'CASE WHEN [rast] < ${height} THEN [rast] ELSE NULL END'-->
|
|
|
+<!-- ), 1)).*-->
|
|
|
+<!-- FROM clipped_raster-->
|
|
|
+<!-- )-->
|
|
|
+<!-- SELECT SUM((#{height} - stats.mean) * stats.count * (pixel.pixel_width * pixel.pixel_width)) AS fill_volume-->
|
|
|
+<!-- FROM stats, pixel;-->
|
|
|
+<!-- </select>-->
|
|
|
+
|
|
|
<select id="getDemRing" resultType="String">
|
|
|
- WITH contour AS (SELECT (ST_Dump(ST_Contour(rast, 1, interval => 1))).geom AS geom, (ST_Value(rast, ST_Centroid((ST_Dump(ST_Contour(rast, 1, interval => 1))).geom)):: int) AS elevation
|
|
|
+ WITH contour AS (SELECT (public.ST_Dump(public.ST_Contour(rast, 1, interval => 1))).geom AS geom, (public.ST_Value(rast, public.ST_Centroid((public.ST_Dump(public.ST_Contour(rast, 1, interval => 1))).geom)):: int) AS elevation
|
|
|
FROM ${tableName}
|
|
|
- WHERE ST_Intersects(rast, ST_GeomFromText(#{geomWkt}, 4326))
|
|
|
- )
|
|
|
- SELECT ST_Intersection(geom, ST_GeomFromText(#{geomWkt}, 4326)) AS geom
|
|
|
+ WHERE public.ST_Intersects(rast, public.ST_GeomFromText(#{geomWkt}, 4326)))
|
|
|
+ SELECT public.ST_Intersection(geom, public.ST_GeomFromText(#{geomWkt}, 4326)) AS geom
|
|
|
FROM contour
|
|
|
WHERE elevation = #{height}
|
|
|
</select>
|