-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #24 from tilezen/zerebubuth/add-admin-areas
Add admin areas
- Loading branch information
Showing
4 changed files
with
46 additions
and
7 deletions.
There are no files selected for viewing
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
SELECT | ||
gid AS __id__, | ||
ST_AsBinary(geom) AS __geometry__, | ||
jsonb_build_object( | ||
'source', 'openstreetmap.org', | ||
'kind', 'admin_area', | ||
'admin_level', 2, | ||
'iso_code', iso_code | ||
) AS __properties__ | ||
|
||
FROM ( | ||
SELECT | ||
gid, | ||
-- extract only polygons. we might get linestring and point fragments when | ||
-- the box and geometry touch but don't overlap. we don't want these, so | ||
-- want to throw them away. | ||
ST_CollectionExtract(ST_Intersection(the_geom, {{box}}), 3) AS geom, | ||
iso_code | ||
|
||
FROM admin_areas | ||
|
||
WHERE | ||
the_geom && {{box}} AND | ||
-- NOTE: this isn't a typo, it's the result of importing this from a shape | ||
-- file, where column names are only allowed to be 8 characters wide! | ||
admin_leve = '2' | ||
) maybe_empty_intersections | ||
|
||
WHERE | ||
NOT ST_IsEmpty(geom) |
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
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