void EllipseNodeEditor::updateDraggers() { LocalizedNodeEditor::updateDraggers(); if (_majorDragger && _minorDragger) { const osg::EllipsoidModel* em = _node->getMapNode()->getMap()->getProfile()->getSRS()->getEllipsoid(); //Get the current location of the center of the circle GeoPoint location = _node->getPosition(); //Get the raddi of the ellipse in meters EllipseNode* ellipse = static_cast<EllipseNode*>(_node.get()); double majorR = ellipse->getRadiusMajor().as(Units::METERS); double minorR = ellipse->getRadiusMinor().as(Units::METERS); double rotation = ellipse->getRotationAngle().as( Units::RADIANS ); double lat, lon; GeoMath::destination(osg::DegreesToRadians( location.y() ), osg::DegreesToRadians( location.x() ), osg::PI_2 - rotation, minorR, lat, lon, em->getRadiusEquator()); _minorDragger->setPosition( GeoPoint(location.getSRS(), osg::RadiansToDegrees( lon ), osg::RadiansToDegrees( lat ), 0, ALTMODE_ABSOLUTE), false); GeoMath::destination(osg::DegreesToRadians( location.y() ), osg::DegreesToRadians( location.x() ), -rotation, majorR, lat, lon, em->getRadiusEquator()); _majorDragger->setPosition( GeoPoint(location.getSRS(), osg::RadiansToDegrees( lon ), osg::RadiansToDegrees( lat ), 0, ALTMODE_ABSOLUTE), false); } }
void EllipseNodeEditor::updateDraggers() { LocalizedNodeEditor::updateDraggers(); if (_majorDragger && _minorDragger) { const osg::EllipsoidModel* em = _node->getMapNode()->getMap()->getProfile()->getSRS()->getEllipsoid(); //Get the current location of the center of the circle GeoPoint location = _node->getPosition(); //Get the raddi of the ellipse in meters EllipseNode* ellipse = static_cast<EllipseNode*>(_node.get()); double majorR = ellipse->getRadiusMajor().as(Units::METERS); double minorR = ellipse->getRadiusMinor().as(Units::METERS); double rotation = ellipse->getRotationAngle().as( Units::RADIANS ); double latRad, lonRad; // minor dragger: end of the rotated +Y axis: GeoMath::destination( osg::DegreesToRadians( location.y() ), osg::DegreesToRadians( location.x() ), rotation, minorR, latRad, lonRad, em->getRadiusEquator()); GeoPoint minorLocation(location.getSRS(), osg::RadiansToDegrees( lonRad ), osg::RadiansToDegrees( latRad )); minorLocation.z() = 0; _minorDragger->setPosition( minorLocation, false ); // major dragger: end of the rotated +X axis GeoMath::destination( osg::DegreesToRadians( location.y() ), osg::DegreesToRadians( location.x() ), rotation + osg::PI_2, majorR, latRad, lonRad, em->getRadiusEquator()); GeoPoint majorLocation(location.getSRS(), osg::RadiansToDegrees( lonRad ), osg::RadiansToDegrees( latRad )); majorLocation.z() = 0; _majorDragger->setPosition( majorLocation, false); } }