atlas::util::PolygonLocator class

Find polygon that contains a point.

Construction requires a list of polygons. The implementation makes use of a KDTree that holds centroids of all polygons. Once the nearest polygon-centroids (default=4) are found, the corresponding polygons are visited in order of shortest distance, to check if the point is contained within.

Constructors, destructors, conversion operators

PolygonLocator(const std::shared_ptr<const PolygonCoordinates::Vector> polygons, const Projection& projection = Projection())
Construct PolygonLocator from shared_ptr of polygons.
PolygonLocator(PolygonCoordinates::Vector&& polygons, const Projection& projection = Projection())
Construct PolygonLocator and move polygons inside.
PolygonLocator(const PolygonCoordinates::Vector& polygons, const Projection& projection = Projection())
Construct PolygonLocator using reference to polygons. !WARNING! polygons should not go out of scope before PolygonLocator.

Public functions

template<typename PointContainer, typename PolygonIndexContainer>
void operator()(const PointContainer& points, PolygonIndexContainer& index)
auto operator()(const Point2& point) const -> idx_t
find the polygon that holds the point (lon,lat)