## Re: [Geotools-gt2-users] (no subject)

 Re: [Geotools-gt2-users] (no subject) From: - 2010-05-20 14:46:06 ```I would try it in the following manner 1) Take your points and sort them primary by x value, secondary by y value, eliminate duplicates 2) Create a linestring from your points, step 1 should assure a valid geometry 3) intersect the linestring with the mulitpolygon, the result can be an empty geometry, a linestring or a multilinstring. 4) You need only one loop Cheers Quoting Jürgen Jacob : > Hi list, > I have a question that could be more related to a jts-user list but > hopefully someone can help me. > > I have two set of Geometry objects (a set of Points and a set of > Multipolygons) and I have to check which of them intersect to get > the mapping of Polygon->Points. > geometryObjectA.intersect(geometryObjectB) returns true or false and > the simplest but quite inefficient solution is: two nested loops > iterating over both sets and check each pair if it intersects. Since > a point could be intersected by more than polygon (if it lies on a > edge or even a vertex) no breaks could be used in the loops. Very > inefficient, or? > > I'm neither an expert in algorithm optimization nor in jts and > geotools libs therefore I'd like to know: > > Are there convenience functions in one of them that offer optimized > algorithms for interection/union/.. tasks of geometry sets? > > If not: What should I do instead of iterating two times over these > sets? The Multipolygons are quite complex (>1000 or even >10000 > vertices and consisting of several polygons). I was thinking of > first intersecting the Points with the envelope of the Multipolygons > and only if this matches checking the Multipolygon itself. > Other optimization ideas? > > Barking up the wrong tree? > > I was also thinking of storing the MultiPolygons in a (spatial) > database, create an index and le the database do the intersection > and hope that they have optimized it :-) > > Thanks for any help! > Jürgen > > -- > GRATIS für alle GMX-Mitglieder: Die maxdome Movie-FLAT! > Jetzt freischalten unter http://portal.gmx.net/de/go/maxdome01 > > ------------------------------------------------------------------------------ > > _______________________________________________ > Geotools-gt2-users mailing list > Geotools-gt2-users@... > https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users > ---------------------------------------------------------------- This message was sent using IMP, the Internet Messaging Program. ```