2018-08-25 16:43:31 +03:00
|
|
|
DROP FUNCTION IF EXISTS public.function_source;
|
|
|
|
CREATE OR REPLACE FUNCTION public.function_source(z integer, x integer, y integer, query_params json) RETURNS bytea AS $$
|
|
|
|
DECLARE
|
|
|
|
mvt bytea;
|
|
|
|
BEGIN
|
2019-10-26 20:37:49 +03:00
|
|
|
RAISE NOTICE 'query_params: %', query_params;
|
2018-10-12 18:18:34 +03:00
|
|
|
|
2018-08-25 16:43:31 +03:00
|
|
|
SELECT INTO mvt ST_AsMVT(tile, 'public.function_source', 4096, 'geom') FROM (
|
|
|
|
SELECT
|
2021-10-12 17:56:45 +03:00
|
|
|
ST_AsMVTGeom(ST_Transform(ST_CurveToLine(geom), 3857), TileBBox(z, x, y, 3857), 4096, 64, true) AS geom
|
2018-08-25 16:43:31 +03:00
|
|
|
FROM public.table_source
|
2019-10-26 20:37:49 +03:00
|
|
|
WHERE geom && TileBBox(z, x, y, 4326)
|
2018-08-25 16:43:31 +03:00
|
|
|
) as tile WHERE geom IS NOT NULL;
|
|
|
|
|
|
|
|
RETURN mvt;
|
|
|
|
END
|
|
|
|
$$ LANGUAGE plpgsql IMMUTABLE STRICT PARALLEL SAFE;
|