[Marble-commits] KDE/kdeedu/marble/src/lib/geodata/writers/kml
Dennis Nienhüser
earthwings at gentoo.org
Fri Jan 7 13:22:23 CET 2011
SVN commit 1212545 by nienhueser:
Altitude must be written as well in linestrings.
M +17 -2 KmlLineStringTagWriter.cpp
--- trunk/KDE/kdeedu/marble/src/lib/geodata/writers/kml/KmlLineStringTagWriter.cpp #1212544:1212545
@@ -32,8 +32,17 @@
writer.writeStartElement( kml::kmlTag_LineString );
writer.writeStartElement( "coordinates" );
- for ( int i = 0; i < lineString->size(); ++i )
- {
+ // Write altitude for *all* elements, if *any* element
+ // has altitude information (!= 0.0)
+ bool hasAltitude = false;
+ for ( int i = 0; i < lineString->size(); ++i ) {
+ if ( lineString->at( i ).altitude() ) {
+ hasAltitude = true;
+ break;
+ }
+ }
+
+ for ( int i = 0; i < lineString->size(); ++i ) {
GeoDataCoordinates coordinates = lineString->at( i );
if ( i > 0 )
{
@@ -45,7 +54,13 @@
writer.writeCharacters( "," );
qreal lat = coordinates.latitude( GeoDataCoordinates::Degree );
writer.writeCharacters( QString::number( lat, 'f', 10 ) );
+
+ if ( hasAltitude ) {
+ qreal alt = coordinates.altitude();
+ writer.writeCharacters( "," );
+ writer.writeCharacters( QString::number( alt, 'f', 2 ) );
}
+ }
writer.writeEndElement();
writer.writeEndElement();
More information about the Marble-commits
mailing list