Skip to content

Instantly share code, notes, and snippets.

@knutole
Created January 12, 2015 16:08
Show Gist options
  • Save knutole/ad663a8f12ca83b78e5d to your computer and use it in GitHub Desktop.
Save knutole/ad663a8f12ca83b78e5d to your computer and use it in GitHub Desktop.
SELECT row_to_json(fc)
FROM (
SELECT ST_AsGeoJSON(ST_Intersection(lg.geometry, bbox.geom))::json As geometry,
(
SELECT row_to_json(t)
FROM (
SELECT name, type, admin_level
) t
)
As properties
FROM
osm_admin As lg,
(SELECT ST_SetSRID(ST_MakeBox2d(ST_MakePoint(1193640.6337013133, 8384836.254770694),
ST_MakePoint(1203424.5733218156, 8375052.315150192)), 3857) as geom) as bbox
WHERE ST_Intersects(lg.geometry, bbox.geom)
) fc;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment