Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import com.vividsolutions.jts.geom.*;
import com.vividsolutions.jts.geom.prep.PreparedGeometry;
import com.vividsolutions.jts.geom.prep.PreparedGeometryFactory;
import com.vividsolutions.jts.geom.prep.PreparedLineString;
import com.vividsolutions.jts.operation.union.UnaryUnionOp;
import com.vividsolutions.jts.operation.valid.IsValidOp;

Expand Down Expand Up @@ -234,8 +235,16 @@ public SpatialRelation relate(Rectangle rectangle) {
SpatialRelation bboxR = bbox.relate(rectangle);
if (bboxR == SpatialRelation.WITHIN || bboxR == SpatialRelation.DISJOINT)
return bboxR;
// FYI, the right answer could still be DISJOINT or WITHIN, but we don't know yet.
return relate(ctx.getGeometryFrom(rectangle));

// FYI, the right answer could still be DISJOINT, but cannot be WITHIN.

Geometry rectangleGeom = ctx.getGeometryFrom(rectangle);
if (!rectangle.isEmpty() && preparedGeometry instanceof PreparedLineString) {
// We know linestring cannot contain a rectangle so we just need to check for intersects.
return preparedGeometry.intersects(rectangleGeom) ? SpatialRelation.INTERSECTS : SpatialRelation.DISJOINT;
}

return relate(rectangleGeom);
}

public SpatialRelation relate(final Circle circle) {
Expand Down