|
30 | 30 | #include <qgsfeature.h>
|
31 | 31 | #include <qgsgeometry.h>
|
32 | 32 | #include <qgspoint.h>
|
| 33 | +#include <qgsdistancearea.h> |
33 | 34 |
|
34 | 35 | #include <QAction>
|
35 | 36 | #include <QToolBar>
|
@@ -339,8 +340,7 @@ void GlobePlugin::projectReady()
|
339 | 340 | }
|
340 | 341 |
|
341 | 342 | void GlobePlugin::blankProjectReady()
|
342 |
| -{ //TODO now i patched the source against from http://trac.osgeo.org/qgis/changeset/14452 |
343 |
| - //when we use a newer code base we do not need to patch |
| 343 | +{ //needs at least http://trac.osgeo.org/qgis/changeset/14452 |
344 | 344 | mSettingsDialog.elevationDatasources()->clearContents();
|
345 | 345 | mSettingsDialog.elevationDatasources()->setRowCount(0);
|
346 | 346 | }
|
@@ -400,15 +400,17 @@ void GlobePlugin::syncExtent()
|
400 | 400 | //rotate earth to north and perpendicular to camera
|
401 | 401 | manip->setRotation( osg::Quat() );
|
402 | 402 |
|
403 |
| - //get actual mapCanvas->extent().height in meters |
| 403 | + //get mapCanvas->extent().height() in meters |
404 | 404 | QgsRectangle extent = mQGisIface->mapCanvas()->extent();
|
405 |
| - //TODO: implement a stronger solution ev look at http://www.uwgb.edu/dutchs/usefuldata/utmformulas.htm |
406 |
| - QgsCoordinateReferenceSystem* destSrs = new QgsCoordinateReferenceSystem( 31254, QgsCoordinateReferenceSystem::EpsgCrsId ); |
407 |
| - QgsCoordinateTransform* trans = new QgsCoordinateTransform( mQGisIface->mapCanvas()->mapRenderer()->destinationSrs(), *destSrs ); |
408 |
| - QgsRectangle projectedExtent = trans->transformBoundingBox( extent ); |
| 405 | + QgsDistanceArea dist; |
| 406 | + dist.setProjectionsEnabled(true); |
| 407 | + QgsPoint ll = QgsPoint(extent.xMinimum(), extent.yMinimum()); |
| 408 | + QgsPoint ul = QgsPoint(extent.xMinimum(), extent.yMaximum()); |
| 409 | + double height = dist.measureLine(ll, ul); |
409 | 410 |
|
| 411 | + //camera viewing angle |
410 | 412 | double viewAngle = 30;
|
411 |
| - double height = projectedExtent.height(); |
| 413 | + //camera distance |
412 | 414 | double distance = height / tan( viewAngle * osg::PI / 180 ); //c = b*cotan(B(rad))
|
413 | 415 |
|
414 | 416 | OE_NOTICE << "map extent: " << height << " camera distance: " << distance << std::endl;
|
|
0 commit comments