Ajouter Vector tiles
il suffit de parameter z,x,y et sysma_object_type_id
-
doc leaflet, il existe au moins 2 plugins compatibles leaflet 1.x
-
plugin 1) https://github.com/Leaflet/Leaflet.VectorGrid
- regarder VectorGrid.Protobuf ici https://leaflet.github.io/Leaflet.VectorGrid/vectorgrid-api-docs.html
-
plugin 2) https://gitlab.com/jkuebart/Leaflet.VectorTileLayer/
-
exemple cliquable (il faut zommer pour voir les parcelles ): https://lpvis.hub.eox.at/
-
autre exemple https://eox.at/2020/01/vector-tiles-with-dynamically-updated-style-in-leaflet-lpvis/#leaflet-vectorgrid-to-action
-
-
exemple sur fichiers tests sur pbf générés par qgis :
-
backend : doc root php : faire une root de type https://sysma.sevre-nantaise.com/sysma_object_tiles/{sysma_object_type_id}/{z}/{x}/{y} @srenou ok ?
- exemple de serveur de fichiers avec https://github.com/maptiler/tileserver-php
- gestion du cache :https://developer.mozilla.org/fr/docs/Web/HTTP/Headers/Cache-Control exemple osm :
- note pour la route, le sysma_object_tiles permettra de distinguer les object des travaux des ... pour le préfixe sysma et nous pourrons utiliser external_layer pour les 'other layers' exemple de sql pour le back
-
sql :
le inputs du controleur :
- {sysma_object_type_id}/{z}/{x}/{y}
-- retourne du bytea Protobuf
-- TODO AR : vérifier st_transform et SRID
WITH
zxy as (
SELECT {z}::int as z, {x} as x, {y} as y
)
, mvtgeom AS (
SELECT
ST_AsMVTGeom(
ST_transform (geom, 3857)
, ST_TileEnvelope(zxy.z, zxy.x, zxy.y)
, extent => 4096
, buffer => 64
, clip_geom => true
) AS geom
, sysma_object_id
, sysma_object
FROM sysma.sysma_object
, zxy
WHERE geom && ST_transform (ST_TileEnvelope(zxy.z, zxy.x, zxy.y, margin => (64.0 / 4096)),2154)
AND sysma_object_type_id= {sysma_object_type_id} -- ici le sysma_object_type_id
AND ST_intersects(geom , ST_transform (ST_TileEnvelope(zxy.z, zxy.x, zxy.y, margin => (64.0 / 4096)),2154))
)
SELECT ST_AsMVT(mvtgeom.*)
FROM mvtgeom
-- exemle sql pour tester la taille d'une taille
WITH
zxy as ( SELECT 12::int as z, 2033::int as x, 1439::int as y )
, mvtgeom AS ( SELECT ST_AsMVTGeom(
st_transform(geom, 3857)
, ST_TileEnvelope(zxy.z, zxy.x, zxy.y) , extent => 4096 , buffer => 64 , clip_geom => true
) AS geom
, sysma_object_id , sysma_object
FROM sysma.sysma_object , zxy
WHERE geom && ST_transform (ST_TileEnvelope(zxy.z, zxy.x, zxy.y, margin => (64.0 / 4096)),2154)
AND sysma_object_type_id= 102663
AND ST_intersects(geom , ST_transform (ST_TileEnvelope(zxy.z, zxy.x, zxy.y, margin => (64.0 / 4096)),2154))
)
, st as (SELECT --st_length(
ST_AsMVT(mvtgeom.*)
--)
FROM mvtgeom
)
select pg_size_pretty(length(ST_AsMVT)::bigint) as filesize
from st;
Modification effectuée par Antoine RIVIERE