st_isclosed.sql 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. -- The closed_linestring table is created with a single linestring column.
  2. CREATE TABLE closed_linestring (ln1 ST_LineString);
  3. -- The INSERT statements insert two records into the closed_linestring table.
  4. -- The first record is not a closed linestring, while the second is.
  5. INSERT INTO closed_linestring VALUES(
  6. ST_LineFromText('linestring (10.02 20.01,10.32 23.98,11.92 25.64)', 1000)
  7. );
  8. INSERT INTO closed_linestring VALUES(
  9. ST_LineFromText('linestring (10.02 20.01,11.92 35.64,25.02 34.15,19.15 33.94,10.02 20.01)',1000)
  10. );
  11. -- The query returns the results of the ST_IsClosed function.
  12. -- The first row returns t (FALSE) because the linestring is not closed,
  13. -- while the second row returns t (TRUE) because the linestring is closed.
  14. SELECT ST_IsClosed(ln1) Is_it_closed
  15. FROM closed_linestring;
  16. -- The closed_mlinestring table is created with a single
  17. -- ST_MultiLineString column.
  18. CREATE TABLE closed_mlinestring (mln1 ST_MultiLineString);
  19. -- The INSERT statements insert a ST_MultiLineString record that is
  20. -- not closed and another that is.
  21. INSERT INTO closed_mlinestring VALUES(
  22. ST_MLineFromText('multilinestring ((10.02 20.01,10.32 23.98,11.92 25.64),(9.55 23.75,15.36 30.11))',1000)
  23. );
  24. INSERT INTO closed_mlinestring VALUES(
  25. ST_MLineFromText('multilinestring ((10.02 20.01,11.92 35.64,25.02 34.15,19.15 33.94,10.02 20.01),(51.71 21.73,73.36 27.04,71.52 32.87,52.43 31.90,51.71 21.73))',1000)
  26. );
  27. -- The query lists the results of the ST_IsClosed function.
  28. -- The first row returns f (FALSE) because the multilinestring is not closed.
  29. -- The second row returns t (TRUE) because the multilinestring stored in the
  30. -- mln1 column is closed. A multilinestring is closed if all of its
  31. -- linestring elements are closed.
  32. SELECT ST_IsClosed(mln1) Is_it_closed
  33. FROM closed_mlinestring;