summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarius Stanciu <[email protected]>2015-07-19 18:06:12 +0300
committerMarius Stanciu <[email protected]>2015-07-19 18:06:12 +0300
commit6c64f0e66b2d88f4b381c30ba9098316d16558ac (patch)
treea3a40fea5fcd05cf563f3f010f950b2273edd9d4
parent7498ccde56063eeff1dfa3128d051f5015c5f762 (diff)
osm writer classes
REVIEW: 124096
-rw-r--r--src/plugins/runner/osm/writers/OsmNodeTagWriter.cpp56
-rw-r--r--src/plugins/runner/osm/writers/OsmNodeTagWriter.h34
-rw-r--r--src/plugins/runner/osm/writers/OsmRelationTagWriter.cpp67
-rw-r--r--src/plugins/runner/osm/writers/OsmRelationTagWriter.h41
-rw-r--r--src/plugins/runner/osm/writers/OsmTagWriter.cpp37
-rw-r--r--src/plugins/runner/osm/writers/OsmTagWriter.h28
-rw-r--r--src/plugins/runner/osm/writers/OsmWayTagWriter.cpp49
-rw-r--r--src/plugins/runner/osm/writers/OsmWayTagWriter.h35
8 files changed, 347 insertions, 0 deletions
diff --git a/src/plugins/runner/osm/writers/OsmNodeTagWriter.cpp b/src/plugins/runner/osm/writers/OsmNodeTagWriter.cpp
new file mode 100644
index 0000000..bff7a54
--- /dev/null
+++ b/src/plugins/runner/osm/writers/OsmNodeTagWriter.cpp
@@ -0,0 +1,56 @@
+//
+// This file is part of the Marble Virtual Globe.
+//
+// This program is free software licensed under the GNU LGPL. You can
+// find a copy of this license in LICENSE.txt in the top directory of
+// the source code.
+//
+// Copyright 2015 Stanciu Marius-Valeriu <[email protected]>
+//
+
+//Self
+#include "OsmNodeTagWriter.h"
+
+//Qt
+#include <QHash>
+
+//Marble
+#include "OsmElementDictionary.h"
+#include "OsmObjectAttributeWriter.h"
+#include "OsmObjectManager.h"
+#include "OsmTagTagWriter.h"
+#include "GeoDataPoint.h"
+#include "GeoDataLineString.h"
+#include "osm/OsmPlacemarkData.h"
+
+namespace Marble
+{
+
+
+void OsmNodeTagWriter::writeNode( const GeoDataCoordinates& coordinates, const OsmPlacemarkData& osmData, GeoWriter& writer )
+{
+ QString lat = QString::number( coordinates.latitude( GeoDataCoordinates::Degree ), 'f', 10 );
+ QString lon = QString::number( coordinates.longitude( GeoDataCoordinates::Degree ), 'f', 10 );
+
+ writer.writeStartElement( osm::osmTag_node );
+
+ writer.writeAttribute( "lat", lat );
+ writer.writeAttribute( "lon", lon );
+ OsmObjectAttributeWriter::writeAttributes( osmData, writer );
+ OsmTagTagWriter::writeTags( osmData, writer );
+
+ writer.writeEndElement();
+}
+
+void OsmNodeTagWriter::writeAllNodes( const OsmPlacemarkData& osmData, GeoWriter& writer )
+{
+ QHash< GeoDataCoordinates, OsmPlacemarkData >::const_iterator it = osmData.nodeReferencesBegin();
+ QHash< GeoDataCoordinates, OsmPlacemarkData >::const_iterator end = osmData.nodeReferencesEnd();
+
+ // Writing all the component nodes
+ for ( ; it != end; ++it ) {
+ writeNode( it.key(), it.value(), writer );
+ }
+}
+
+}
diff --git a/src/plugins/runner/osm/writers/OsmNodeTagWriter.h b/src/plugins/runner/osm/writers/OsmNodeTagWriter.h
new file mode 100644
index 0000000..89ca9ed
--- /dev/null
+++ b/src/plugins/runner/osm/writers/OsmNodeTagWriter.h
@@ -0,0 +1,34 @@
+//
+// This file is part of the Marble Virtual Globe.
+//
+// This program is free software licensed under the GNU LGPL. You can
+// find a copy of this license in LICENSE.txt in the top directory of
+// the source code.
+//
+// Copyright 2015 Stanciu Marius-Valeriu <[email protected]>
+//
+
+#ifndef MARBLE_OSMNODETAGWRITER_H
+#define MARBLE_OSMNODETAGWRITER_H
+
+namespace Marble
+{
+class GeoDataLineString;
+class GeoDataCoordinates;
+class GeoWriter;
+class OsmPlacemarkData;
+class OsmWayData;
+
+class OsmNodeTagWriter
+{
+
+public:
+ static void writeAllNodes( const OsmPlacemarkData& osmData, GeoWriter& writer );
+ static void writeNode( const GeoDataCoordinates& coordinates,
+ const OsmPlacemarkData& osmData, GeoWriter& writer );
+};
+
+}
+
+#endif
+
diff --git a/src/plugins/runner/osm/writers/OsmRelationTagWriter.cpp b/src/plugins/runner/osm/writers/OsmRelationTagWriter.cpp
new file mode 100644
index 0000000..8f79a17
--- /dev/null
+++ b/src/plugins/runner/osm/writers/OsmRelationTagWriter.cpp
@@ -0,0 +1,67 @@
+//
+// This file is part of the Marble Virtual Globe.
+//
+// This program is free software licensed under the GNU LGPL. You can
+// find a copy of this license in LICENSE.txt in the top directory of
+// the source code.
+//
+// Copyright 2015 Stanciu Marius-Valeriu <[email protected]>
+//
+
+//Self
+#include "OsmRelationTagWriter.h"
+
+//Marble
+#include "OsmElementDictionary.h"
+#include "OsmObjectManager.h"
+#include "OsmObjectAttributeWriter.h"
+#include "OsmTagTagWriter.h"
+#include "GeoDataLineString.h"
+#include "GeoDataCoordinates.h"
+#include "GeoDataPlacemark.h"
+#include "osm/OsmPlacemarkData.h"
+
+namespace Marble
+{
+
+void OsmRelationTagWriter::writeMultipolygon( const GeoDataPolygon& polygon,
+ const OsmPlacemarkData& osmData, GeoWriter& writer )
+{
+ writer.writeStartElement( osm::osmTag_relation );
+
+ OsmObjectAttributeWriter::writeAttributes( osmData, writer );
+ OsmTagTagWriter::writeTags( osmData, writer );
+
+ const GeoDataLinearRing &ring = polygon.outerBoundary();
+
+ writer.writeStartElement( osm::osmTag_member );
+ QString memberId = QString::number( osmData.reference( &ring ).id() );
+ writer.writeAttribute( "type", "way" );
+ writer.writeAttribute( "ref", memberId );
+ writer.writeAttribute( "role", "outer" );
+ writer.writeEndElement();
+
+ foreach ( const GeoDataLinearRing &innerRing, polygon.innerBoundaries() ) {
+ writer.writeStartElement( osm::osmTag_member );
+ QString memberId = QString::number( osmData.reference( &innerRing ).id() );
+ writer.writeAttribute( "type", "way" );
+ writer.writeAttribute( "ref", memberId );
+ writer.writeAttribute( "role", "inner" );
+ writer.writeEndElement();
+ }
+ writer.writeEndElement();
+ }
+
+void OsmRelationTagWriter::writeRelation( const QVector<GeoDataPlacemark*>& members, const QString& id,
+ const QMap<QString,QString>& tags, GeoWriter& writer )
+{
+ Q_UNUSED( members );
+ Q_UNUSED( id );
+ Q_UNUSED( tags );
+ Q_UNUSED( writer );
+
+ // Not implemented yet ( need to implement the custom relations first )
+}
+
+}
+
diff --git a/src/plugins/runner/osm/writers/OsmRelationTagWriter.h b/src/plugins/runner/osm/writers/OsmRelationTagWriter.h
new file mode 100644
index 0000000..1d0037a
--- /dev/null
+++ b/src/plugins/runner/osm/writers/OsmRelationTagWriter.h
@@ -0,0 +1,41 @@
+//
+// This file is part of the Marble Virtual Globe.
+//
+// This program is free software licensed under the GNU LGPL. You can
+// find a copy of this license in LICENSE.txt in the top directory of
+// the source code.
+//
+// Copyright 2015 Stanciu Marius-Valeriu <[email protected]>
+//
+
+#ifndef MARBLE_OSMRELATIONTAGWRITER_H
+#define MARBLE_OSMRELATIONTAGWRITER_H
+
+
+#include <QMap>
+
+namespace Marble
+{
+
+class GeoDataPolygon;
+class GeoWriter;
+class GeoDataPlacemark;
+class OsmPlacemarkData;
+
+class OsmRelationTagWriter
+{
+
+public:
+ static void writeRelation( const QVector<GeoDataPlacemark*>& relation, const QString& id,
+ const QMap<QString,QString>& tags, GeoWriter& writer );
+
+ static void writeMultipolygon( const GeoDataPolygon& polygon,
+ const OsmPlacemarkData& osmData, GeoWriter& writer );
+};
+
+}
+
+#endif
+
+
+
diff --git a/src/plugins/runner/osm/writers/OsmTagWriter.cpp b/src/plugins/runner/osm/writers/OsmTagWriter.cpp
new file mode 100644
index 0000000..d70e07e
--- /dev/null
+++ b/src/plugins/runner/osm/writers/OsmTagWriter.cpp
@@ -0,0 +1,37 @@
+//
+// This file is part of the Marble Virtual Globe.
+//
+// This program is free software licensed under the GNU LGPL. You can
+// find a copy of this license in LICENSE.txt in the top directory of
+// the source code.
+//
+// Copyright 2015 Stanciu Marius-Valeriu <[email protected]>
+//
+
+#include "OsmTagWriter.h"
+
+#include "GeoWriter.h"
+#include "OsmElementDictionary.h"
+#include "MarbleGlobal.h"
+
+namespace Marble
+{
+
+static GeoTagWriterRegistrar s_writerOsm( GeoTagWriter::QualifiedName( "",
+ osm::osmTag_version06 ),
+ new OsmTagWriter() );
+
+
+bool OsmTagWriter::write( const GeoNode *node, GeoWriter& writer ) const
+{
+ Q_UNUSED( node );
+
+ writer.writeStartElement( "osm" );
+ writer.writeAttribute( "version", osm::osmTag_version06 );
+ writer.writeAttribute( "generator", "Marble " + Marble::MARBLE_VERSION_STRING );
+
+ return true;
+}
+
+}
+
diff --git a/src/plugins/runner/osm/writers/OsmTagWriter.h b/src/plugins/runner/osm/writers/OsmTagWriter.h
new file mode 100644
index 0000000..c86885a
--- /dev/null
+++ b/src/plugins/runner/osm/writers/OsmTagWriter.h
@@ -0,0 +1,28 @@
+//
+// This file is part of the Marble Virtual Globe.
+//
+// This program is free software licensed under the GNU LGPL. You can
+// find a copy of this license in LICENSE.txt in the top directory of
+// the source code.
+//
+// Copyright 2015 Stanciu Marius-Valeriu <[email protected]>
+//
+
+#ifndef MARBLE_OSMTAGWRITER_H
+#define MARBLE_OSMTAGWRITER_H
+
+#include "GeoTagWriter.h"
+
+namespace Marble
+{
+
+class OsmTagWriter : public GeoTagWriter
+{
+public:
+ virtual bool write( const GeoNode *node, GeoWriter& writer ) const;
+};
+
+}
+
+#endif
+
diff --git a/src/plugins/runner/osm/writers/OsmWayTagWriter.cpp b/src/plugins/runner/osm/writers/OsmWayTagWriter.cpp
new file mode 100644
index 0000000..ea534bb
--- /dev/null
+++ b/src/plugins/runner/osm/writers/OsmWayTagWriter.cpp
@@ -0,0 +1,49 @@
+//
+// This file is part of the Marble Virtual Globe.
+//
+// This program is free software licensed under the GNU LGPL. You can
+// find a copy of this license in LICENSE.txt in the top directory of
+// the source code.
+//
+// Copyright 2015 Stanciu Marius-Valeriu <[email protected]>
+//
+
+//Self
+#include "OsmWayTagWriter.h"
+
+//Marble
+#include "OsmElementDictionary.h"
+#include "OsmObjectAttributeWriter.h"
+#include "OsmObjectManager.h"
+#include "OsmTagTagWriter.h"
+#include "GeoDataLineString.h"
+#include "GeoDataCoordinates.h"
+#include "osm/OsmPlacemarkData.h"
+
+namespace Marble
+{
+
+void OsmWayTagWriter::writeWay( const GeoDataLineString& lineString,
+ const OsmPlacemarkData& osmData, GeoWriter& writer )
+{
+
+ writer.writeStartElement( osm::osmTag_way );
+
+ OsmObjectAttributeWriter::writeAttributes( osmData, writer );
+ OsmTagTagWriter::writeTags( osmData, writer );
+
+ // Writing all the component nodes ( Nd tags )
+ QVector<GeoDataCoordinates>::const_iterator it = lineString.constBegin();
+ QVector<GeoDataCoordinates>::ConstIterator const end = lineString.constEnd();
+
+ for ( ; it != end; ++it ) {
+ QString ndId = QString::number( osmData.reference( *it ).id() );
+ writer.writeStartElement( osm::osmTag_nd );
+ writer.writeAttribute( "ref", ndId );
+ writer.writeEndElement();
+ }
+
+ writer.writeEndElement();
+}
+
+}
diff --git a/src/plugins/runner/osm/writers/OsmWayTagWriter.h b/src/plugins/runner/osm/writers/OsmWayTagWriter.h
new file mode 100644
index 0000000..81e237b
--- /dev/null
+++ b/src/plugins/runner/osm/writers/OsmWayTagWriter.h
@@ -0,0 +1,35 @@
+//
+// This file is part of the Marble Virtual Globe.
+//
+// This program is free software licensed under the GNU LGPL. You can
+// find a copy of this license in LICENSE.txt in the top directory of
+// the source code.
+//
+// Copyright 2015 Stanciu Marius-Valeriu <[email protected]>
+//
+
+#ifndef MARBLE_OSMWAYTAGWRITER_H
+#define MARBLE_OSMWAYTAGWRITER_H
+
+#include <QMap>
+
+namespace Marble
+{
+
+class GeoDataLineString;
+class GeoWriter;
+class OsmPlacemarkData;
+
+class OsmWayTagWriter
+{
+
+public:
+ static void writeWay( const GeoDataLineString& lineString,
+ const OsmPlacemarkData& osmData, GeoWriter& writer );
+};
+
+}
+
+#endif
+
+