From: Regina Obe Date: Mon, 1 Jun 2015 09:04:59 +0000 (+0000) Subject: #3074: Add postgres regress for ST_SubDivide, update documentation to not use example... X-Git-Tag: 2.2.0rc1~420 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=7b5ef60910426fd6112dfd5225e0b781360ab80a;p=postgis #3074: Add postgres regress for ST_SubDivide, update documentation to not use example below 8 vertices and put note about no less than 8 is allowed git-svn-id: http://svn.osgeo.org/postgis/trunk@13595 b70326c6-7e19-0410-871a-916f4a2858ee --- diff --git a/doc/html/image_src/st_subdivide02.wkt b/doc/html/image_src/st_subdivide02.wkt index d8649d864..7b6ea08d3 100644 --- a/doc/html/image_src/st_subdivide02.wkt +++ b/doc/html/image_src/st_subdivide02.wkt @@ -1,3 +1,4 @@ -Style1;LINESTRING(0 0,35.3553390593274 35.3553390593274,70.7106781186547 70.7106781186547,75.000000000001 75.000000000001) -Style2;LINESTRING(75.000000000001 75.000000000001,100 100,135.355339059327 135.355339059327,150 150) - +Style1;LINESTRING(0 0,7.07106781186547 7.07106781186547,14.1421356237309 14.1421356237309,21.2132034355964 21.2132034355964,28.2842712474619 28.2842712474619,35.3553390593274 35.3553390593274,37.499999999998 37.499999999998) +Style2;LINESTRING(37.499999999998 37.499999999998,42.4264068711929 42.4264068711929,49.4974746830583 49.4974746830583,56.5685424949238 56.5685424949238,63.6396103067893 63.6396103067893,70.7106781186548 70.7106781186548,74.999999999998 74.999999999998) +Style3;LINESTRING(74.999999999998 74.999999999998,77.7817459305202 77.7817459305202,84.8528137423857 84.8528137423857,91.9238815542512 91.9238815542512,98.9949493661167 98.9949493661167,100 100,107.071067811865 107.071067811865,112.499999999998 112.499999999998) +Style4;LINESTRING(112.499999999998 112.499999999998,114.142135623731 114.142135623731,121.213203435596 121.213203435596,128.284271247462 128.284271247462,135.355339059327 135.355339059327,142.426406871193 142.426406871193,149.497474683058 149.497474683058,149.999999999998 149.999999999998) diff --git a/doc/reference_processing.xml b/doc/reference_processing.xml index f2dd5625a..8392e854a 100644 --- a/doc/reference_processing.xml +++ b/doc/reference_processing.xml @@ -3134,7 +3134,7 @@ the maximum allowed number of vertices. Useful for converting excessively large polygons and other objects into small portions that fit within the database page size. Uses the same envelope clipping as ST_ClipByBox2D does, recursively subdividing the input geometry until all portions have less than the -maximum vertex count. +maximum vertex count. Minimum vertice count allowed is 8 and if you try to specify lower than 8, it will throw an error. Clipping performed by the GEOS module. @@ -3192,9 +3192,11 @@ FROM ( SELECT ST_SubDivide('POLYGON((132 10,119 23,85 35,68 29,66 28,49 42,32 56 Useful in conjunction with ST_Segmentize to create additional vertices that can then be used for splitting - SELECT ST_AsText(ST_SubDivide(ST_Segmentize('LINESTRING(0 0, 100 100, 150 150)'::geometry,50),4)); -LINESTRING(0 0,35.3553390593274 35.3553390593274,70.7106781186547 70.7106781186547,75.000000000001 75.000000000001) -LINESTRING(75.000000000001 75.000000000001,100 100,135.355339059327 135.355339059327,150 150) + SELECT ST_AsText(ST_SubDivide(ST_Segmentize('LINESTRING(0 0, 100 100, 150 150)'::geometry,10),8)); +LINESTRING(0 0,7.07106781186547 7.07106781186547,14.1421356237309 14.1421356237309,21.2132034355964 21.2132034355964,28.2842712474619 28.2842712474619,35.3553390593274 35.3553390593274,37.499999999998 37.499999999998) +LINESTRING(37.499999999998 37.499999999998,42.4264068711929 42.4264068711929,49.4974746830583 49.4974746830583,56.5685424949238 56.5685424949238,63.6396103067893 63.6396103067893,70.7106781186548 70.7106781186548,74.999999999998 74.999999999998) +LINESTRING(74.999999999998 74.999999999998,77.7817459305202 77.7817459305202,84.8528137423857 84.8528137423857,91.9238815542512 91.9238815542512,98.9949493661167 98.9949493661167,100 100,107.071067811865 107.071067811865,112.499999999998 112.499999999998) +LINESTRING(112.499999999998 112.499999999998,114.142135623731 114.142135623731,121.213203435596 121.213203435596,128.284271247462 128.284271247462,135.355339059327 135.355339059327,142.426406871193 142.426406871193,149.497474683058 149.497474683058,149.999999999998 149.999999999998) diff --git a/regress/Makefile.in b/regress/Makefile.in index 3a561938d..bc62dc4d5 100644 --- a/regress/Makefile.in +++ b/regress/Makefile.in @@ -188,7 +188,8 @@ ifeq ($(shell expr $(POSTGIS_GEOS_VERSION) ">=" 35),1) # GEOS-3.5 adds: # ST_ClipByBox2d TESTS += \ - clipbybox2d + clipbybox2d \ + subdivide endif ifeq ($(HAVE_JSON),yes) diff --git a/regress/subdivide.sql b/regress/subdivide.sql new file mode 100644 index 000000000..69b6a2d55 --- /dev/null +++ b/regress/subdivide.sql @@ -0,0 +1,24 @@ +-- polygon +WITH g AS (SELECT 'POLYGON((132 10,119 23,85 35,68 29,66 28,49 42,32 56,22 64,32 110,40 119,36 150, +57 158,75 171,92 182,114 184,132 186,146 178,176 184,179 162,184 141,190 122, +190 100,185 79,186 56,186 52,178 34,168 18,147 13,132 10))'::geometry As geom) +, gs AS (SELECT ST_Area(geom) As full_area, ST_SubDivide(geom,10) As geom FROM g) +SELECT '1' As rn, full_area::numeric(10,3) = SUM(ST_Area(gs.geom))::numeric(10,3), COUNT(gs.geom) As num_pieces, MAX(ST_NPoints(gs.geom)) As max_vert +FROM gs +GROUP BY gs.full_area; + +-- linestring +WITH g AS (SELECT ST_Segmentize('LINESTRING(0 0, 100 100, 150 150)'::geometry,10) As geom) +, gs AS (SELECT ST_Length(geom) As m, ST_SubDivide(geom,8) As geom FROM g) +SELECT '2' As rn, m::numeric(10,3) = SUM(ST_Length(gs.geom))::numeric(10,3), COUNT(gs.geom) As num_pieces, MAX(ST_NPoints(gs.geom)) As max_vert +FROM gs +GROUP BY gs.m; + +--multipolygon +WITH g AS (SELECT 'POLYGON((132 10,119 23,85 35,68 29,66 28,49 42,32 56,22 64,32 110,40 119,36 150, +57 158,75 171,92 182,114 184,132 186,146 178,176 184,179 162,184 141,190 122, +190 100,185 79,186 56,186 52,178 34,168 18,147 13,132 10))'::geometry As geom) +, gs AS (SELECT ST_Area(ST_Union(g.geom, ST_Translate(g.geom,300,10) )) As full_area, ST_SubDivide(ST_Union(g.geom, ST_Translate(g.geom,300,10) ), 10) As geom FROM g) +SELECT '3' As rn, full_area::numeric(10,3) = SUM(ST_Area(gs.geom))::numeric(10,3), COUNT(gs.geom) As num_pieces, MAX(ST_NPoints(gs.geom)) As max_vert +FROM gs +GROUP BY gs.full_area; diff --git a/regress/subdivide_expected b/regress/subdivide_expected new file mode 100644 index 000000000..6dc4df337 --- /dev/null +++ b/regress/subdivide_expected @@ -0,0 +1,3 @@ +1|t|4|12 +2|t|4|8 +3|t|8|12