-
Notifications
You must be signed in to change notification settings - Fork 265
Closed
Description
I cannot find a method to compute intersection of two envelopes. The only way I know to do that is via OGCGeometry:
OGCGeometry.createFromEsriGeometry(a, null).intersection(OGCGeometry.createFromEsriGeometry(b, null))
However this method is very slow. It is about 300 times slower than envelope-specific computation: prestodb/presto#10327
@Nullable
public static Envelope intersection(Envelope envelope, Envelope otherEnvelope)
{
requireNonNull(envelope, "envelope is null");
requireNonNull(otherEnvelope, "otherEnvelope is null");
if (envelope.getXMax() < otherEnvelope.getXMin()
|| envelope.getXMin() > otherEnvelope.getXMax()
|| envelope.getYMax() < otherEnvelope.getYMin()
|| envelope.getYMin() > otherEnvelope.getYMax()) {
return null;
}
return new Envelope(
max(envelope.getXMin(), otherEnvelope.getXMin()),
max(envelope.getYMin(), otherEnvelope.getYMin()),
min(envelope.getXMax(), otherEnvelope.getXMax()),
min(envelope.getYMax(), otherEnvelope.getYMax()));
}
Would it be possible to add an efficient Envelope#intersection API?
Reactions are currently unavailable
Metadata
Metadata
Assignees
Type
Fields
Give feedbackNo fields configured for issues without a type.