GeoDesk for C++
Fast and storage-efficient spatial database engine for OpenStreetMap features
Loading...
Searching...
No Matches
geodesk::Ways Class Reference

A collection containing only Way features. More...

#include <Features.h>

Inheritance diagram for geodesk::Ways:
geodesk::Features

Public Member Functions

State and Membership
 operator bool () const
 Returns true if this collection contains at least one Feature.
 
bool operator! () const
 Returns true if this collection is empty.
 
bool contains (const Feature &feature) const
 Checks if the specified Feature exists in this collection.
 
Filtering by type and tags
Features operator() (const char *query) const
 Only features that match the given query.
 
Nodes nodes () const
 Only nodes.
 
Nodes nodes (const char *query) const
 Only nodes that match the given query.
 
Ways ways () const
 Only ways.
 
Ways ways (const char *query) const
 Only ways that match the given query.
 
Relations relations () const
 Only relations.
 
Relations relations (const char *query) const
 Only relations that match the given query.
 
Spatial Filters
Features operator() (const Box &box) const
 Only features whose bounding box intersects the given bounding box.
 
Features operator() (Coordinate xy) const
 Only features whose bounding box contains the given Coordinate.
 
Features operator() (const Feature &feature) const
 Only features whose geometry intersects with the given Feature (short form of intersecting())
 
Features intersecting (const Feature &feature) const
 Only features whose geometry intersects with the given Feature.
 
Features within (const Feature &feature) const
 Only features that lie entirely inside the geometry of the given Feature.
 
Features containing (const Feature &feature) const
 Only features whose geometry contains the given Feature.
 
Features containing (Coordinate xy) const
 Only features whose geometry contains the given Coordinate.
 
Features containingLonLat (double lon, double lat) const
 Only features whose geometry contains the given location.
 
Features crossing (const Feature &feature) const
 Only features whose geometry crosses the given Feature.
 
Features maxMetersFrom (double distance, Coordinate xy) const
 Only features whose closest point lies within distance meters of xy.
 
Features maxMetersFrom (double distance, double lon, double lat) const
 Only features whose closest point lies within distance meters of the given location.
 
Retrieving Features
std::optional< Featurefirst () const
 Returns the first Feature in this collection, or std::nullopt if the collection is empty.
 
Feature one () const
 Returns the one and only Feature in this collection.
 
void addTo (std::vector< Feature > &features) const
 Appends the Feature objects in this collection to the given std::vector.
 
void addTo (std::vector< FeaturePtr > &features) const
 Appends the Feature objects in this collection to the given std::vector as FeaturePtr pointers.
 
Scalar Queries
uint64_t count () const
 Returns the total number of features in this collection.
 
double length () const
 Computes the total length (in meters) of the features in this collection.
 
double area () const
 Computes the total area (in square meters) of the features in this collection.
 
Topological Filters
Features nodesOf (const Feature &feature) const
 Only nodes that belong to the given Way.
 
Features membersOf (const Feature &feature) const
 Only features that belong to the given Relation.
 
Features parentsOf (const Feature &feature) const
 Only features that are parent relations of the given Feature (or parent ways of the given Node).
 
Features connectedTo (const Feature &feature) const
 Only features that share a common node with the given Feature.
 
Filtering with Predicate
template<typename Predicate >
Features filter (Predicate predicate) const
 Only features that match the given predicate.
 
Access to the Low-Level API
FeatureStorestore () const noexcept
 Returns a pointer to the FeatureStore which contains the features in this collection.
 

Detailed Description

A collection containing only Way features.

Member Function Documentation

◆ addTo() [1/2]

void geodesk::Features::addTo ( std::vector< Feature > & features) const
inherited

Appends the Feature objects in this collection to the given std::vector.

◆ addTo() [2/2]

void geodesk::Features::addTo ( std::vector< FeaturePtr > & features) const
inherited

Appends the Feature objects in this collection to the given std::vector as FeaturePtr pointers.

◆ area()

double geodesk::Features::area ( ) const
inherited

Computes the total area (in square meters) of the features in this collection.

Exceptions
QueryExceptionif one or more tiles that contain the geometry of a Relation are missing

◆ connectedTo()

Features geodesk::Features::connectedTo ( const Feature & feature) const
inherited

Only features that share a common node with the given Feature.

◆ containing() [1/2]

Features geodesk::Features::containing ( const Feature & feature) const
inherited

Only features whose geometry contains the given Feature.

Exceptions
QueryExceptionif one or more tiles that contain the geometry of a Relation are missing

◆ containing() [2/2]

Features geodesk::Features::containing ( Coordinate xy) const
inherited

Only features whose geometry contains the given Coordinate.

◆ containingLonLat()

Features geodesk::Features::containingLonLat ( double lon,
double lat ) const
inherited

Only features whose geometry contains the given location.

Parameters
londegrees longitude
latdegrees latitude

◆ contains()

bool geodesk::Features::contains ( const Feature & feature) const
inherited

Checks if the specified Feature exists in this collection.

◆ count()

uint64_t geodesk::Features::count ( ) const
inherited

Returns the total number of features in this collection.

◆ crossing()

Features geodesk::Features::crossing ( const Feature & feature) const
inherited

Only features whose geometry crosses the given Feature.

Exceptions
QueryExceptionif one or more tiles that contain the geometry of a Relation are missing

◆ filter()

template<typename Predicate >
Features geodesk::Features::filter ( Predicate predicate) const
inherited

Only features that match the given predicate.

Parameters
predicateA callable object (e.g., lambda, function pointer, or functor) that defines the filtering logic. The callable must accept a Feature and return a bool.

Important: The provided predicate must be thread-safe, as it may be invoked concurrently.

// Find all parks whose area is at least 1 kmĀ²
// (one million square meters)
Features parks = world("a[leisure=park]");
Features largeParks = parks.filter([](Feature park)
{ return park.area() > 1'000'000; });
A geographic feature.
Definition Feature.h:27
double area() const
Measures the area of this Feature.
A collection of geographic features.
Definition Features.h:112
Features filter(Predicate predicate) const
Only features that match the given predicate.

◆ first()

std::optional< Feature > geodesk::Features::first ( ) const
inherited

Returns the first Feature in this collection, or std::nullopt if the collection is empty.

Only Nodes of a Way and member Features of a Relation are ordered; for all other collections, first() returns an arbitrary Feature.

Returns
the first Feature, or std::nullopt

◆ intersecting()

Features geodesk::Features::intersecting ( const Feature & feature) const
inherited

Only features whose geometry intersects with the given Feature.

Exceptions
QueryExceptionif one or more tiles that contain the geometry of a Relation are missing

◆ length()

double geodesk::Features::length ( ) const
inherited

Computes the total length (in meters) of the features in this collection.

Exceptions
QueryExceptionif one or more tiles that contain the geometry of a Relation are missing

◆ maxMetersFrom() [1/2]

Features geodesk::Features::maxMetersFrom ( double distance,
Coordinate xy ) const
inherited

Only features whose closest point lies within distance meters of xy.

Parameters
distancethe maximum distance (in meters)
xythe center of the search radius

◆ maxMetersFrom() [2/2]

Features geodesk::Features::maxMetersFrom ( double distance,
double lon,
double lat ) const
inherited

Only features whose closest point lies within distance meters of the given location.

Parameters
distancethe maximum distance (in meters)
lonlongitude of the search radius center
latlatitude of the search radius center

◆ membersOf()

Features geodesk::Features::membersOf ( const Feature & feature) const
inherited

Only features that belong to the given Relation.

◆ nodes() [1/2]

Nodes geodesk::Features::nodes ( ) const
inherited

Only nodes.

◆ nodes() [2/2]

Nodes geodesk::Features::nodes ( const char * query) const
inherited

Only nodes that match the given query.

Parameters
querya query in GOQL format
Exceptions
QueryExceptionif the query is malformed.

◆ nodesOf()

Features geodesk::Features::nodesOf ( const Feature & feature) const
inherited

Only nodes that belong to the given Way.

◆ one()

Feature geodesk::Features::one ( ) const
inherited

Returns the one and only Feature in this collection.

Returns
the sole Feature
Exceptions
QueryExceptionif this collection is empty or contains more than one Feature

◆ operator bool()

geodesk::Features::operator bool ( ) const
inherited

Returns true if this collection contains at least one Feature.

◆ operator!()

bool geodesk::Features::operator! ( ) const
inherited

Returns true if this collection is empty.

◆ operator()() [1/4]

Features geodesk::Features::operator() ( const Box & box) const
inherited

Only features whose bounding box intersects the given bounding box.

Parameters
box

◆ operator()() [2/4]

Features geodesk::Features::operator() ( const char * query) const
inherited

Only features that match the given query.

Parameters
querya query in GOQL format
Exceptions
QueryExceptionif the query is malformed.

◆ operator()() [3/4]

Features geodesk::Features::operator() ( const Feature & feature) const
inherited

Only features whose geometry intersects with the given Feature (short form of intersecting())

◆ operator()() [4/4]

Features geodesk::Features::operator() ( Coordinate xy) const
inherited

Only features whose bounding box contains the given Coordinate.

Parameters
xy

◆ parentsOf()

Features geodesk::Features::parentsOf ( const Feature & feature) const
inherited

Only features that are parent relations of the given Feature (or parent ways of the given Node).

◆ relations() [1/2]

Relations geodesk::Features::relations ( ) const
inherited

Only relations.

◆ relations() [2/2]

Relations geodesk::Features::relations ( const char * query) const
inherited

Only relations that match the given query.

Parameters
querya query in GOQL format
Exceptions
QueryExceptionif the query is malformed.

◆ store()

FeatureStore * geodesk::Features::store ( ) const
noexceptinherited

Returns a pointer to the FeatureStore which contains the features in this collection.

◆ ways() [1/2]

Ways geodesk::Features::ways ( ) const
inherited

Only ways.

◆ ways() [2/2]

Ways geodesk::Features::ways ( const char * query) const
inherited

Only ways that match the given query.

Parameters
querya query in GOQL format
Exceptions
QueryExceptionif the query is malformed.

◆ within()

Features geodesk::Features::within ( const Feature & feature) const
inherited

Only features that lie entirely inside the geometry of the given Feature.

Exceptions
QueryExceptionif one or more tiles that contain the geometry of a Relation are missing

The documentation for this class was generated from the following file: