st_numinteriorring.sql 858 B

1234567891011121314151617181920212223
  1. -- An ornithologist wishes to study a bird population on several
  2. -- south sea islands. She wants to identify which islands contain
  3. -- one or more lakes because the bird species she is interested in
  4. -- feeds only in freshwater lakes.
  5. -- The ID and name columns of the islands table identifies each island
  6. -- while the land ST_Polygon column stores the island's geometry.
  7. CREATE TABLE islands (id integer,
  8. name varchar(32),
  9. land ST_Polygon);
  10. INSERT INTO islands VALUES(
  11. 1,
  12. 'hawaii',
  13. ST_PolyFromText('polygon ((42000 18000,48000 18000,48000 13000,42000 13000,42000 18000))',1000)
  14. );
  15. -- Because interior rings represent the lakes, the ST_NumInteriorRing
  16. -- function will list only those islands that have at least one interior ring.
  17. SELECT name
  18. FROM islands
  19. WHERE ST_NumInteriorRing(land) > 0;