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

A Feature that represents a grouping of related features or a complex polygon. More...

#include <Relation.h>

Inheritance diagram for geodesk::Relation:
geodesk::Feature

Public Member Functions

Type & Identity
FeatureType type () const noexcept
 FeatureType::RELATION
 
int64_t id () const noexcept
 The ID of this Relation.
 
bool isNode () const noexcept
 Always false
 
bool isAnonymousNode () const noexcept
 Always false
 
bool isWay () const noexcept
 Always false
 
bool isRelation () const noexcept
 Always true
 
bool isArea () const noexcept
 true if this Relation represents an area.
 
bool belongsToRelation () const noexcept
 true if this Relation itself belongs to at least one Relation.
 
StringValue role () const noexcept
 The Relation's role in its parent Relation, if it was returned via members() or Features::membersOf(), otherwise an empty string.
 
Display
const char * typeName () const noexcept
 "node", "way" or "relation"
 
char * format (char *buf) const noexcept
 Formats the string representation (e.g. "node/123456") of this Feature into the provided buffer.
 
std::string toString () const
 Creates a std::string with the Feature's type and ID.
 
std::string label () const
 Creates a short descriptive label.
 
Tags
TagValue operator[] (std::string_view key) const noexcept
 Obtains the tag value for the given key.
 
Tags tags () const noexcept
 A collection of the Feature's tags.
 
bool hasTag (std::string_view k) const noexcept
 Checks if this Feature has a tag with the given key.
 
bool hasTag (std::string_view k, std::string_view v) const noexcept
 Checks if this Feature has a tag with the given key and value.
 
Geometry
Box bounds () const noexcept
 The bounding box of this Feature.
 
Coordinate xy () const noexcept
 The Mercator-projected x/y coordinate of a Node, or the center point of the bounding box for a Way or Relation.
 
int32_t x () const noexcept
 The Mercator-projected x-coordinate of a Node, or the horizontal midpoint of the bounding box for a Way or Relation.
 
int32_t y () const noexcept
 The Mercator-projected y-coordinate of a Node, or the vertical midpoint of the bounding box for a Way or Relation.
 
double lon () const noexcept
 The longitude of this feature (in WGS-84 degrees).
 
double lat () const noexcept
 The latitude of this feature (in WGS-84 degrees).
 
Coordinate centroid () const
 Computes the centroid of this Feature.
 
double area () const
 Measures the area of this Feature.
 
double length () const
 Measures the length of this Feature.
 
GEOSGeometry * toGeometry (GEOSContextHandle_t geosContext) const
 Creates a GEOSGeometry based on this Feature's geometry.
 
Related Features
Nodes nodes () const
 The nodes of this Way.
 
Nodes nodes (const char *query) const
 The nodes of this Way that match the given query.
 
Features members () const
 The members of this Relation.
 
Features members (const char *query) const
 The members of this Relation that match the given query.
 
Features parents () const
 The parent relations of this Feature (and the parent ways for a Node).
 
Features parents (const char *query) const
 The parent relations of this Feature (and the parent ways for a Node) that match the given query.
 
Access to the Low-Level API
FeaturePtr ptr () const noexcept
 Pointer to the stored data of this Feature.
 
FeatureStorestore () const noexcept
 Pointer to the FeatureStore which contains this Feature.
 

Detailed Description

A Feature that represents a grouping of related features or a complex polygon.

Each Relation has one or more member features, which can be retrieved via members(). Each Feature object returned by members() has its role set to a non-empty string, if it has an explicit role in this Relation (e.g. "stop" for a Node in a route relation that represents a bus stop).

Note: Functions that require the complete geometry of a Relation (such as area() or centroid()) may fail with a QueryException if one or more tiles that contain members of the Relation are missing.

Member Function Documentation

◆ area()

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

Measures the area of this Feature.

Returns
area (in square meters), or 0 if the feature is not polygonal
Exceptions
QueryExceptionif one or more tiles that contain the geometry of a Relation are missing

◆ belongsToRelation()

bool geodesk::Relation::belongsToRelation ( ) const
noexcept

true if this Relation itself belongs to at least one Relation.

◆ bounds()

Box geodesk::Feature::bounds ( ) const
noexceptinherited

The bounding box of this Feature.

Returns
The Feature's bounding box (in Mercator projection)

◆ centroid()

Coordinate geodesk::Feature::centroid ( ) const
inherited

Computes the centroid of this Feature.

Returns
the Feature's centroid (in Mercator projection)
Exceptions
QueryExceptionif one or more tiles that contain the geometry of a Relation are missing

◆ format()

char * geodesk::Feature::format ( char * buf) const
noexceptinherited

Formats the string representation (e.g. "node/123456") of this Feature into the provided buffer.

Appends a null-terminator at the end of the output, and returns a pointer to the null-terminator, allowing easy concatenation.

Parameters
bufpointer to a char array of sufficient size
Returns
a pointer to the null-terminator of the string in buf

◆ hasTag() [1/2]

bool geodesk::Feature::hasTag ( std::string_view k) const
noexceptinherited

Checks if this Feature has a tag with the given key.

