File indexing completed on 2025-01-05 03:59:14
0001 // SPDX-License-Identifier: LGPL-2.1-or-later 0002 // 0003 // SPDX-FileCopyrightText: 2012 Shou Ya <shouyatf@gmail.com> 0004 // SPDX-FileCopyrightText: 2012 Dennis Nienhüser <nienhueser@kde.org> 0005 // 0006 0007 #include "KmlPhotoOverlayWriter.h" 0008 0009 #include "GeoDataPhotoOverlay.h" 0010 #include "GeoDataTypes.h" 0011 #include "GeoDataImagePyramid.h" 0012 #include "GeoDataPoint.h" 0013 #include "GeoDataViewVolume.h" 0014 #include "GeoWriter.h" 0015 #include "KmlElementDictionary.h" 0016 0017 namespace Marble 0018 { 0019 0020 static GeoTagWriterRegistrar s_writerLookAt( 0021 GeoTagWriter::QualifiedName( QString::fromUtf8(GeoDataTypes::GeoDataPhotoOverlayType), 0022 QString::fromUtf8(kml::kmlTag_nameSpaceOgc22) ), 0023 new KmlPhotoOverlayWriter ); 0024 0025 KmlPhotoOverlayWriter::KmlPhotoOverlayWriter() : KmlOverlayTagWriter( QString::fromUtf8(kml::kmlTag_PhotoOverlay) ) 0026 { 0027 // nothing to do 0028 } 0029 0030 bool KmlPhotoOverlayWriter::writeMid( const GeoNode *node, GeoWriter &writer ) const 0031 { 0032 KmlOverlayTagWriter::writeMid( node, writer ); 0033 0034 const GeoDataPhotoOverlay *photo_overlay = 0035 static_cast<const GeoDataPhotoOverlay*>( node ); 0036 0037 // rotation 0038 QString const rotation = QString::number( photo_overlay->rotation(), 'f', 3 ); 0039 writer.writeOptionalElement( QString::fromUtf8(kml::kmlTag_rotation), rotation, QString::fromUtf8("0.000") ); 0040 0041 // ViewVolume 0042 writer.writeStartElement( QString::fromUtf8(kml::kmlTag_ViewVolume) ); 0043 writer.writeOptionalElement<qreal>( QString::fromUtf8(kml::kmlTag_leftFov), photo_overlay->viewVolume().leftFov(), 0 ); 0044 writer.writeOptionalElement<qreal>( QString::fromUtf8(kml::kmlTag_rightFov), photo_overlay->viewVolume().rightFov(), 0 ); 0045 writer.writeOptionalElement<qreal>( QString::fromUtf8(kml::kmlTag_bottomFov), photo_overlay->viewVolume().bottomFov(), 0 ); 0046 writer.writeOptionalElement<qreal>( QString::fromUtf8(kml::kmlTag_topFov), photo_overlay->viewVolume().topFov(), 0 ); 0047 writer.writeOptionalElement<qreal>( QString::fromUtf8(kml::kmlTag_near), photo_overlay->viewVolume().near(), 0 ); 0048 writer.writeEndElement(); 0049 0050 // ImagePyramid 0051 writer.writeStartElement( QString::fromUtf8(kml::kmlTag_ImagePyramid) ); 0052 writer.writeOptionalElement<int>( QString::fromUtf8(kml::kmlTag_tileSize), photo_overlay->imagePyramid().tileSize(), 256 ); 0053 writer.writeOptionalElement<int>( QString::fromUtf8(kml::kmlTag_maxWidth), photo_overlay->imagePyramid().maxWidth() ); 0054 writer.writeOptionalElement<int>( QString::fromUtf8(kml::kmlTag_maxHeight), photo_overlay->imagePyramid().maxHeight() ); 0055 0056 switch ( photo_overlay->imagePyramid().gridOrigin() ) 0057 { 0058 case GeoDataImagePyramid::LowerLeft: 0059 writer.writeElement( QString::fromUtf8(kml::kmlTag_gridOrigin), QString::fromUtf8("lowerLeft") ); 0060 break; 0061 case GeoDataImagePyramid::UpperLeft: 0062 writer.writeElement( QString::fromUtf8(kml::kmlTag_gridOrigin), QString::fromUtf8("upperLeft") ); 0063 break; 0064 } 0065 writer.writeEndElement(); 0066 0067 // Point 0068 writeElement( &photo_overlay->point(), writer ); 0069 0070 // shape 0071 switch ( photo_overlay->shape() ) 0072 { 0073 case GeoDataPhotoOverlay::Rectangle: 0074 break; 0075 case GeoDataPhotoOverlay::Cylinder: 0076 writer.writeElement( QString::fromUtf8(kml::kmlTag_shape), QString::fromUtf8("cylinder") ); 0077 break; 0078 case GeoDataPhotoOverlay::Sphere: 0079 writer.writeElement( QString::fromUtf8(kml::kmlTag_shape), QString::fromUtf8("sphere") ); 0080 break; 0081 } 0082 0083 return true; 0084 } 0085 0086 }