1 #ifndef OSMIUM_GEOM_OGR_HPP
2 #define OSMIUM_GEOM_OGR_HPP
50 #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 OGRFactoryImpl() =
default;
85 return point_type{
new OGRPoint{xy.
x, xy.
y}};
90 void linestring_start() {
91 m_linestring.reset(
new OGRLineString{});
95 assert(!!m_linestring);
96 m_linestring->addPoint(xy.
x, xy.
y);
99 linestring_type linestring_finish(
size_t ) {
100 assert(!!m_linestring);
101 return std::move(m_linestring);
106 void polygon_start() {
107 m_ring.reset(
new OGRLinearRing{});
112 m_ring->addPoint(xy.
x, xy.
y);
115 polygon_type polygon_finish(
size_t ) {
116 auto polygon = std::unique_ptr<OGRPolygon>{
new OGRPolygon{}};
117 polygon->addRingDirectly(m_ring.release());
123 void multipolygon_start() {
124 m_multipolygon.reset(
new OGRMultiPolygon{});
127 void multipolygon_polygon_start() {
128 m_polygon.reset(
new OGRPolygon{});
131 void multipolygon_polygon_finish() {
132 assert(!!m_multipolygon);
134 m_multipolygon->addGeometryDirectly(m_polygon.release());
137 void multipolygon_outer_ring_start() {
138 m_ring.reset(
new OGRLinearRing{});
141 void multipolygon_outer_ring_finish() {
144 m_polygon->addRingDirectly(m_ring.release());
147 void multipolygon_inner_ring_start() {
148 m_ring.reset(
new OGRLinearRing{});
151 void multipolygon_inner_ring_finish() {
154 m_polygon->addRingDirectly(m_ring.release());
160 m_ring->addPoint(xy.
x, xy.
y);
163 multipolygon_type multipolygon_finish() {
164 assert(!!m_multipolygon);
165 return std::move(m_multipolygon);
172 template <
typename TProjection = IdentityProjection>
179 #endif // OSMIUM_GEOM_OGR_HPP
double y
Definition: coordinates.hpp:49
Definition: factory.hpp:146
Namespace for everything in the Osmium library.
Definition: assembler.hpp:66
Definition: coordinates.hpp:46
double x
Definition: coordinates.hpp:48