Giter VIP home page Giter VIP logo

Comments (10)

springmeyer avatar springmeyer commented on August 19, 2024

Good questions. The pure "Point in Polygon" usecase (radius=0) is an important one and I think can be accommodated fairly cleanly using the same interface as "Nearby features" (radius>=0) searches.

My feeling is that:

  • Yes, if radius=0 it is safe to assume only one tile buffer will be passed and therefore we could throw if not (since that would be programmer error)
  • Also, if the bbox of the buffer's z/x/y does not intersect with the query point we could also throw - that would be programmer error again, right?

Then we'd want to keep on eye, during later performance profiling, that this validation is not showing up > 1% in the callgraph. I don't presume it would and I'm not worried about any meaningful perf penalty of this validation, but it would be good to confirm.

Other performance question to consider:

  • If radius=0 is there meaningful overhead in using closest_point? Could @artemp provide a faster PIP solution when radius=0? Would it be contains, within, covers? Or, do the usecases downstream always expect to know the closest point on a polygon boundary even when radius=0?

from vtquery.

mapsam avatar mapsam commented on August 19, 2024

Yes, if radius=0 it is safe to assume only one tile buffer will be passed and therefore we could throw if not (since that would be programmer error)

Already throwing if there are no buffers, so this case is covered.

Also, if the bbox of the buffer's z/x/y does not intersect with the query point we could also throw - that would be programmer error again, right?

Since we're working with a relative query point (something that can be positive or negative tile coordinates from the current tile buffer, we could add a check that says "if radius is 0 and the query point is > the tile's extent" throw since this will return zero results anyways.

if (radius == 0 && 
    (query_point.x > tile.extent() || 
     query_point.y > tile.extent() || 
     query_point.x < 0 || 
     query_point.y < 0)
) {
  // return callback error
}

from vtquery.

artemp avatar artemp commented on August 19, 2024

We're already have fast tracking return path for when point is within polygon:

https://github.com/mapbox/spatial-algorithms/blob/53d7861dc0ecca66ecbbae8fcef6b231ddbb2752/include/mapbox/geometry/algorithms/closest_point_impl.hpp#L36-L39

/cc @springmeyer @mapsam

from vtquery.

springmeyer avatar springmeyer commented on August 19, 2024

"if radius is 0 and the query point is > the tile's extent" throw since this will return zero results anyways.

👍 on this check. Although without this check throwing would it potentially return results in the case that the tiles have buffered data outside the extent?

from vtquery.

springmeyer avatar springmeyer commented on August 19, 2024

We're already have fast tracking return path for when point is within polygon:
https://github.com/mapbox/spatial-algorithms/blob/53d7861dc0ecca66ecbbae8fcef6b231ddbb2752/include/mapbox/geometry/algorithms/closest_point_impl.hpp#L36-L39

Brilliant, thanks for already thinking of that @artemp :)

from vtquery.

mapsam avatar mapsam commented on August 19, 2024

@springmeyer another question here:

"If radius is 0, should we only default to decoding polygons?"

Since we're only looking for PIP at this point, perhaps would speed things up?

from vtquery.

springmeyer avatar springmeyer commented on August 19, 2024

Good question @mapsam 🤔 . I noticed our current docs https://www.mapbox.com/api-documentation/#retrieve-features-from-vector-tiles say:

The radius parameter has no upper bound and is required for queries against point and line data.

So it sounds like radius=0 is understood to mean only polygons currently. Though technically I think in node-mapnik it could still return points and lines if you are exact. So, I think making radius=0 actually only try to query polygons would be ideal: both from a performance perspective and from a clear usability perspective (so you don't get surprised with points and lines in rare cases).

from vtquery.

mapsam avatar mapsam commented on August 19, 2024

I agree @springmeyer 👍 - plus the "direct" hit will never be fully accurate, considering a vector tile's coordinates are already simplified. Returning a point/polyline hit could be misleading in that way.

from vtquery.

springmeyer avatar springmeyer commented on August 19, 2024

Good point @mapsam - that the likelyhood of also returning a direct hit for lines/points increases to the extent that the precision is lost. So, yeah, that is another 👍 to only worrying about polygons and maybe in a far off future, supporting returning polygons with radius=0 that are "almost" hit (though we'd need to test that extensively to ensure it is actually needed).

from vtquery.

mapsam avatar mapsam commented on August 19, 2024

Radius=0 is only polygons, and we are only using a "within" operation and not an "along" operation. Closing!

from vtquery.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.