st_convexhull.sql 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. -- The example creates the convexhull_test table that has two columns:
  2. -- geotype and g1. Geotype, a varchar(20), stores the name of the geometry
  3. -- subclass that is stored in g1, a geometry.
  4. CREATE TABLE convexhull_test (geotype varchar(20),
  5. g1 ST_Geometry);
  6. -- The INSERT statements insert several geometry subclasses
  7. -- into the convexhull_test table.
  8. INSERT INTO convexhull_test VALUES(
  9. 'Point',
  10. ST_PointFromText('point (10.02 20.01)',1000)
  11. );
  12. INSERT INTO convexhull_test VALUES(
  13. 'Linestring',
  14. ST_LineFromText('linestring (10.02 20.01,10.32 23.98,11.92 25.64)',1000)
  15. );
  16. INSERT INTO convexhull_test VALUES(
  17. 'Polygon',
  18. ST_PolyFromText('polygon ((10.02 20.01,11.92 35.64,25.02 34.15, 19.15 33.94,10.02 20.01))',1000)
  19. );
  20. INSERT INTO convexhull_test VALUES(
  21. 'MultiPoint',
  22. ST_MPointFromText('multipoint (10.02 20.01,10.32 23.98,11.92 25.64)',1000)
  23. );
  24. INSERT INTO convexhull_test VALUES(
  25. 'MultiLineString',
  26. ST_MLineFromText('multilinestring ((10.02 20.01,10.32 23.98,11.92 25.64),(9.55 23.75,15.36 30.11))',1000)
  27. );
  28. INSERT INTO convexhull_test VALUES(
  29. 'Multipolygon',
  30. 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)
  31. );
  32. -- The select statement lists the subclass name stored in the
  33. -- geotype column and the convex hull.
  34. SELECT geotype, ST_ConvexHull(g1) convexhull
  35. FROM convexhull_test;