GeoDesk for C++
Fast and storage-efficient spatial database engine for OpenStreetMap features
Loading...
Searching...
No Matches
Features.h
Go to the documentation of this file.
1// Copyright (c) 2024 Clarisma / GeoDesk contributors
2// SPDX-License-Identifier: LGPL-3.0-only
3
4#pragma once
5
6#include <vector>
9#include <geodesk/geom/Box.h>
10
11namespace geodesk
12{
13class Feature;
14class Nodes;
15class Ways;
16class Relations;
17}
18
19namespace geodesk {
20
112{
113public:
119 Features(const char* golFile);
120
124 Features(const Features& other);
125
128
132 operator bool() const;
133
136 bool operator!() const;
137
140 bool contains(const Feature& feature) const;
141
145
152 Features operator()(const char* query) const;
153
157 Nodes nodes() const;
158
166 Nodes nodes(const char* query) const;
167
171 Ways ways() const;
172
180 Ways ways(const char* query) const;
181
186
194 Relations relations(const char* query) const;
195
199
208 std::optional<Feature> first() const;
209
217 Feature one() const;
218
221 operator std::vector<Feature>() const;
222
227 operator std::vector<FeaturePtr>() const;
228
231 void addTo(std::vector<Feature>& features) const;
232
236 void addTo(std::vector<FeaturePtr>& features) const;
237
241
244 uint64_t count() const;
245
252 double length() const;
253
260 double area() const;
261
265
270 Features operator()(const Box& box) const;
271
277
281 Features operator()(const Feature& feature) const;
282
289 Features intersecting(const Feature& feature) const;
290
297 Features within(const Feature& feature) const;
298
305 Features containing(const Feature& feature) const;
306
311
318 Features containingLonLat(double lon, double lat) const;
319
326 Features crossing(const Feature& feature) const;
327
334 Features maxMetersFrom(double distance, Coordinate xy) const;
335
343 Features maxMetersFrom(double distance, double lon, double lat) const;
344
348
351 Features nodesOf(const Feature& feature) const;
352
355 Features membersOf(const Feature& feature) const;
356
360 Features parentsOf(const Feature& feature) const;
361
365 Features connectedTo(const Feature& feature) const;
366
370
389 template <typename Predicate>
390 Features filter(Predicate predicate) const;
391
395
399 FeatureStore* store() const noexcept;
400
402};
403
406class Nodes : public Features
407{
408};
409
412class Ways : public Features
413{
414};
415
418class Relations : public Features
419{
420};
421
422} // namespace geodesk
423
424
425
An axis-aligned bounding box.
Definition Box.h:34
A pair of Cartesian coordinate values.
Definition Coordinate.h:17
A geographic feature.
Definition Feature.h:27
A Geographic Object Library.
Definition FeatureStore.h:35
A collection of geographic features.
Definition Features.h:112
Features(const char *golFile)
Creates a collection that contains all features in the given Geographic Object Library.
Ways ways() const
Only ways.
Ways ways(const char *query) const
Only ways that match the given query.
Features containingLonLat(double lon, double lat) const
Only features whose geometry contains the given location.
double length() const
Computes the total length (in meters) of the features in this collection.
Features containing(const Feature &feature) const
Only features whose geometry contains the given Feature.
Features maxMetersFrom(double distance, double lon, double lat) const
Only features whose closest point lies within distance meters of the given location.
bool contains(const Feature &feature) const
Checks if the specified Feature exists in this collection.
Features nodesOf(const Feature &feature) const
Only nodes that belong to the given Way.
void addTo(std::vector< FeaturePtr > &features) const
Appends the Feature objects in this collection to the given std::vector as FeaturePtr pointers.
FeatureStore * store() const noexcept
Returns a pointer to the FeatureStore which contains the features in this collection.
Features crossing(const Feature &feature) const
Only features whose geometry crosses the given Feature.
Features membersOf(const Feature &feature) const
Only features that belong to the given Relation.
Relations relations() const
Only relations.
Features filter(Predicate predicate) const
Only features that match the given predicate.
Feature one() const
Returns the one and only Feature in this collection.
Features within(const Feature &feature) const
Only features that lie entirely inside the geometry of the given Feature.
Relations relations(const char *query) const
Only relations that match the given query.
void addTo(std::vector< Feature > &features) const
Appends the Feature objects in this collection to the given std::vector.
Features parentsOf(const Feature &feature) const
Only features that are parent relations of the given Feature (or parent ways of the given Node).
std::optional< Feature > first() const
Returns the first Feature in this collection, or std::nullopt if the collection is empty.
Features operator()(const char *query) const
Only features that match the given query.
Nodes nodes() const
Only nodes.
double area() const
Computes the total area (in square meters) of the features in this collection.
Features(const Features &other)
Creates a collection with all the features in the other collection.
Features operator()(const Box &box) const
Only features whose bounding box intersects the given bounding box.
uint64_t count() const
Returns the total number of features in this collection.
Features intersecting(const Feature &feature) const
Only features whose geometry intersects with the given Feature.
Features operator()(const Feature &feature) const
Only features whose geometry intersects with the given Feature (short form of intersecting())
bool operator!() const
Returns true if this collection is empty.
Features operator()(Coordinate xy) const
Only features whose bounding box contains the given Coordinate.
Features maxMetersFrom(double distance, Coordinate xy) const
Only features whose closest point lies within distance meters of xy.
Features connectedTo(const Feature &feature) const
Only features that share a common node with the given Feature.
Nodes nodes(const char *query) const
Only nodes that match the given query.
Features containing(Coordinate xy) const
Only features whose geometry contains the given Coordinate.
A collection containing only Node features.
Definition Features.h:407
A collection containing only Relation features.
Definition Features.h:419
A collection containing only Way features.
Definition Features.h:413
Definition Feature.h:11