se_perpendicularpoint.sql 984 B

123456789101112131415161718192021222324252627
  1. CREATE TABLE linestring_test (line ST_LineString);
  2. -- Create a U-shaped linestring:
  3. INSERT INTO linestring_test VALUES (
  4. ST_LineFromText('linestring z (0 10 1, 0 0 3, 10 0 5, 10 10 7)', 0)
  5. );
  6. -- Perpendicular point is coincident with the input point,
  7. -- on the base of the U:
  8. SELECT SE_PerpendicularPoint(line, ST_PointFromText('point(5 0)', 0))
  9. FROM linestring_test;
  10. -- Perpendicular points are located on all three segments of the U:
  11. SELECT SE_PerpendicularPoint(line, ST_PointFromText('point(5 5)', 0))
  12. FROM linestring_test;
  13. -- Perpendicular points are located at the endpoints of the U:
  14. SELECT SE_PerpendicularPoint(line, ST_PointFromText('point(5 10)', 0))
  15. FROM linestring_test;
  16. -- Perpendicular point is on the base of the U:
  17. SELECT SE_PerpendicularPoint(line, ST_PointFromText('point(5 15)', 0))
  18. FROM linestring_test;
  19. -- No perpendicular point can be constructed:
  20. SELECT SE_PerpendicularPoint(line, ST_PointFromText('point(15 15)', 0))
  21. FROM linestring_test;