1 #ifndef OSMIUM_GEOM_OGR_HPP
2 #define OSMIUM_GEOM_OGR_HPP
50 #include <ogr_geometry.h>
61 class OGRFactoryImpl {
65 typedef std::unique_ptr<OGRPoint> point_type;
66 typedef std::unique_ptr<OGRLineString> linestring_type;
67 typedef std::unique_ptr<OGRPolygon> polygon_type;
68 typedef std::unique_ptr<OGRMultiPolygon> multipolygon_type;
69 typedef std::unique_ptr<OGRLinearRing> ring_type;
73 linestring_type m_linestring;
74 multipolygon_type m_multipolygon;
75 polygon_type m_polygon;
80 OGRFactoryImpl() =
default;
85 return point_type(
new OGRPoint(xy.
x, xy.
y));
90 void linestring_start() {
91 m_linestring = std::unique_ptr<OGRLineString>(
new OGRLineString());
95 assert(!!m_linestring);
96 m_linestring->addPoint(xy.
x, xy.
y);
99 linestring_type linestring_finish(
size_t ) {
100 return std::move(m_linestring);
105 void polygon_start() {
106 m_ring = std::unique_ptr<OGRLinearRing>(
new OGRLinearRing());
111 m_ring->addPoint(xy.
x, xy.
y);
114 polygon_type polygon_finish(
size_t ) {
115 std::unique_ptr<OGRPolygon> polygon = std::unique_ptr<OGRPolygon>(
new OGRPolygon());
116 polygon->addRingDirectly(m_ring.release());
122 void multipolygon_start() {
123 m_multipolygon.reset(
new OGRMultiPolygon());
126 void multipolygon_polygon_start() {
127 m_polygon.reset(
new OGRPolygon());
130 void multipolygon_polygon_finish() {
131 assert(!!m_multipolygon);
133 m_multipolygon->addGeometryDirectly(m_polygon.release());
136 void multipolygon_outer_ring_start() {
137 m_ring.reset(
new OGRLinearRing());
140 void multipolygon_outer_ring_finish() {
143 m_polygon->addRingDirectly(m_ring.release());
146 void multipolygon_inner_ring_start() {
147 m_ring.reset(
new OGRLinearRing());
150 void multipolygon_inner_ring_finish() {
153 m_polygon->addRingDirectly(m_ring.release());
159 m_ring->addPoint(xy.
x, xy.
y);
162 multipolygon_type multipolygon_finish() {
163 assert(!!m_multipolygon);
164 return std::move(m_multipolygon);
171 template <
class TProjection = IdentityProjection>
178 #endif // OSMIUM_GEOM_OGR_HPP
double y
Definition: coordinates.hpp:50
Definition: factory.hpp:146
Namespace for everything in the Osmium library.
Definition: assembler.hpp:55
Definition: coordinates.hpp:47
double x
Definition: coordinates.hpp:49