question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Optimize intersection computation for envelopes

See original GitHub issue

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: https://github.com/prestodb/presto/pull/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?

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:7 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
stolstovcommented, Apr 5, 2018

Yes, that’s a bug.

1reaction
stolstovcommented, Apr 5, 2018

@mbasmanova These methods change e1 polygon as in e1.intersect(e2). The result polygon will be empty if they dont intersect and as well the method returns boolean as extra bonus.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Simplification Envelopes - JHU CS
Abstract. We propose the idea of simplification envelopes for gen- erating a hierarchy of level-of-detail approximations for a given polygonal model.
Read more >
Simplification Envelopes
Abstract. We propose the idea of simplification envelopes for gen- erating a hierarchy of level-of-detail approximations for a given polygonal model.
Read more >
Fast envelope algorithms
1D envelope algorithm framework of Cook and Zhang (2016), we develop an envelope ... a non-convex optimization problem over a u-dimensional Grassmannian.
Read more >
Envelope Algorithm Optimization -- Best Place to Put a Circle
Here is a tutorial about the envelope theorem in optimization. ... pointing to the origin, and a circle intersection between the points.
Read more >
On the computation of convex envelopes for bivariate ...
The procedure is based on the solution of a KKT system and simplifies the derivation of the convex envelope with respect to previously...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found