Skip to content

Instantly share code, notes, and snippets.

@MateoV
Last active August 29, 2015 14:00
Show Gist options
  • Save MateoV/11304986 to your computer and use it in GitHub Desktop.
Save MateoV/11304986 to your computer and use it in GitHub Desktop.
SELECT *,
CASE WHEN (select fid from water where st_contains(water.geom, sub.geom)) IS NOT NULL
THEN 1 ELSE 0 END AS maritime
FROM ((
SELECT (boundary_split.boundary).geom, $way_id*(boundary_split.boundary).path[1] as osm_id, $disputed as disputed
FROM
(SELECT
st_dump(st_split($way_geom, st_linemerge(geom))) AS boundary
FROM
(SELECT geom FROM coastline WHERE st_intersects(geom, $way_geom)) AS coast) AS boundary_split
) UNION ALL (
SELECT $way_geom as geomm, $way_id as osm_id, $disputed as disputed
FROM coastline
WHERE st_disjoint(coastline.geom, $way_geom) group by geomm
)) as sub
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment