Skip to content

Commit ae352e6

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

File tree

4 files changed

+22
-0
lines changed

4 files changed

+22
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
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 st_transform(rast,3857) as bands from public.landcover where rast && st_transform( st_tileenvelope(z,x,y),32644)
9+
)
10+
SELECT into mvt ST_AsJPEG(st_tile(bands,512,512)) from rast;
11+
return mvt;
12+
END
13+
$$ 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 SYSTEM SET postgis.gdal_enabled_drivers TO 'GTiff PNG JPEG';
3+
-- ALTER SYSTEM postgis.enable_outdb_rasters = true;
4+
-- SELECT pg_reload_conf();

tests/fixtures/raster/raster.tif

713 KB
Binary file not shown.

0 commit comments

Comments
 (0)