Skip to content

Instantly share code, notes, and snippets.

@az09
Created April 23, 2018 14:06
Show Gist options
  • Save az09/925275a24eea4b095e630f7c0df7f01d to your computer and use it in GitHub Desktop.
Save az09/925275a24eea4b095e630f7c0df7f01d to your computer and use it in GitHub Desktop.
Bad query for area_label
explain(analyze,buffers,verbose)
SELECT ST_AsBinary("way") AS geom,"area","name","type"
FROM (
SELECT COALESCE(landuse, leisure, "natural", highway, amenity, tourism) AS "type", name, way_area AS area, ST_PointOnSurface(way) AS way
FROM planet_osm_polygon
WHERE name IS NOT NULL
AND way && ST_SetSRID('BOX3D(15573585.89094331 4224215.931154246,15617613.61923559 4268243.659446535)'::box3d, 3857)
AND ST_IsValid(way)
UNION ALL
SELECT 'building' AS "type", name, way_area AS area, ST_PointOnSurface(way) AS way
FROM planet_osm_polygon
WHERE name IS NOT NULL
AND building NOT IN ('', 'no', '0', 'false')
AND way && ST_SetSRID('BOX3D(15573585.89094331 4224215.931154246,15617613.61923559 4268243.659446535)'::box3d, 3857)
AND ST_IsValid(way)
ORDER BY area DESC
) AS data
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment