Limiter les points par distance en fonction du zoom

This commit is contained in:
leosw committed 2026-10-18 15:26:43 +02:00
1 parent 9c68959083
commit 1f3db69791
1 file changed
+20 -8
+20 -8
View File
@@ -468,18 +468,27 @@ class Pois
$con = sql_connect();
pg_query($con, "SET jit=off");
$grid = pow(2, 9 - $z) * 2000;
$sql = "WITH tile AS ( SELECT
ST_TileEnvelope($1, $2, $3) AS tile_geom
),
mvtgeom AS ( SELECT CAST(contents.id AS integer) AS id,
mvtgeom AS (
SELECT DISTINCT ON (
FLOOR(ST_X(ST_Transform(specs.geom, 3857)) / $4),
FLOOR(ST_Y(ST_Transform(specs.geom, 3857)) / $4)
)
CAST(contents.id AS integer) AS id,
contents.poi_type::text AS poi_type,
contents.permalink::text AS permalink,
ST_AsMVTGeom( ST_Transform(
specs.geom,
3857
),
tile.tile_geom, 4096, 64, true ) AS geom
ST_AsMVTGeom(
ST_Transform(specs.geom, 3857),
tile.tile_geom,
4096,
64,
true
) AS geom
FROM content_version_poi_specifications specs
INNER JOIN content_versions
ON specs.content_version_id = content_versions.id
@@ -488,10 +497,13 @@ class Pois
INNER JOIN contents
ON content_locales.content_id = contents.id
CROSS JOIN tile
WHERE contents.type = 'poi'
AND specs.geom IS NOT NULL
AND ST_Transform(specs.geom, 3857) && tile.tile_geom
ORDER BY
FLOOR(ST_X(ST_Transform(specs.geom, 3857)) / $4),
FLOOR(ST_Y(ST_Transform(specs.geom, 3857)) / $4),
contents.id
)
SELECT ST_AsMVT( mvtgeom, 'pois', 4096, 'geom' )
FROM mvtgeom
@@ -500,7 +512,7 @@ class Pois
$result = pg_query_params(
$con,
$sql,
[$z, $x, $y]
[$z, $x, $y, $grid]
);
if (!$result) {