Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- bool SphericalProjection::screenCoordinates( const GeoDataCoordinates &coordinates,
- const ViewportParams *viewport,
- qreal &x, qreal &y, bool &globeHidesPoint ) const
- {
- qDebug() << "SphericalProjection::screenCoordinates() lat: " << coordinates.latitude() << " lon: " << coordinates.longitude() << " type: " << coordinates.getType();
- qreal absoluteAltitude = coordinates.altitude() + EARTH_RADIUS;
- Quaternion qpos = coordinates.quaternion();
- //if (coordinates.getType())
- // viewport->setClock(coordinates.getClock());
- qpos.rotateAroundAxis( *( viewport->planetAxisMatrix(coordinates.getType() ) ));
- qreal pixelAltitude = ( ( viewport->radius() )
- / EARTH_RADIUS * absoluteAltitude );
- if ( coordinates.altitude() < 10000 ) {
- // Skip placemarks at the other side of the earth.
- if ( qpos.v[Q_Z] < 0 ) {
- globeHidesPoint = true;
- return false;
- }
- }
- else {
- qreal earthCenteredX = pixelAltitude * qpos.v[Q_X];
- qreal earthCenteredY = pixelAltitude * qpos.v[Q_Y];
- qreal radius = viewport->radius();
- // Don't draw high placemarks (e.g. satellites) that aren't visible.
- if ( qpos.v[Q_Z] < 0
- && ( ( earthCenteredX * earthCenteredX
- + earthCenteredY * earthCenteredY )
- < radius * radius ) ) {
- globeHidesPoint = true;
- return false;
- }
- }
- // Let (x, y) be the position on the screen of the placemark..
- x = ((qreal)(viewport->width()) / 2 + pixelAltitude * qpos.v[Q_X]);
- y = ((qreal)(viewport->height()) / 2 - pixelAltitude * qpos.v[Q_Y]);
- // Skip placemarks that are outside the screen area
- if ( x < 0 || x >= viewport->width() || y < 0 || y >= viewport->height() ) {
- globeHidesPoint = false;
- return false;
- }
- globeHidesPoint = false;
- return true;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement