Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [jts-dev] Intersects

FWIW I implemented this in Spatial4j's "ShapeCollection".  It's got Intersect detection as well as Contains and Within predicates.
https://github.com/locationtech/spatial4j/blob/master/src/main/java/org/locationtech/spatial4j/shape/ShapeCollection.java
(with tests of course).
Spatial4j can be configured to use JTS but I substitute ShapeCollection for JTS's GeometryCollection because I need these predicates.

On Fri, Apr 15, 2016 at 3:57 PM Michaël Michaud <m.michael.michaud@xxxxxxxxx> wrote:
Hi Martin,

Currently, all relate operations fail when one geometry or the other is a GeometryCollection.

This restriction includes intersects predicate (with the notable exception of Rectangles which use a short-circuit
and can successfully return true or false with a GeometryCollection argument)

As intersects is probably the most used predicate and also a predicate for which it is quite easy
to define the semantic with geometryCollection argument, I think it could be possible to replace
the direct call to "relate" by :

for (int i = 0 ; i < this.getNumGeometries() ; i++) {
    for (int j = 0 ; other.getNumGeometries() ; j++) {
        if (this.getGeometryN(i).relate(other.getGeometryN(j)).isIntersects()) return true;
    }
}
return false;

What do you think ?

It may be more complex to handle also nested geometry collections

Michaël
_______________________________________________
jts-dev mailing list
jts-dev@xxxxxxxxxxxxxxxx
To change your delivery options, retrieve your password, or unsubscribe from this list, visit
https://www.locationtech.org/mailman/listinfo/jts-dev
--
Lucene/Solr Search Committer, Consultant, Developer, Author, Speaker

Back to the top