mirror of
https://github.com/maplibre/martin.git
synced 2024-12-23 23:11:40 +03:00
2ee517d135
Can now handle several additional Postgres functions to get a tile, plus tons of small fixes ### Multiple result variants * `getmvt(z,x,y) -> [bytea,md5]` (single row with two columns) * `getmvt(z,x,y) -> [bytea]` (single row with a single column) * `getmvt(z,x,y) -> bytea` (value) ### Multiple input parameter variants * `getmvt(z, x, y)` or `getmvt(zoom, x, y)` (all 3 vars must be integers) * `getmvt(z, x, y, url_query)`, where instead of `url_query` it could be any other name, but must be of type JSON ### Breaking * srid is now the same type as PG -- `i32` * renamed config vals `table_sources` and `function_sources` into `tables` and `functions` ### Features and fixes * if postgis is v3.1+, uses margin parameter to extend the search box by the size of the buffer. I think we should make 3.1 minimal required. * fixes feature ID issue from #466 * fixes mixed case names for schemas, tables and columns, functions and parameter names per #389 ### Notes * More dynamic SQL generation in code instead of using external SQL files. Those should only be used when they are not parametrized. * The new function/table discovery mechanism: query for all functions in the database, and match up those functions with the ones configured (if any), plus adds all the rest of the un-declared ones if discovery mode is on. * During table and function discovery, the code generates a map of `(PgSqlInfo, FunctionInfo)` (or table) tupples containing SQL needed to get the tile. * Auto-discovery mode is currently hidden - the discovery is on only when no tables or functions are configured. TBD - how to configure it in the future * The new system allows for an easy way to auto-discover for the specific schemas only, solving #47 * predictable order of table/function instantiation * bounding boxes computed in parallel for all tables (when not configured) * proper identifier escaping * test cleanup fixes #378 fixes #466 fixes #65 fixes #389
17 lines
592 B
PL/PgSQL
17 lines
592 B
PL/PgSQL
DROP FUNCTION IF EXISTS public.function_zoom_xy;
|
|
|
|
CREATE OR REPLACE FUNCTION public.function_zoom_xy(zoom integer, x integer, y integer) RETURNS bytea AS $$
|
|
DECLARE
|
|
mvt bytea;
|
|
BEGIN
|
|
SELECT INTO mvt ST_AsMVT(tile, 'public.function_zoom_xy', 4096, 'geom') FROM (
|
|
SELECT
|
|
ST_AsMVTGeom(ST_Transform(ST_CurveToLine(geom), 3857), ST_TileEnvelope(zoom, x, y), 4096, 64, true) AS geom
|
|
FROM public.table_source
|
|
WHERE geom && ST_Transform(ST_TileEnvelope(zoom, x, y), 4326)
|
|
) as tile WHERE geom IS NOT NULL;
|
|
|
|
RETURN mvt;
|
|
END
|
|
$$ LANGUAGE plpgsql IMMUTABLE STRICT PARALLEL SAFE;
|