GeoDesk for C++
Fast and storage-efficient spatial database engine for OpenStreetMap features
|
A geographic feature. More...
#include <Feature.h>
Public Member Functions | |
Feature (FeatureStore *store, FeaturePtr ptr) | |
Type & Identity | |
FeatureType | type () const noexcept |
The Feature's type. | |
int64_t | id () const noexcept |
The ID of this Feature. | |
bool | isNode () const noexcept |
true if this Feature is a Node. | |
bool | isAnonymousNode () const noexcept |
true if this Feature is an anonymous node. | |
bool | isWay () const noexcept |
true if this Feature is a Way. | |
bool | isRelation () const noexcept |
true if this Feature is a Relation. | |
bool | isArea () const noexcept |
true if this Feature is an area (represented by either a Way or Relation). | |
bool | belongsToRelation () const noexcept |
true if this Feature belongs to at least one Relation. | |
StringValue | role () const noexcept |
The Feature's role in its 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. | |
FeatureStore * | store () const noexcept |
Pointer to the FeatureStore which contains this Feature. | |
A geographic feature.
geodesk::Feature::Feature | ( | FeatureStore * | store, |
FeaturePtr | ptr ) |
double geodesk::Feature::area | ( | ) | const |
Measures the area of this Feature.
0
if the feature is not polygonal QueryException | if one or more tiles that contain the geometry of a Relation are missing |
|
noexcept |
|
noexcept |
Coordinate geodesk::Feature::centroid | ( | ) | const |
Computes the centroid of this Feature.
QueryException | if one or more tiles that contain the geometry of a Relation are missing |
|
noexcept |
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.
buf | pointer to a char array of sufficient size |
buf
|
noexcept |
Checks if this Feature has a tag with the given key.
|
noexcept |
Checks if this Feature has a tag with the given key and value.
|
noexcept |
|
noexcept |
true
if this Feature is an anonymous node.
An anonymous node is a Node that has no tags and does not belong to any relation; it merely exists as a vertex of a Way. Its ID is always 0
and its FeaturePtr
is nullptr
.
|
noexcept |
std::string geodesk::Feature::label | ( | ) | const |
Creates a short descriptive label.
This is usually a combination of the type and name, such as hotel "Four Seasons"
.
|
noexcept |
double geodesk::Feature::length | ( | ) | const |
Measures the length of this Feature.
0
if the feature is not lineal QueryException | if one or more tiles that contain the geometry of a Relation are missing |
|
noexcept |
Features geodesk::Feature::members | ( | ) | const |
Features geodesk::Feature::members | ( | const char * | query | ) | const |
The members of this Relation that match the given query.
query | a query in GOQL format |
QueryException | if the query is malformed. |
Nodes geodesk::Feature::nodes | ( | ) | const |
Nodes geodesk::Feature::nodes | ( | const char * | query | ) | const |
The nodes of this Way that match the given query.
query | a query in GOQL format |
QueryException | if the query is malformed. |
|
noexcept |
Obtains the tag value for the given key.
Features geodesk::Feature::parents | ( | ) | const |
Features geodesk::Feature::parents | ( | const char * | query | ) | const |
|
noexcept |
Pointer to the stored data of this Feature.
If this Feature is an anonymous node, the FeaturePtr
will be a nullptr
|
noexcept |
The Feature's role in its Relation, if it was returned via members() or Features::membersOf(), otherwise an empty string.
|
noexcept |
Pointer to the FeatureStore which contains this Feature.
GEOSGeometry * geodesk::Feature::toGeometry | ( | GEOSContextHandle_t | geosContext | ) | const |
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).
geosContext | The GEOS context o use |
GEOSGeometry
std::string geodesk::Feature::toString | ( | ) | const |
Creates a std::string
with the Feature's type and ID.
"node/123456"
)
|
noexcept |
The Feature's type.
NODE
, WAY
or RELATION
|
noexcept |
"node"
, "way"
or "relation"
|
noexcept |
|
noexcept |
|
noexcept |