Пример #1
0
void SceneController::setBounds(const osgEarth::GeoPoint& p1, const osgEarth::GeoPoint& p2)
{
  _boundsLL.set(osg::minimum(p1.x(), p2.x()), osg::minimum(p1.y(), p2.y()));
  _boundsUR.set(osg::maximum(p1.x(), p2.x()), osg::maximum(p1.y(), p2.y()));

  if (_annoRoot.valid())
  {
    //TODO: use correct coords here
    osgEarth::Symbology::Geometry* geom = new osgEarth::Symbology::Polygon();
    geom->push_back(_boundsLL.x(), _boundsLL.y());
    geom->push_back(_boundsUR.x(), _boundsLL.y());
    geom->push_back(_boundsUR.x(), _boundsUR.y());
    geom->push_back(_boundsLL.x(), _boundsUR.y());

    osgEarth::Features::Feature* feature = new osgEarth::Features::Feature(geom, _mapNode->getMapSRS()->getGeographicSRS(), _boundsStyle);

    if (!_bboxNode.valid())
    {
      _bboxNode = new osgEarth::Annotation::FeatureNode(_mapNode, feature);
      _bboxNode->getOrCreateStateSet()->setMode(GL_LIGHTING, osg::StateAttribute::OFF);
      _annoRoot->addChild( _bboxNode.get() );
    }
    else
    {
      _bboxNode->setFeature(feature);
    }
  }
}
Пример #2
0
      virtual void onPositionChanged(const Dragger* sender, const osgEarth::GeoPoint& position)
      {
          const osg::EllipsoidModel* em = _node->getMapNode()->getMapSRS()->getEllipsoid();

          //Figure out the distance between the center of the circle and this new location
          GeoPoint center = _node->getPosition();

          double distance = GeoMath::distance(osg::DegreesToRadians( center.y() ), osg::DegreesToRadians( center.x() ), 
                                              osg::DegreesToRadians( position.y() ), osg::DegreesToRadians( position.x() ),
                                              em->getRadiusEquator());

          double bearing = GeoMath::bearing(osg::DegreesToRadians( center.y() ), osg::DegreesToRadians( center.x() ), 
                                            osg::DegreesToRadians( position.y() ), osg::DegreesToRadians( position.x() ));
        

          //Compute the new angular rotation based on how they moved the point
          if (_major)
          {
              _node->setRotationAngle( Angle( bearing-osg::PI_2, Units::RADIANS ) );
              _node->setRadiusMajor( Distance(distance, Units::METERS ) );
          }
          else // minor
          {
              _node->setRotationAngle( Angle( bearing, Units::RADIANS ) );
              _node->setRadiusMinor( Distance(distance, Units::METERS ) );
          }
          _editor->updateDraggers();
     }
Пример #3
0
 virtual void onPositionChanged(const Dragger* sender, const osgEarth::GeoPoint& position)
 {
     (*_featureNode->getFeature()->getGeometry())[_point] =  osg::Vec3d(position.x(), position.y(), 0);
     _featureNode->init();
 }