Advertisement
Guest User

Untitled

a guest
May 14th, 2012
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.06 KB | None | 0 0
  1. bool SphericalProjection::screenCoordinates( const GeoDataCoordinates &coordinates,
  2. const ViewportParams *viewport,
  3. qreal &x, qreal &y, bool &globeHidesPoint ) const
  4. {
  5. qDebug() << "SphericalProjection::screenCoordinates() lat: " << coordinates.latitude() << " lon: " << coordinates.longitude() << " type: " << coordinates.getType();
  6. qreal absoluteAltitude = coordinates.altitude() + EARTH_RADIUS;
  7. Quaternion qpos = coordinates.quaternion();
  8.  
  9. //if (coordinates.getType())
  10. // viewport->setClock(coordinates.getClock());
  11. qpos.rotateAroundAxis( *( viewport->planetAxisMatrix(coordinates.getType() ) ));
  12.  
  13. qreal pixelAltitude = ( ( viewport->radius() )
  14. / EARTH_RADIUS * absoluteAltitude );
  15. if ( coordinates.altitude() < 10000 ) {
  16. // Skip placemarks at the other side of the earth.
  17. if ( qpos.v[Q_Z] < 0 ) {
  18. globeHidesPoint = true;
  19. return false;
  20. }
  21. }
  22. else {
  23. qreal earthCenteredX = pixelAltitude * qpos.v[Q_X];
  24. qreal earthCenteredY = pixelAltitude * qpos.v[Q_Y];
  25. qreal radius = viewport->radius();
  26.  
  27. // Don't draw high placemarks (e.g. satellites) that aren't visible.
  28. if ( qpos.v[Q_Z] < 0
  29. && ( ( earthCenteredX * earthCenteredX
  30. + earthCenteredY * earthCenteredY )
  31. < radius * radius ) ) {
  32. globeHidesPoint = true;
  33. return false;
  34. }
  35. }
  36.  
  37. // Let (x, y) be the position on the screen of the placemark..
  38. x = ((qreal)(viewport->width()) / 2 + pixelAltitude * qpos.v[Q_X]);
  39. y = ((qreal)(viewport->height()) / 2 - pixelAltitude * qpos.v[Q_Y]);
  40.  
  41. // Skip placemarks that are outside the screen area
  42. if ( x < 0 || x >= viewport->width() || y < 0 || y >= viewport->height() ) {
  43. globeHidesPoint = false;
  44. return false;
  45. }
  46.  
  47. globeHidesPoint = false;
  48. return true;
  49. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement