File indexing completed on 2024-05-12 03:51:44
0001 /* 0002 SPDX-FileCopyrightText: 2011 Anders Lund <anders@alweb.dk> 0003 SPDX-License-Identifier: LGPL-2.1-or-later 0004 */ 0005 0006 #include "GPXrteptTagHandler.h" 0007 0008 #include "MarbleDebug.h" 0009 0010 #include "GPXElementDictionary.h" 0011 #include "GeoParser.h" 0012 #include "GeoDataLineString.h" 0013 #include "GeoDataCoordinates.h" 0014 #include "GeoDataPlacemark.h" 0015 #include "GeoDataStyle.h" 0016 0017 namespace Marble 0018 { 0019 namespace gpx 0020 { 0021 GPX_DEFINE_TAG_HANDLER(rtept) 0022 0023 GeoNode* GPXrteptTagHandler::parse(GeoParser& parser) const 0024 { 0025 Q_ASSERT(parser.isStartElement() && parser.isValidElement(QLatin1String(gpxTag_rtept))); 0026 0027 GeoStackItem parentItem = parser.parentElement(); 0028 if (parentItem.represents(gpxTag_rte)) 0029 { 0030 GeoDataPlacemark* placemark = parentItem.nodeAs<GeoDataPlacemark>(); 0031 GeoDataLineString* linestring = static_cast<GeoDataLineString*>(placemark->geometry()); 0032 GeoDataCoordinates coord; 0033 0034 QXmlStreamAttributes attributes = parser.attributes(); 0035 QStringRef tmp; 0036 qreal lat = 0; 0037 qreal lon = 0; 0038 tmp = attributes.value(QLatin1String(gpxTag_lat)); 0039 if ( !tmp.isEmpty() ) 0040 { 0041 lat = tmp.toString().toFloat(); 0042 } 0043 tmp = attributes.value(QLatin1String(gpxTag_lon)); 0044 if ( !tmp.isEmpty() ) 0045 { 0046 lon = tmp.toString().toFloat(); 0047 } 0048 coord.set(lon, lat, 0, GeoDataCoordinates::Degree); 0049 linestring->append(coord); 0050 0051 } 0052 return nullptr; 0053 } 0054 0055 } // namespace gpx 0056 0057 } // namespace Marble