File indexing completed on 2024-05-19 03:53:14
0001 // SPDX-License-Identifier: LGPL-2.1-or-later 0002 // 0003 // SPDX-FileCopyrightText: 2015 Stanciu Marius-Valeriu <stanciumarius94@gmail.com> 0004 // 0005 0006 //Self 0007 #include "OsmNodeTagWriter.h" 0008 0009 //Qt 0010 #include <QHash> 0011 0012 //Marble 0013 #include "OsmElementDictionary.h" 0014 #include "OsmObjectAttributeWriter.h" 0015 #include "OsmTagTagWriter.h" 0016 #include "GeoDataPoint.h" 0017 #include "GeoDataLineString.h" 0018 #include "GeoWriter.h" 0019 #include "osm/OsmPlacemarkData.h" 0020 #include "osm/OsmObjectManager.h" 0021 0022 namespace Marble 0023 { 0024 0025 0026 void OsmNodeTagWriter::writeNode( const OsmConverter::Node &node, GeoWriter& writer ) 0027 { 0028 QString lat = QString::number( node.first.latitude( GeoDataCoordinates::Degree ), 'f', 7 ); 0029 QString lon = QString::number( node.first.longitude( GeoDataCoordinates::Degree ), 'f', 7 ); 0030 0031 writer.writeStartElement( osm::osmTag_node ); 0032 0033 writer.writeAttribute( "lat", lat ); 0034 writer.writeAttribute( "lon", lon ); 0035 OsmObjectAttributeWriter::writeAttributes( node.second, writer ); 0036 OsmTagTagWriter::writeTags(node.second, writer); 0037 0038 writer.writeEndElement(); 0039 } 0040 0041 void OsmNodeTagWriter::writeAllNodes( const OsmConverter::Nodes& nodes, GeoWriter& writer ) 0042 { 0043 // Writing all the component nodes 0044 qint64 lastId = 0; 0045 for(auto const &node: nodes) { 0046 if (node.second.id() != lastId) { 0047 writeNode(node, writer); 0048 lastId = node.second.id(); 0049 } // else duplicate/shared node 0050 } 0051 } 0052 0053 }