<div dir="ltr"><div style="font-size:12.8000001907349px"><div>Hey,<br></div>I executed your data,<br></div><div style="font-size:12.8000001907349px">the following command solve the problem (with very recent GEOS for me)<br>(POSTGIS="2.2.0dev r12846" GEOS="3.5.0dev-CAPI-1.9.0 r0" PROJ="Rel. 4.8.0, 6 March 2012" GDAL="GDAL 2.0.0dev, released 2014/04/16" LIBXML="2.8.0" RASTER)<br><br>:<br><br>DROP TABLE IF EXISTS unique_polygon ; <br>CREATE TABLE unique_polygon AS <br> SELECT geom_set_id, row_number() over() as gid, ST_Translate(dmp.geom, - 385614, - 4795454 ) AS geom<br> FROM error_generating_polygons,unnest(polygons) as geomn, st_dump(geomn) as dmp; <br>CREATE INDEX ON unique_polygon USING GIST(geom) ;<br><br>DRoP TABLE IF EXISTS unioned_poly ; <br>CREATE TABLE unioned_poly AS <br>SELECT ST_Union( ST_MakePolygon(ST_ExteriorRing(geom)) )<br>FROM unique_polygon<br>GROUP BY geom_set_id<br></div><div style="font-size:12.8000001907349px">(150 sec)<br><br></div><div style="font-size:12.8000001907349px"><br></div><div style="font-size:12.8000001907349px">The change compared to your approach : convert input to table of simple polygons, (no array, no multi).<br></div><div style="font-size:12.8000001907349px">Then translate to improve precision in geos computing<br><br></div><div style="font-size:12.8000001907349px">Then the union.<br></div><div style="font-size:12.8000001907349px">I don't really understand what you are trying to do,<br></div><div style="font-size:12.8000001907349px">but ist_union seems dangerous and quit ineffective for that .<br><br></div><div style="font-size:12.8000001907349px">Of course reducing the number of useless points before union make it 10 times faster .<br><br>DRoP TABLE IF EXISTS unioned_poly ; <br>CREATE TABLE unioned_poly AS <br>SELECT ST_Union( <br> ST_Buffer(<br> ST_MakePolygon(<br> ST_ExteriorRing(<br> ST_SImplifyPreserveTopology(<br> geom<br> ,10<br> )<br> )<br> )<br> ,1 ) <br> )<br>FROM unique_polygon<br>GROUP BY geom_set_id<br></div><div style="font-size:12.8000001907349px">(17 sec)<br></div><br style="font-size:12.8000001907349px"><span style="font-size:12.8000001907349px">Cheers,</span><br style="font-size:12.8000001907349px"><span style="font-size:12.8000001907349px">Rémi-C</span><br></div><div class="gmail_extra"><br><div class="gmail_quote">2015-02-09 13:00 GMT+01:00 Rémi Cura <span dir="ltr"><<a href="mailto:remi.cura@gmail.com" target="_blank">remi.cura@gmail.com</a>></span>:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Hey Sandro,<div>this is a precision related issue,</div><div>coordinates are way too big and should be translated.<br></div><div>Cheers,</div><div>Rémi-C</div></div><div class="HOEnZb"><div class="h5"><div class="gmail_extra"><br><div class="gmail_quote">2015-02-09 12:25 GMT+01:00 Sandro Santilli <span dir="ltr"><<a href="mailto:strk@keybit.net" target="_blank">strk@keybit.net</a>></span>:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">On Tue, Feb 03, 2015 at 11:28:35AM -0500, BladeOfLight16 wrote:<br>
<br>
> <a href="https://drive.google.com/file/d/0B_6I7kRgE8teVUpha2Q4ZlNDMWs/view?usp=sharing" target="_blank">https://drive.google.com/file/d/0B_6I7kRgE8teVUpha2Q4ZlNDMWs/view?usp=sharing</a>.<br>
<br>
...<br>
<span><br>
> DO $$<br>
> DECLARE problem_row error_generating_polygons%ROWTYPE;<br>
> BEGIN<br>
> FOR problem_row IN (SELECT * FROM error_generating_polygons) LOOP<br>
> BEGIN<br>
> PERFORM ST_Union(ST_Boundary(geom))<br>
> FROM UNNEST(problem_row.polygons) p (geom);<br>
> RAISE NOTICE 'geom_set_id % succeeded', problem_row.geom_set_id;<br>
> EXCEPTION<br>
> WHEN OTHERS THEN<br>
> RAISE NOTICE 'Error for geom_set_id % (Code %): %',<br>
> problem_row.geom_set_id, SQLSTATE, SQLERRM;<br>
> END;<br>
> END LOOP;<br>
> END<br>
> $$;<br>
<br>
</span>First of all I confirm it still happens with GEOS="3.5.0dev-CAPI-1.9.0 r4038".<br>
Second, I took a look at a random set (geom_set_id=1) and I found it pretty<br>
big. That's to say you could probably further reduce the dataset for the<br>
ticket. That set contains 109 polygons, I can get the error by attempting<br>
to union the boundaries of the first 40 in that set, and I'm sure you can<br>
further reduce the input.<br>
<br>
So my suggestion:<br>
<br>
1) file the ticket<br>
2) attach the _smallest_ input that reproduces the problem<br>
<br>
About ST_IsValid: lines are always valid, so there's no need to test.<br>
Most likely this is a robustness issue failing to deal with very close<br>
but not equal lines.<br>
<br>
NOTE: I've tried my reduced input (~40) geoms against the topology builder<br>
and it also resulted in errors, until I specified a tolerance of 1e-4.<br>
<br>
--strk;<br>
<br>
() Free GIS & Flash consultant/developer<br>
/\ <a href="http://strk.keybit.net/services.html" target="_blank">http://strk.keybit.net/services.html</a><br>
<div><div>_______________________________________________<br>
postgis-users mailing list<br>
<a href="mailto:postgis-users@lists.osgeo.org" target="_blank">postgis-users@lists.osgeo.org</a><br>
<a href="http://lists.osgeo.org/cgi-bin/mailman/listinfo/postgis-users" target="_blank">http://lists.osgeo.org/cgi-bin/mailman/listinfo/postgis-users</a><br>
</div></div></blockquote></div><br></div>
</div></div></blockquote></div><br></div>