On Thu, Jun 21, 2012 at 1:05 PM, Andrea Aime
<andrea.a...@geo-solutions.it>wrote:

> On Thu, Jun 21, 2012 at 8:17 PM, Martin Davis <mda...@opengeo.org> wrote:
>
>> The reason for the exception is that the JTS intersection operation only
>> works on valid geometries.  Unfortunately the output of the
>> gs:CollectGeometries process may not be valid in the case where it is
>> collecting a set of Polygons.  This is because polygons which are adjacent
>> to each other or which overlap do not form valid MultiPolygons.  Both of
>> these situations occur in your process (the input states are adjacent, and
>> the buffers will overlap).
>
>
> The current version of collectGeometries now does a union before returning
> polygon collections, I guess you haven't used it in a few months, the
> change has been made in March (http://jira.codehaus.org/browse/GEOT-4077)
>
> However this might explain why Cesare's case is not working, I believe he
> has a 2.1.3 installed.
>

Oh, right, I see that now.  It should probably use the newish JTS
Geometry.union() rather than buffer(0) - it's faster for large datasets.

>
>
>>
>> Actually the buffer operation should work with any kind of input, and
>> produce a valid polygonal output.  So the problem is due to collecting the
>> STATES polygons together and trying to use that in JTS:intersection.
>>
>> In fact, the JTS:intersection operation is not designed to work on
>> collections of geometries anyway.
>>
>
> The gs:CollectGeometries process made sure to build a type specific
> collection for that very reason, you will get back
> a GeometryCollection only if the collected geometries are etherogeneous:
>
> http://svn.osgeo.org/geotools/trunk/modules/library/main/src/main/java/org/geotools/geometry/jts/GeometryCollector.java
>
> Or do you mean that intersecting a Multipolygon against another
> Multipolygon is less robust than an intersection
> between simple polygons?
>

I mean that in order for the intersection to work, both arguments need to
be valid geometries.  In the case of the states collection, this requires
that they be unioned together.  The effect of this is to produce a single
polygon (the outline of the US).  Then the result of the intersection is
going to be a single polygon.  I took a guess that the desire result was
actually a collection of the intersections of the individual state polygons
against the buffer polygon (this is the most common reason for this kind of
processing, in my experience).

>
>
>>
>> --
Martin Davis
OpenGeo - http://opengeo.org
Expert service straight from the developers.
------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
Geoserver-users mailing list
Geoserver-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/geoserver-users

Reply via email to