st_issimple.sql 1.0 KB

1234567891011121314151617181920212223242526272829
  1. -- The table issimple_test is created with two columns.
  2. -- The pid column is a smallint containing the unique
  3. -- identifier for each row. The g1 ST_Geometry column
  4. -- stores the simple and nonsimple geometry samples.
  5. CREATE TABLE issimple_test (pid smallint,
  6. g1 ST_Geometry);
  7. -- The INSERT statements insert two records into the issimple_test
  8. -- table. The first is a simple linestring because it
  9. -- doesn't intersect its interior. The second is nonsimple
  10. -- because it does intersect its interior.
  11. INSERT INTO issimple_test VALUES(
  12. 1,
  13. ST_LineFromText('linestring (10 10, 20 20, 30 30)',1000)
  14. );
  15. INSERT INTO issimple_test VALUES(
  16. 2,
  17. ST_LineFromText('linestring (10 10,20 20,20 30,10 30,10 20,20 10)',1000)
  18. );
  19. -- The query returns the results of the ST_IsSimple function.
  20. -- The first record returns t (TRUE) because the linestring is simple, while
  21. -- the second record returns f (FALSE) because the linestring is not simple.
  22. SELECT pid, ST_IsSimple(g1) Is_it_simple
  23. FROM issimple_test;