Created
January 12, 2015 16:58
-
-
Save knutole/c8f3f072e0cbd72482f0 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SELECT row_to_json(fc) | |
FROM ( | |
SELECT ST_AsGeoJSON(ST_Transform(ST_Intersection(lg.geometry, bbox.geom), 4326))::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(10.735445022583008, 59.913428634991995), | |
ST_MakePoint(10.776472091674805, 59.933989460416115)), 4326) as geom) as bbox | |
WHERE ST_Intersects(ST_Transform(lg.geometry, 4326), bbox.geom) | |
) fc; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
SELECT row_to_json(fc)
FROM (
SELECT ST_AsGeoJSON(ST_Transform(ST_Intersection(lg.geometry, bbox.geom), 4326))::json As geometry,
(
SELECT row_to_json(t)
FROM (
SELECT name, type, admin_level
) t
)
As properties
FROM
osm_admin As lg,
(SELECT ST_Transform(ST_MakeEnvelope(10.735445022583008, 59.913428634991995,
10.776472091674805, 59.933989460416115, 4326),3857) as geom) as bbox
WHERE ST_Intersects(lg.geometry, bbox.geom)
) fc;