◆ hasTag() [2/2]

bool geodesk::Feature::hasTag ( std::string_view k,
std::string_view v ) const
noexceptinherited

Checks if this Feature has a tag with the given key and value.

◆ id()

int64_t geodesk::Relation::id ( ) const
noexcept

The ID of this Relation.

◆ isAnonymousNode()

bool geodesk::Relation::isAnonymousNode ( ) const
noexcept

Always false

◆ isArea()

bool geodesk::Relation::isArea ( ) const
noexcept

true if this Relation represents an area.

◆ isNode()

bool geodesk::Relation::isNode ( ) const
noexcept

Always false

◆ isRelation()

bool geodesk::Relation::isRelation ( ) const
noexcept

Always true

◆ isWay()

bool geodesk::Relation::isWay ( ) const
noexcept

Always false

◆ label()

std::string geodesk::Feature::label ( ) const
inherited

Creates a short descriptive label.

This is usually a combination of the type and name, such as hotel "Four Seasons".

◆ lat()

double geodesk::Feature::lat ( ) const
noexceptinherited

The latitude of this feature (in WGS-84 degrees).

For a Way or Relation, this is the vertical midpoint of its bounding box.

◆ length()

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

Measures the length of this Feature.

Returns
length (in meters), or 0 if the feature is not lineal
Exceptions
QueryExceptionif one or more tiles that contain the geometry of a Relation are missing

◆ lon()

double geodesk::Feature::lon ( ) const
noexceptinherited

The longitude of this feature (in WGS-84 degrees).

For a Way or Relation, this is the horizontal midpoint of its bounding box.

◆ members() [1/2]

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

The members of this Relation.

Returns
an ordered collection of Feature objects

◆ members() [2/2]

Features geodesk::Feature::members ( const char * query) const
inherited

The members of this Relation that match the given query.

Parameters
querya query in GOQL format
Returns
an ordered collection of Feature objects
Exceptions
QueryExceptionif the query is malformed.

◆ nodes() [1/2]

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

The nodes of this Way.

Returns
an ordered collection of Node objects

◆ nodes() [2/2]

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

The nodes of this Way that match the given query.

Parameters
querya query in GOQL format
Returns
an ordered collection of Node objects
Exceptions
QueryExceptionif the query is malformed.

◆ operator[]()

TagValue geodesk::Feature::operator[] ( std::string_view key) const
noexceptinherited

Obtains the tag value for the given key.

Returns
the tag's value (or an empty string if the feature doesn't have a tag with this key)

◆ parents() [1/2]

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

The parent relations of this Feature (and the parent ways for a Node).

Returns
a collection of Relation objects (Way and Relation for Node)

◆ parents() [2/2]

Features geodesk::Feature::parents ( const char * query) const
inherited

The parent relations of this Feature (and the parent ways for a Node) that match the given query.

Parameters
querya query in GOQL format
Returns
a collection of Relation objects (Way and Relation for Node)
Exceptions
QueryExceptionif the query is malformed.

◆ ptr()

FeaturePtr geodesk::Feature::ptr ( ) const
noexceptinherited

Pointer to the stored data of this Feature.

If this Feature is an anonymous node, the FeaturePtr will be a nullptr

◆ role()

StringValue geodesk::Relation::role ( ) const
noexcept

The Relation's role in its parent Relation, if it was returned via members() or Features::membersOf(), otherwise an empty string.

Returns
the Relation's role (or an empty string)

◆ store()

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

Pointer to the FeatureStore which contains this Feature.

◆ tags()

Tags geodesk::Feature::tags ( ) const
noexceptinherited

A collection of the Feature's tags.

◆ toGeometry()

GEOSGeometry * geodesk::Feature::toGeometry ( GEOSContextHandle_t geosContext) const
inherited

Creates a GEOSGeometry based on this Feature's geometry.

Coordinates will be in Mercator projection. The caller assumes ownership of the newly created GEOSGeometry and is responsible for its cleanup.

This method is only available if build option GEODESK_WITH_GEOS is enabled (off by default).

Parameters
geosContextThe GEOS context o use
Returns
the pointer to the newly-created GEOSGeometry

◆ toString()

std::string geodesk::Feature::toString ( ) const
inherited

Creates a std::string with the Feature's type and ID.

Returns
a std::string (e.g. "node/123456")

◆ type()

FeatureType geodesk::Relation::type ( ) const
noexcept

◆ typeName()

const char * geodesk::Feature::typeName ( ) const
noexceptinherited

"node", "way" or "relation"

Returns
pointer null-terminated constant string

◆ x()

int32_t geodesk::Feature::x ( ) const
noexceptinherited

The Mercator-projected x-coordinate of a Node, or the horizontal midpoint of the bounding box for a Way or Relation.

◆ xy()

Coordinate geodesk::Feature::xy ( ) const
noexceptinherited

The Mercator-projected x/y coordinate of a Node, or the center point of the bounding box for a Way or Relation.

◆ y()

int32_t geodesk::Feature::y ( ) const
noexceptinherited

The Mercator-projected y-coordinate of a Node, or the vertical midpoint of the bounding box for a Way or Relation.


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