st_envelope.sql 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. -- The envelope_test table's geotype column stores the name of the
  2. -- geometry subclass stored in the g1 ST_Geometry column.
  3. CREATE TABLE envelope_test (geotype varchar(20),
  4. g1 ST_Geometry);
  5. -- The INSERT statements insert each geometry subclass into the
  6. -- envelope_test table.
  7. INSERT INTO envelope_test VALUES(
  8. 'Point',
  9. ST_PointFromText('point (10.02 20.01)',1000)
  10. );
  11. INSERT INTO envelope_test VALUES(
  12. 'Linestring',
  13. ST_LineFromText('linestring (10.01 20.01, 10.01 30.01, 10.01 40.01)', 1000)
  14. );
  15. INSERT INTO envelope_test VALUES(
  16. 'Linestring',
  17. ST_LineFromText('linestring (10.02 20.01,10.32 23.98,11.92 25.64)', 1000)
  18. );
  19. INSERT INTO envelope_test VALUES(
  20. 'Polygon',
  21. ST_PolyFromText('polygon ((10.02 20.01,11.92 35.64,25.02 34.15,19.15 33.94, 10.02 20.01))',1000)
  22. );
  23. INSERT INTO envelope_test VALUES(
  24. 'Multipoint',
  25. ST_MPointFromText('multipoint (10.02 20.01,10.32 23.98,11.92 25.64)', 1000)
  26. );
  27. INSERT INTO envelope_test VALUES(
  28. 'Multilinestring',
  29. ST_MLineFromText('multilinestring ((10.01 20.01,20.01 20.01,30.01 20.01), (30.01 20.01,40.01 20.01,50.01 20.01))',1000)
  30. );
  31. INSERT INTO envelope_test VALUES(
  32. 'Multilinestring',
  33. ST_MLineFromText('multilinestring ((10.02 20.01,10.32 23.98,11.92 25.64),(9.55 23.75,15.36 30.11))',1000)
  34. );
  35. INSERT INTO envelope_test VALUES(
  36. 'Multipolygon',
  37. 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)
  38. );
  39. -- The query lists the subclass name and its envelope. Th
  40. -- ST_Envelope function returns a point, linestring, or polygon.
  41. SELECT geotype, ST_Envelope(g1) Envelope
  42. FROM envelope_test;