st_dimension.sql 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. -- The dimension_test table is created with the columns geotype and g1.
  2. -- The geotype column stores the name of the subclass stored in the g1
  3. -- geometry column.
  4. CREATE TABLE dimension_test (geotype varchar(20),
  5. g1 ST_Geometry);
  6. -- The INSERT statements insert a sample subclass into the dimension_test table.
  7. INSERT INTO dimension_test VALUES(
  8. 'Point',
  9. ST_PointFromText('point (10.02 20.01)',1000)
  10. );
  11. INSERT INTO dimension_test VALUES(
  12. 'Linestring',
  13. ST_LineFromText('linestring (10.02 20.01,10.32 23.98,11.92 25.64)',1000)
  14. );
  15. INSERT INTO dimension_test VALUES(
  16. 'Polygon',
  17. ST_PolyFromText('polygon ((10.02 20.01,11.92 35.64,25.02 34.15, 19.15 33.94,10.02 20.01))',1000)
  18. );
  19. INSERT INTO dimension_test VALUES(
  20. 'Multipoint',
  21. ST_MPointFromText('multipoint (10.02 20.01,10.32 23.98,11.92 25.64)',1000)
  22. );
  23. INSERT INTO dimension_test VALUES(
  24. 'Multilinestring',
  25. ST_MLineFromText('multilinestring ((10.02 20.01,10.32 23.98,11.92 25.64),(9.55 23.75,15.36 30.11))',1000)
  26. );
  27. INSERT INTO dimension_test VALUES(
  28. 'Multipolygon',
  29. ST_MPolyFromText('multipolygon (((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)
  30. );
  31. -- The select statement lists the subclass name stored in the
  32. -- geotype column with the dimension of that geotype.
  33. SELECT geotype, ST_Dimension(g1) Dimension
  34. FROM dimension_test;