@@ -530,15 +530,28 @@ void GlobePlugin::syncExtent()
530530 const QgsMapSettings &mapSettings = mapCanvas->mapSettings ();
531531 QgsRectangle extent = mapCanvas->extent ();
532532
533+ long epsgGlobe = 4326 ;
534+ QgsCoordinateReferenceSystem globeCrs;
535+ globeCrs.createFromOgcWmsCrs ( QString ( " EPSG:%1" ).arg ( epsgGlobe ) );
536+
537+ // transform extent to WGS84
538+ if ( mapSettings.destinationCrs ().authid ().compare ( QString ( " EPSG:%1" ).arg ( epsgGlobe ), Qt::CaseInsensitive ) != 0 )
539+ {
540+ QgsCoordinateReferenceSystem srcCRS ( mapSettings.destinationCrs () );
541+ QgsCoordinateTransform* coordTransform = new QgsCoordinateTransform ( srcCRS, globeCrs );
542+ extent = coordTransform->transformBoundingBox ( extent );
543+ delete coordTransform;
544+ }
545+
533546 osgEarth::Util::EarthManipulator* manip = dynamic_cast <osgEarth::Util::EarthManipulator*>( mOsgViewer ->getCameraManipulator () );
534547 // rotate earth to north and perpendicular to camera
535548 manip->setRotation ( osg::Quat () );
536549
537550 QgsDistanceArea dist;
538551
539- dist.setSourceCrs ( mapSettings. destinationCrs (). srsid () );
540- dist.setEllipsoidalMode ( mapSettings. hasCrsTransformEnabled () );
541- dist.setEllipsoid ( QgsProject::instance ()-> readEntry ( " Measure " , " /Ellipsoid " , GEO_NONE ) );
552+ dist.setSourceCrs ( globeCrs );
553+ dist.setEllipsoidalMode ( true );
554+ dist.setEllipsoid ( " WGS84 " );
542555
543556 QgsPoint ll = QgsPoint ( extent.xMinimum (), extent.yMinimum () );
544557 QgsPoint ul = QgsPoint ( extent.xMinimum (), extent.yMaximum () );
0 commit comments