st_numpoints.sql 834 B

123456789101112131415161718192021222324252627
  1. -- The numpoints_test table is created with the geotype column,
  2. -- which contains the ST_Geometry type stored in the g1 geometry column.
  3. CREATE TABLE numpoints_test (geotype varchar(12),
  4. g1 ST_Geometry);
  5. -- The INSERT statements insert a point, a linestring, and a polygon.
  6. INSERT INTO numpoints_test VALUES(
  7. 'point',
  8. ST_PointFromText('point (10.02 20.01)',1000)
  9. );
  10. INSERT INTO numpoints_test VALUES(
  11. 'linestring',
  12. ST_LineFromText('linestring (10.02 20.01, 23.73 21.92)',1000)
  13. );
  14. INSERT INTO numpoints_test VALUES(
  15. 'polygon',
  16. ST_PolyFromText('polygon ((10.02 20.01, 23.73 21.92, 24.51 12.98, 11.64 13.42, 10.02 20.01))',1000)
  17. );
  18. -- The query lists the geometry type and the number of points in each.
  19. SELECT geotype, ST_NumPoints(g1) Number_of_points
  20. FROM numpoints_test;