se_locatebetween.sql 1.2 KB

12345678910111213141516171819202122232425262728
  1. -- The locatebetween_test table is created with two columns:
  2. -- the gid integer column uniquely identifies each row,
  3. -- while the g1 ST_MultiLineString stores the sample geometry.
  4. CREATE TABLE locatebetween_test (gid integer, g1 ST_Geometry);
  5. -- The INSERT statements insert two rows into the locatebetween_test table.
  6. -- The first row is a ST_MultiLineString and the second is a ST_MultiPoint.
  7. INSERT INTO locatebetween_test VALUES(
  8. 1,
  9. ST_MLineFromText('multilinestring m ((10.29 19.23 5,23.82 20.29 6, 30.19 18.47 7,45.98 20.74 8),(23.82 20.29 6,30.98 23.98 7,42.92 25.98 8))',1000)
  10. );
  11. INSERT INTO locatebetween_test VALUES(
  12. 2,
  13. ST_MPointFromText('multipoint m (10.29 19.23 5,23.82 20.29 6,30.19 18.47 7,45.98 20.74 8,23.82 20.29 6,30.98 23.98 7,42.92 25.98 8)', 1000)
  14. );
  15. -- The SE_LocateBetween function below locates measures lying
  16. -- between measures 6.5 and 7.5, inclusively. The first row returns
  17. -- a ST_Multilinestring containing several LineStrings. The second
  18. -- row returns a ST_MultiPoint because the source data was ST_MultiPoint.
  19. -- When the source data has a dimension of 0 (point or multipoint)
  20. -- an exact match is required.
  21. SELECT gid, SE_LocateBetween(g1,6.5,7.5) Geometry
  22. FROM locatebetween_test;