Skip to content

Instantly share code, notes, and snippets.

@knutole
Created January 21, 2015 15:48
Show Gist options
  • Save knutole/5b7713849ccce50e31de to your computer and use it in GitHub Desktop.
Save knutole/5b7713849ccce50e31de to your computer and use it in GitHub Desktop.
inefficient query
SELECT row_to_json(fc) FROM ( SELECT ST_AsGeoJSON(ST_Transform(ST_Intersection(ST_MakeValid(lg.geometry), bbox.geom), 4326))::json As geometry, ( SELECT row_to_json(t) FROM ( SELECT "name","type","area") t ) As properties FROM osm_waterareas As lg, (SELECT ST_Transform(ST_MakeEnvelope(-7.031250000000009,36.59788913307019,-5.625000000000013,37.718590325588146, 4326),3857) as geom) as bbox WHERE ST_Intersects(ST_MakeValid(lg.geometry), bbox.geom) AND (area > 12500000) ) fc;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment