1#ifndef OSMIUM_GEOM_OGR_HPP
2#define OSMIUM_GEOM_OGR_HPP
48#include <ogr_geometry.h>
61 class OGRFactoryImpl {
65 using point_type = std::unique_ptr<OGRPoint>;
66 using linestring_type = std::unique_ptr<OGRLineString>;
67 using polygon_type = std::unique_ptr<OGRPolygon>;
68 using multipolygon_type = std::unique_ptr<OGRMultiPolygon>;
69 using ring_type = std::unique_ptr<OGRLinearRing>;
73 linestring_type m_linestring{
nullptr};
74 multipolygon_type m_multipolygon{
nullptr};
75 polygon_type m_polygon{
nullptr};
76 ring_type m_ring{
nullptr};
80 explicit OGRFactoryImpl(
int ) {
86 return point_type{
new OGRPoint{xy.
x, xy.
y}};
91 void linestring_start() {
92 m_linestring.reset(
new OGRLineString{});
96 assert(!!m_linestring);
97 m_linestring->addPoint(xy.
x, xy.
y);
100 linestring_type linestring_finish(
size_t ) {
101 assert(!!m_linestring);
102 return std::move(m_linestring);
107 void polygon_start() {
108 m_ring.reset(
new OGRLinearRing{});
113 m_ring->addPoint(xy.
x, xy.
y);
116 polygon_type polygon_finish(
size_t ) {
117 auto polygon = std::unique_ptr<OGRPolygon>{
new OGRPolygon{}};
118 polygon->addRingDirectly(m_ring.release());
124 void multipolygon_start() {
125 m_multipolygon.reset(
new OGRMultiPolygon{});
128 void multipolygon_polygon_start() {
129 m_polygon.reset(
new OGRPolygon{});
132 void multipolygon_polygon_finish() {
133 assert(!!m_multipolygon);
135 m_multipolygon->addGeometryDirectly(m_polygon.release());
138 void multipolygon_outer_ring_start() {
139 m_ring.reset(
new OGRLinearRing{});
142 void multipolygon_outer_ring_finish() {
145 m_polygon->addRingDirectly(m_ring.release());
148 void multipolygon_inner_ring_start() {
149 m_ring.reset(
new OGRLinearRing{});
152 void multipolygon_inner_ring_finish() {
155 m_polygon->addRingDirectly(m_ring.release());
161 m_ring->addPoint(xy.
x, xy.
y);
164 multipolygon_type multipolygon_finish() {
165 assert(!!m_multipolygon);
166 return std::move(m_multipolygon);
173 template <
typename TProjection = IdentityProjection>
Definition: factory.hpp:149
Namespace for everything in the Osmium library.
Definition: assembler.hpp:53
Definition: coordinates.hpp:48
double y
Definition: coordinates.hpp:51
double x
Definition: coordinates.hpp:50