Skip to content

Add raster zxy function doc #937

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions tests/fixtures/functions/function_zxy_raster.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
DROP FUNCTION IF EXISTS public.function_zxy_raster;

CREATE OR REPLACE FUNCTION public.function_zxy_raster(z integer, x integer, y integer) RETURNS bytea AS $$
DECLARE
mvt bytea;
BEGIN
with rast as (
SELECT
st_clip(
st_transform(st_union(rast),3857),
st_tileenvelope(z,x,y)
)
as bands
from public.landcover where ST_ConvexHull(rast) && st_transform( st_tileenvelope(z,x,y),4326)
)
SELECT into mvt ST_AsJPEG(st_tile(bands,256,256)) from rast;
return mvt;
END
$$ LANGUAGE plpgsql IMMUTABLE STRICT PARALLEL SAFE;
5 changes: 5 additions & 0 deletions tests/fixtures/initdb.sh
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,11 @@ for sql_file in "$FIXTURES_DIR"/tables/*.sql; do
psql -e -P pager=off -v ON_ERROR_STOP=1 -f "$sql_file"
done

echo "Importing raster tables from $FIXTURES_DIR/raster"
echo "################################################################################################"
psql -e -P pager=off -v ON_ERROR_STOP=1 -f "$FIXTURES_DIR"/raster/init_raster_support.sql
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

echo -e "\n\n\n"
echo "################################################################################################"
echo "Importing functions from $FIXTURES_DIR/functions"
Expand Down
4 changes: 4 additions & 0 deletions tests/fixtures/raster/init_raster_support.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
create extension postgis_raster;
alter DATABASE db SET postgis.enable_outdb_rasters = true;
alter DATABASE db set postgis.gdal_enabled_drivers To 'GTiff PNG JPEG';
SELECT pg_reload_conf();
Binary file added tests/fixtures/raster/raster.tif
Binary file not shown.