1#ifndef OSMIUM_GEOM_FACTORY_HPP
2#define OSMIUM_GEOM_FACTORY_HPP
68 std::runtime_error(message),
73 m_message += object_type;
75 m_message += std::to_string(m_id);
81 if (m_id == 0 &&
id != 0) {
83 m_message += object_type;
85 m_message += std::to_string(
id);
95 const char*
what() const noexcept
override {
96 return m_message.c_str();
140 return "+proj=longlat +datum=WGS84 +no_defs";
148 template <
typename TGeomImpl,
typename TProjection = IdentityProjection>
157 if (last_location != node_ref.location()) {
158 last_location = node_ref.location();
177 template <
typename... TArgs>
187 template <
typename... TArgs>
219 e.
set_id(
"node", node.id());
236 m_impl.linestring_start();
239 template <
typename TIter>
241 size_t num_points = 0;
242 for (; it !=
end; ++it, ++num_points) {
248 template <
typename TIter>
250 size_t num_points = 0;
252 for (; it !=
end; ++it) {
253 if (last_location != it->location()) {
254 last_location = it->location();
263 return m_impl.linestring_finish(num_points);
268 size_t num_points = 0;
290 if (num_points < 2) {
301 e.
set_id(
"way", way.id());
312 template <
typename TIter>
314 size_t num_points = 0;
315 for (; it !=
end; ++it, ++num_points) {
321 template <
typename TIter>
323 size_t num_points = 0;
325 for (; it !=
end; ++it) {
326 if (last_location != it->location()) {
327 last_location = it->location();
336 return m_impl.polygon_finish(num_points);
341 size_t num_points = 0;
363 if (num_points < 4) {
374 e.
set_id(
"way", way.id());
383 size_t num_polygons = 0;
384 size_t num_rings = 0;
385 m_impl.multipolygon_start();
387 for (
const auto& item : area) {
390 if (num_polygons > 0) {
391 m_impl.multipolygon_polygon_finish();
393 m_impl.multipolygon_polygon_start();
394 m_impl.multipolygon_outer_ring_start();
396 m_impl.multipolygon_outer_ring_finish();
401 m_impl.multipolygon_inner_ring_start();
403 m_impl.multipolygon_inner_ring_finish();
409 if (num_rings == 0) {
413 m_impl.multipolygon_polygon_finish();
414 return m_impl.multipolygon_finish();
416 e.
set_id(
"area", area.id());
Definition: location.hpp:271
double lon() const
Definition: location.hpp:400
double lat() const
Definition: location.hpp:419
Definition: node_ref_list.hpp:52
const_iterator cbegin() const noexcept
Returns an iterator to the beginning.
Definition: node_ref_list.hpp:209
const_iterator cend() const noexcept
Returns an iterator to the end.
Definition: node_ref_list.hpp:214
const_reverse_iterator crend() const noexcept
Returns a reverse_iterator to the end.
Definition: node_ref_list.hpp:234
const_reverse_iterator crbegin() const noexcept
Returns a reverse_iterator to the beginning.
Definition: node_ref_list.hpp:229
Definition: node_ref.hpp:50
constexpr osmium::object_id_type ref() const noexcept
Definition: node_ref.hpp:71
osmium::Location & location() noexcept
Definition: node_ref.hpp:85
Definition: factory.hpp:149
multipolygon_type create_multipolygon(const osmium::Area &area)
Definition: factory.hpp:381
typename TGeomImpl::multipolygon_type multipolygon_type
Definition: factory.hpp:198
void linestring_start()
Definition: factory.hpp:235
size_t fill_polygon(TIter it, TIter end)
Definition: factory.hpp:313
typename TGeomImpl::point_type point_type
Definition: factory.hpp:195
point_type create_point(const osmium::Node &node)
Definition: factory.hpp:215
TGeomImpl m_impl
Definition: factory.hpp:165
GeometryFactory()
Definition: factory.hpp:169
size_t fill_linestring(TIter it, TIter end)
Definition: factory.hpp:240
void polygon_start()
Definition: factory.hpp:308
size_t fill_polygon_unique(TIter it, TIter end)
Definition: factory.hpp:322
linestring_type create_linestring(const osmium::Way &way, use_nodes un=use_nodes::unique, direction dir=direction::forward)
Definition: factory.hpp:297
polygon_type create_polygon(const osmium::WayNodeList &wnl, use_nodes un=use_nodes::unique, direction dir=direction::forward)
Definition: factory.hpp:339
typename TGeomImpl::polygon_type polygon_type
Definition: factory.hpp:197
int epsg() const noexcept
Definition: factory.hpp:201
point_type create_point(const osmium::NodeRef &node_ref)
Definition: factory.hpp:224
TProjection projection_type
Definition: factory.hpp:193
TProjection m_projection
Definition: factory.hpp:164
GeometryFactory(TArgs &&... args)
Definition: factory.hpp:178
point_type create_point(const osmium::Location &location) const
Definition: factory.hpp:211
GeometryFactory(TProjection &&projection, TArgs &&... args)
Definition: factory.hpp:188
polygon_type create_polygon(const osmium::Way &way, use_nodes un=use_nodes::unique, direction dir=direction::forward)
Definition: factory.hpp:370
size_t fill_linestring_unique(TIter it, TIter end)
Definition: factory.hpp:249
linestring_type create_linestring(const osmium::WayNodeList &wnl, use_nodes un=use_nodes::unique, direction dir=direction::forward)
Definition: factory.hpp:266
linestring_type linestring_finish(size_t num_points)
Definition: factory.hpp:262
typename TGeomImpl::linestring_type linestring_type
Definition: factory.hpp:196
std::string proj_string() const
Definition: factory.hpp:205
polygon_type polygon_finish(size_t num_points)
Definition: factory.hpp:335
typename TGeomImpl::ring_type ring_type
Definition: factory.hpp:199
void add_points(const osmium::NodeRefList &nodes)
Definition: factory.hpp:154
Definition: factory.hpp:127
static std::string proj_string() noexcept
Definition: factory.hpp:139
Coordinates operator()(osmium::Location location) const
Definition: factory.hpp:131
static int epsg() noexcept
Definition: factory.hpp:135
Definition: factory.hpp:60
void set_id(const char *object_type, osmium::object_id_type id)
Definition: factory.hpp:80
const char * what() const noexcept override
Definition: factory.hpp:95
osmium::object_id_type id() const noexcept
Definition: factory.hpp:91
std::string m_message
Definition: factory.hpp:62
osmium::object_id_type m_id
Definition: factory.hpp:63
geometry_error(const std::string &message, const char *object_type="", osmium::object_id_type id=0)
Definition: factory.hpp:67
#define OSMIUM_EXPORT
Definition: compatibility.hpp:54
use_nodes
Definition: factory.hpp:109
@ unique
Remove consecutive nodes with same location.
direction
Definition: factory.hpp:118
@ backward
Linestring has reverse direction.
@ forward
Linestring has same direction as way.
InputIterator< Reader > end(Reader &)
Definition: reader_iterator.hpp:47
Namespace for everything in the Osmium library.
Definition: assembler.hpp:53
int64_t object_id_type
Type for OSM object (node, way, or relation) IDs.
Definition: types.hpp:45
Definition: location.hpp:555
Definition: coordinates.hpp:48