Limiter les points par distance en fonction du zoom
This commit is contained in:
1 parent
9c68959083
commit
1f3db69791
1 file changed
+34
-22
+34
-22
@@ -468,31 +468,43 @@ class Pois
|
|||||||
$con = sql_connect();
|
$con = sql_connect();
|
||||||
pg_query($con, "SET jit=off");
|
pg_query($con, "SET jit=off");
|
||||||
|
|
||||||
|
$grid = pow(2, 9 - $z) * 2000;
|
||||||
|
|
||||||
$sql = "WITH tile AS ( SELECT
|
$sql = "WITH tile AS ( SELECT
|
||||||
ST_TileEnvelope($1, $2, $3) AS tile_geom
|
ST_TileEnvelope($1, $2, $3) AS tile_geom
|
||||||
),
|
),
|
||||||
|
|
||||||
mvtgeom AS ( SELECT CAST(contents.id AS integer) AS id,
|
mvtgeom AS (
|
||||||
contents.poi_type::text AS poi_type,
|
SELECT DISTINCT ON (
|
||||||
contents.permalink::text AS permalink,
|
FLOOR(ST_X(ST_Transform(specs.geom, 3857)) / $4),
|
||||||
ST_AsMVTGeom( ST_Transform(
|
FLOOR(ST_Y(ST_Transform(specs.geom, 3857)) / $4)
|
||||||
specs.geom,
|
)
|
||||||
3857
|
CAST(contents.id AS integer) AS id,
|
||||||
),
|
contents.poi_type::text AS poi_type,
|
||||||
tile.tile_geom, 4096, 64, true ) AS geom
|
contents.permalink::text AS permalink,
|
||||||
FROM content_version_poi_specifications specs
|
ST_AsMVTGeom(
|
||||||
INNER JOIN content_versions
|
ST_Transform(specs.geom, 3857),
|
||||||
ON specs.content_version_id = content_versions.id
|
tile.tile_geom,
|
||||||
INNER JOIN content_locales
|
4096,
|
||||||
ON content_versions.locale_id = content_locales.id
|
64,
|
||||||
INNER JOIN contents
|
true
|
||||||
ON content_locales.content_id = contents.id
|
) AS geom
|
||||||
CROSS JOIN tile
|
FROM content_version_poi_specifications specs
|
||||||
|
INNER JOIN content_versions
|
||||||
WHERE contents.type = 'poi'
|
ON specs.content_version_id = content_versions.id
|
||||||
AND specs.geom IS NOT NULL
|
INNER JOIN content_locales
|
||||||
AND ST_Transform(specs.geom, 3857) && tile.tile_geom
|
ON content_versions.locale_id = content_locales.id
|
||||||
)
|
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' )
|
SELECT ST_AsMVT( mvtgeom, 'pois', 4096, 'geom' )
|
||||||
FROM mvtgeom
|
FROM mvtgeom
|
||||||
WHERE geom IS NOT NULL";
|
WHERE geom IS NOT NULL";
|
||||||
@@ -500,7 +512,7 @@ class Pois
|
|||||||
$result = pg_query_params(
|
$result = pg_query_params(
|
||||||
$con,
|
$con,
|
||||||
$sql,
|
$sql,
|
||||||
[$z, $x, $y]
|
[$z, $x, $y, $grid]
|
||||||
);
|
);
|
||||||
|
|
||||||
if (!$result) {
|
if (!$result) {
|
||||||
|
|||||||
Reference in new issue
Block a user