Skip to content

Commit 5774b36

Browse files
committed
Add raster zxy function doc and test
1 parent 3c24ae2 commit 5774b36

File tree

4 files changed

+28
-0
lines changed

4 files changed

+28
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
DROP FUNCTION IF EXISTS public.function_zxy_raster;
2+
3+
CREATE OR REPLACE FUNCTION public.function_zxy_raster(z integer, x integer, y integer) RETURNS bytea AS $$
4+
DECLARE
5+
mvt bytea;
6+
BEGIN
7+
with rast as (
8+
SELECT
9+
st_clip(
10+
st_transform(st_union(rast),3857),
11+
st_tileenvelope(z,x,y)
12+
)
13+
as bands
14+
from public.landcover where ST_ConvexHull(rast) && st_transform( st_tileenvelope(z,x,y),4326)
15+
)
16+
SELECT into mvt ST_AsJPEG(st_tile(bands,256,256)) from rast;
17+
return mvt;
18+
END
19+
$$ LANGUAGE plpgsql IMMUTABLE STRICT PARALLEL SAFE;

tests/fixtures/initdb.sh

+5
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,11 @@ for sql_file in "$FIXTURES_DIR"/tables/*.sql; do
2626
psql -e -P pager=off -v ON_ERROR_STOP=1 -f "$sql_file"
2727
done
2828

29+
echo "Importing raster tables from $FIXTURES_DIR/raster"
30+
echo "################################################################################################"
31+
psql -e -P pager=off -v ON_ERROR_STOP=1 -f "$FIXTURES_DIR"/raster/init_raster_support.sql
32+
raster2pgsql -s 4326 -I -C -F -t 100x100 "$FIXTURES_DIR"/raster/raster.tif public.landcover | psql -e -P pager=off -v ON_ERROR_STOP=1
33+
2934
echo -e "\n\n\n"
3035
echo "################################################################################################"
3136
echo "Importing functions from $FIXTURES_DIR/functions"
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
create extension postgis_raster;
2+
alter DATABASE db SET postgis.enable_outdb_rasters = true;
3+
alter DATABASE db set postgis.gdal_enabled_drivers To 'GTiff PNG JPEG';
4+
SELECT pg_reload_conf();

tests/fixtures/raster/raster.tif

713 KB
Binary file not shown.

0 commit comments

Comments
 (0)