st_relate.sql 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. -- A DE-9IM pattern matrix is a device for comparing geometries.
  2. -- These are serveral types of such matrices. There are several
  3. -- types of such matrices. For example, the equals pattern matrix
  4. -- will tell you if any two geometries are equal.
  5. -- In this example, an equals pattern matrix, shown below is read left
  6. -- to right, and top to bottom into the string ("T*F**FFF*").
  7. --
  8. -- b
  9. --
  10. -- Interior Boundary Exterior
  11. -- Interior T * F
  12. -- a Boundary * * F
  13. -- Exterior F F *
  14. --
  15. -- The table relate_test is created with the following CREATE TABLE statement.
  16. CREATE TABLE relate_test (g1 ST_Geometry,
  17. g2 ST_Geometry,
  18. g3 ST_Geometry);
  19. -- The following INSERT statements insert a sample subclass into the
  20. -- relate_test table.
  21. INSERT INTO relate_test VALUES(
  22. ST_PointFromText('point (10.02 20.01)',1000),
  23. ST_PointFromText('point (10.02 20.01)',1000),
  24. ST_PointFromText('point (30.01 20.01)',1000)
  25. );
  26. -- The following SELECT statement and the corresponding result
  27. -- set demonstrates that the geometries which are equal match the
  28. -- equals pattern matrix, and those which are not equal do not match.
  29. SELECT ST_Relate(g1,g2,"T*F**FFF*") equals,
  30. ST_Relate(g1,g3,"T*F**FFF*") not_equals
  31. FROM relate_test;