]> granicus.if.org Git - postgis/commitdiff
#3074: Add postgres regress for ST_SubDivide, update documentation to not use example...
authorRegina Obe <lr@pcorp.us>
Mon, 1 Jun 2015 09:04:59 +0000 (09:04 +0000)
committerRegina Obe <lr@pcorp.us>
Mon, 1 Jun 2015 09:04:59 +0000 (09:04 +0000)
git-svn-id: http://svn.osgeo.org/postgis/trunk@13595 b70326c6-7e19-0410-871a-916f4a2858ee

doc/html/image_src/st_subdivide02.wkt
doc/reference_processing.xml
regress/Makefile.in
regress/subdivide.sql [new file with mode: 0644]
regress/subdivide_expected [new file with mode: 0644]

index d8649d86423818b97b7a8583accc86ab7aaee2cf..7b6ea08d3eaa9bdf2f1ced4b98dba2f1901cc0b5 100644 (file)
@@ -1,3 +1,4 @@
-Style1;LINESTRING(0 0,35.3553390593274 35.3553390593274,70.7106781186547 70.7106781186547,75.000000000001 75.000000000001)\r
-Style2;LINESTRING(75.000000000001 75.000000000001,100 100,135.355339059327 135.355339059327,150 150)\r
-\r
+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)\r
+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)\r
+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)\r
+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)\r
index f2dd5625a40e49796e3e9dddeba09edb3e91bf73..8392e854a59065f2b3cf240d8455d17631a0eeee 100644 (file)
@@ -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.
     </para>
 
                <para>Clipping performed by the GEOS module.</para>
@@ -3192,9 +3192,11 @@ FROM ( SELECT ST_SubDivide('POLYGON((132 10,119 23,85 35,68 29,66 28,49 42,32 56
                                                          <caption><para>Useful in conjunction with ST_Segmentize to create additional vertices that can then be used for splitting</para></caption>
                                                        </mediaobject>
                                                  </informalfigure>
-                               <programlisting>SELECT ST_AsText(ST_SubDivide(ST_Segmentize('LINESTRING(0 0, 100 100, 150 150)'::geometry,50),4));</programlisting>
-<screen>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)</screen>
+                               <programlisting>SELECT ST_AsText(ST_SubDivide(ST_Segmentize('LINESTRING(0 0, 100 100, 150 150)'::geometry,10),8));</programlisting>
+<screen>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)</screen>
                                                  </para></entry>
                                          </row>
                                </tbody></tgroup></informaltable>
index 3a561938d29c94960783562e4fb2b451d13eacbd..bc62dc4d55ee5bfe06081732e9a27f9b94b8ca04 100644 (file)
@@ -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 (file)
index 0000000..69b6a2d
--- /dev/null
@@ -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 (file)
index 0000000..6dc4df3
--- /dev/null
@@ -0,0 +1,3 @@
+1|t|4|12
+2|t|4|8
+3|t|8|12