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
119{
120public:
126 Features(const char* golFile);
127
131 Features(const Features& other);
132
135
139 operator bool() const;
140
143 bool operator!() const;
144
147 bool isEmpty() const;
148
151 bool contains(const Feature& feature) const;
152
156
163 Features operator()(const char* query) const;
164
168 Nodes nodes() const;
169
177 Nodes nodes(const char* query) const;
178
182 Ways ways() const;
183
191 Ways ways(const char* query) const;
192
197
205 Relations relations(const char* query) const;
206
210
219 std::optional<Feature> first() const;
220
228 Feature one() const;
229
232 operator std::vector<Feature>() const;
233
238 operator std::vector<FeaturePtr>() const;
239
242 void addTo(std::vector<Feature>& features) const;
243
247 void addTo(std::vector<FeaturePtr>& features) const;
248
252
255 uint64_t count() const;
256
263 double length() const;
264
271 double area() const;
272
276
281 Features operator()(const Box& box) const;
282
288
292 Features operator()(const Feature& feature) const;
293
300 Features intersecting(const Feature& feature) const;
301
308 Features within(const Feature& feature) const;
309
316 Features containing(const Feature& feature) const;
317
322
329 Features containingLonLat(double lon, double lat) const;
330
337 Features crossing(const Feature& feature) const;
338
345 Features maxMetersFrom(double distance, Coordinate xy) const;
346
354 Features maxMetersFrom(double distance, double lon, double lat) const;
355
359
362 Features nodesOf(const Feature& feature) const;
363
366 Features membersOf(const Feature& feature) const;
367
371 Features parentsOf(const Feature& feature) const;
372
376 Features connectedTo(const Feature& feature) const;
377
381
400 template <typename Predicate>
401 Features filter(Predicate predicate) const;
402
406
413 Key key(std::string_view k) const;
414
418
422 FeatureStore* store() const noexcept;
423
425};
426
429class Nodes : public Features
430{
431};
432
435class Ways : public Features
436{
437};
438
441class Relations : public Features
442{
443};
444
445} // namespace geodesk
446
447
448
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:36
A collection of geographic features.
Definition Features.h:119
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.
Key key(std::string_view k) const
Obtains a Key for the given string, which can be used for faster tag-value lookups.
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 contains no features.
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.
bool isEmpty() const
Returns true if this collection contains no features.
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 lightweight wrapper for a key string.
Definition Key.h:42
A collection containing only Node features.
Definition Features.h:430
A collection containing only Relation features.
Definition Features.h:442
A collection containing only Way features.
Definition Features.h:436
Definition Feature.h:11