-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
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>
<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>
# GEOS-3.5 adds:
# ST_ClipByBox2d
TESTS += \
- clipbybox2d
+ clipbybox2d \
+ subdivide
endif
ifeq ($(HAVE_JSON),yes)
--- /dev/null
+-- 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;
--- /dev/null
+1|t|4|12
+2|t|4|8
+3|t|8|12