当前位置: 首页>>代码示例>>C++>>正文


C++ GeoPoint::fromWorld方法代码示例

本文整理汇总了C++中GeoPoint::fromWorld方法的典型用法代码示例。如果您正苦于以下问题:C++ GeoPoint::fromWorld方法的具体用法?C++ GeoPoint::fromWorld怎么用?C++ GeoPoint::fromWorld使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在GeoPoint的用法示例。


在下文中一共展示了GeoPoint::fromWorld方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: getNodeCenter

void 
LineOfSightTether::operator()(osg::Node* node, osg::NodeVisitor* nv)
{
    if (nv->getVisitorType() == osg::NodeVisitor::UPDATE_VISITOR)
    {
        LinearLineOfSightNode* los = static_cast<LinearLineOfSightNode*>(node);

        if ( los->getMapNode() )
        {
            if (_startNode.valid())
            {
                osg::Vec3d worldStart = getNodeCenter(_startNode);

                //Convert to mappoint since that is what LOS expects
                GeoPoint mapStart;
                mapStart.fromWorld( los->getMapNode()->getMapSRS(), worldStart );
                los->setStart( mapStart ); //.vec3d() );
            }

            if (_endNode.valid())
            {
                osg::Vec3d worldEnd = getNodeCenter( _endNode );

                //Convert to mappoint since that is what LOS expects
                GeoPoint mapEnd;
                mapEnd.fromWorld( los->getMapNode()->getMapSRS(), worldEnd );
                los->setEnd( mapEnd ); //.vec3d() );
            }
        }
    }
    traverse(node, nv);
}
开发者ID:2php,项目名称:osgearth,代码行数:32,代码来源:LinearLineOfSight.cpp

示例2:

void
LineOfSightEditor::updateDraggers()
{
    osg::Vec3d start = _los->getStartWorld();           
    GeoPoint startMap;
    startMap.fromWorld(_los->getMapNode()->getMapSRS(), start);
    _startDragger->setPosition( startMap, false );

    osg::Vec3d end = _los->getEndWorld();           
    GeoPoint endMap;
    endMap.fromWorld(_los->getMapNode()->getMapSRS(), end);    
    _endDragger->setPosition( endMap, false );
}
开发者ID:mysticbob,项目名称:osgearth,代码行数:13,代码来源:LineOfSight.cpp

示例3: traverse

void ElevationLOD::traverse( osg::NodeVisitor& nv)
{
    if (nv.getVisitorType() ==  osg::NodeVisitor::CULL_VISITOR)
    {
        osgUtil::CullVisitor* cv = static_cast<osgUtil::CullVisitor*>( &nv );
        osg::Vec3d eye, center, up;        
        eye = cv->getViewPoint();

        float height = eye.z();
        if (_srs)
        {
            GeoPoint mapPoint;
            mapPoint.fromWorld( _srs, eye );        
            height = mapPoint.z();
        }

        //OE_NOTICE << "Height " << height << std::endl;

        if (height >= _minElevation && height <= _maxElevation)
        {
            osg::Group::traverse( nv );
        }
        else
        {
            //OE_NOTICE << "Elevation " << height << " outside of range " << _minElevation << " to " << _maxElevation << std::endl;
        }
    }
    else
    {
        osg::Group::traverse( nv );
    }
}
开发者ID:JohnDr,项目名称:osgearth,代码行数:32,代码来源:ElevationLOD.cpp

示例4: handle

      bool handle( const osgGA::GUIEventAdapter& ea, osgGA::GUIActionAdapter& aa )
      {
          if (ea.getEventType() == ea.PUSH && ea.getButton() == osgGA::GUIEventAdapter::LEFT_MOUSE_BUTTON)
          {
              osg::Vec3d world;
              if ( _mapNode->getTerrain()->getWorldCoordsUnderMouse( aa.asView(), ea.getX(), ea.getY(), world ))
              {
                  GeoPoint mapPoint;
                  mapPoint.fromWorld( _mapNode->getMapSRS(), world );
                  //_mapNode->getMap()->worldPointToMapPoint( world, mapPoint );

                  if (!_startValid)
                  {
                      _startValid = true;
                      _start = mapPoint.vec3d();
                      if (_featureNode.valid())
                      {
                          _root->removeChild( _featureNode.get() );
                          _featureNode = 0;
                      }
                  }
                  else
                  {
                      _end = mapPoint.vec3d();
                      compute();
                      _startValid = false;                    
                  }
              }        
          }
          return false;
      }
开发者ID:JohnDr,项目名称:osgearth,代码行数:31,代码来源:osgearth_terrainprofile.cpp

示例5:

bool
AddPointHandler::addPoint( float x, float y, osgViewer::View* view )
{
    osg::Vec3d world;    
    MapNode* mapNode = _featureNode->getMapNode();

    if ( mapNode->getTerrain()->getWorldCoordsUnderMouse( view, x, y, world ) )
    {
        // Get the map point from the world
        GeoPoint mapPoint;
        mapPoint.fromWorld( mapNode->getMapSRS(), world );

        Feature* feature = _featureNode->getFeature();

        if ( feature )            
        {
            // Convert the map point to the feature's SRS
            GeoPoint featurePoint = mapPoint.transform( feature->getSRS() );

            feature->getGeometry()->push_back( featurePoint.vec3d() );            
            _featureNode->init();            
            return true;
        }        
    }
    return false;
}
开发者ID:Brucezhou1979,项目名称:osgearth,代码行数:26,代码来源:FeatureEditing.cpp

示例6: traverse

void ElevationLOD::traverse( osg::NodeVisitor& nv)
{
    if (nv.getVisitorType()   == osg::NodeVisitor::CULL_VISITOR &&
        nv.getTraversalMode() == osg::NodeVisitor::TRAVERSE_ACTIVE_CHILDREN )
    {
        bool rangeOK     = true;
        bool altitudeOK  = true;

        // first test the range:
        if ( _minRange.isSet() || _maxRange.isSet() )
        {
            float range = nv.getDistanceToViewPoint( getBound().center(), true );
            rangeOK =
                (!_minRange.isSet() || (range >= *_minRange)) &&
                (!_maxRange.isSet() || (range <= *_maxRange));
        }

        if ( rangeOK )
        {
            if ( _minElevation.isSet() || _maxElevation.isSet() )
            {
                double alt;

                // first see if we have a precalculated elevation:
                osgUtil::CullVisitor* cv = Culling::asCullVisitor(nv);

                osg::Vec3d eye = cv->getViewPoint();

                if ( _srs && !_srs->isProjected() )
                {
                    GeoPoint mapPoint;
                    mapPoint.fromWorld( _srs.get(), eye );
                    alt = mapPoint.z();
                }
                else
                {
                    alt = eye.z();
                }

                // account for the LOD scale
                alt *= cv->getLODScale();

                altitudeOK =
                    (!_minElevation.isSet() || (alt >= *_minElevation)) &&
                    (!_maxElevation.isSet() || (alt <= *_maxElevation));
            }

            if ( altitudeOK )
            {
                std::for_each(_children.begin(),_children.end(),osg::NodeAcceptOp(nv));
            }
        }
    }
    else
    {
        osg::Group::traverse( nv );
    }
}
开发者ID:2php,项目名称:osgearth,代码行数:58,代码来源:ElevationLOD.cpp

示例7: mouseReleaseEvent

void TerrainProfileGraph::mouseReleaseEvent(QMouseEvent* e)
{
  if (_selecting)
  {
    double selectEnd = mapToScene(e->pos()).x();

    double zoomStart = osg::minimum(_selectStart, selectEnd);
    double zoomEnd = osg::maximum(_selectStart, selectEnd);

    double startDistanceFactor = ((zoomStart - _graphField.x()) / (double)_graphField.width());
    double endDistanceFactor = ((zoomEnd - _graphField.x()) / (double)_graphField.width());

    osg::Vec3d worldStart, worldEnd;
    _calculator->getStart(ALTMODE_ABSOLUTE).toWorld(worldStart);
    _calculator->getEnd(ALTMODE_ABSOLUTE).toWorld(worldEnd);

    double newStartWorldX = (worldEnd.x() - worldStart.x()) * startDistanceFactor + worldStart.x();
    double newStartWorldY = (worldEnd.y() - worldStart.y()) * startDistanceFactor + worldStart.y();
    double newStartWorldZ = (worldEnd.z() - worldStart.z()) * startDistanceFactor + worldStart.z();

    GeoPoint newStart;
    newStart.fromWorld(_calculator->getStart().getSRS(), osg::Vec3d(newStartWorldX, newStartWorldY, newStartWorldZ));
    newStart.z() = 0.0;

    double newEndWorldX = (worldEnd.x() - worldStart.x()) * endDistanceFactor + worldStart.x();
    double newEndWorldY = (worldEnd.y() - worldStart.y()) * endDistanceFactor + worldStart.y();
    double newEndtWorldZ = (worldEnd.z() - worldStart.z()) * endDistanceFactor + worldStart.z();

    GeoPoint newEnd;
    newEnd.fromWorld(_calculator->getStart().getSRS(), osg::Vec3d(newEndWorldX, newEndWorldY, newEndtWorldZ));
    newEnd.z() = 0.0;

    if (osg::absolute(newEnd.x() - newStart.x()) > 0.001 || osg::absolute(newEnd.y() - newStart.y()) > 0.001)
    {
      _calculator->setStartEnd(newStart, newEnd);
    }
    else
    {
      _selecting = false;
      drawHoverCursor(mapToScene(e->pos()));
    }
  }

  _selecting = false;
}
开发者ID:2php,项目名称:osgearth,代码行数:45,代码来源:TerrainProfileGraph.cpp

示例8: update

    void update( float x, float y, osgViewer::View* view )
    {
        bool yes = false;

        // look under the mouse:
        osg::Vec3d world;
        osgUtil::LineSegmentIntersector::Intersections hits;
        if ( view->computeIntersections(x, y, hits) )
        {
            world = hits.begin()->getWorldIntersectPoint();

            // convert to map coords:
            GeoPoint mapPoint;
            mapPoint.fromWorld( s_mapNode->getMapSRS(), world );

            // Depending on the level of detail key you request, you will get a mesh that should line up exactly with the highest resolution mesh that the terrain engine will draw.
            // At level 15 that is a 257x257 heightfield.  If you select a higher lod, the mesh will be less dense.
            TileKey key = s_mapNode->getMap()->getProfile()->createTileKey(mapPoint.x(), mapPoint.y(), 15);
            OE_NOTICE << "Creating tile " << key.str() << std::endl;
            osg::ref_ptr<osg::Node> node = s_mapNode->getTerrainEngine()->createTile(key);
            if (node.valid())
            {
                // Extract the triangles from the node that was created and do our own rendering.  Simulates what you would do when passing in the triangles to a physics engine.
                OE_NOTICE << "Created tile for " << key.str() << std::endl;
                CollectTrianglesVisitor v;
                node->accept(v);
                node = v.buildNode();

                if (_node.valid())
                {
                    s_root->removeChild( _node.get() );
                }

                osg::Group* group = new osg::Group;

                // Show the actual mesh.
                group->addChild( node.get() );

                _node = group;

                // Clamp the marker to the intersection of the triangles created by osgEarth.  This should line up with the mesh that is actually rendered.
                double z = 0.0;
                s_mapNode->getTerrain()->getHeight( node, s_mapNode->getMapSRS(), mapPoint.x(), mapPoint.y(), &z);

                GeoTransform* xform = new GeoTransform();
                xform->setPosition( osgEarth::GeoPoint(s_mapNode->getMapSRS(),mapPoint.x(),  mapPoint.y(), z, ALTMODE_ABSOLUTE) );
                xform->addChild( marker.get() );
                group->addChild( xform );

                s_root->addChild( _node.get() );
            }
            else
            {
                OE_NOTICE << "Failed to create tile for " << key.str() << std::endl;
            }
        }
    }
开发者ID:njuliujl,项目名称:osgearth,代码行数:57,代码来源:osgearth_createtile.cpp

示例9: clampToLeft

void ClipSpace::clampToLeft(GeoPoint& p)
{
    p.transformInPlace(p.getSRS()->getGeographicSRS());
    osg::Vec3d world;
    p.toWorld(world);
    osg::Vec3d clip = world * _worldToClip;
    clip.x() = -1.0;
    world = clip * _clipToWorld;
    p.fromWorld(p.getSRS(), world);
}
开发者ID:emminizer,项目名称:osgearth,代码行数:10,代码来源:ClipSpace.cpp

示例10: update

    void update( float x, float y, osgViewer::View* view )
    {
        bool yes = false;

        // look under the mouse:
        osg::Vec3d world;
        if ( _terrain->getWorldCoordsUnderMouse(view, x, y, world) )
        {
            // convert to map coords:
            GeoPoint mapPoint;
            mapPoint.fromWorld( _terrain->getSRS(), world );

            // do an elevation query:
            double query_resolution = 0.1; // 1/10th of a degree
            double out_hamsl        = 0.0;
            double out_resolution   = 0.0;

            bool ok = _query.getElevation( 
                mapPoint,
                out_hamsl,
                query_resolution, 
                &out_resolution );

            if ( ok )
            {
                // convert to geodetic to get the HAE:
                mapPoint.z() = out_hamsl;
                GeoPoint mapPointGeodetic( s_mapNode->getMapSRS()->getGeodeticSRS(), mapPoint );

                static LatLongFormatter s_f;

                s_posLabel->setText( Stringify()
                    << std::fixed << std::setprecision(2) 
                    << s_f.format(mapPointGeodetic.y())
                    << ", " 
                    << s_f.format(mapPointGeodetic.x()) );

                s_mslLabel->setText( Stringify() << out_hamsl );
                s_haeLabel->setText( Stringify() << mapPointGeodetic.z() );
                s_resLabel->setText( Stringify() << out_resolution );
                yes = true;
            }
        }

        if (!yes)
        {
            s_posLabel->setText( "-" );
            s_mslLabel->setText( "-" );
            s_haeLabel->setText( "-" );
            s_resLabel->setText( "-" );
        }
    }
开发者ID:APerennec,项目名称:osgearth,代码行数:52,代码来源:osgearth_elevation.cpp

示例11: handle

 bool handle(const osgGA::GUIEventAdapter& ea, osgGA::GUIActionAdapter& aa, osg::Object*, osg::NodeVisitor*)
 {
     if (ea.getEventType() == ea.KEYDOWN && ea.getKey() == _c)
     {
         osg::Vec3d world;
         _mapNode->getTerrain()->getWorldCoordsUnderMouse(aa.asView(), ea.getX(), ea.getY(), world);
         GeoPoint coords;
         coords.fromWorld(s_activeMap->getSRS(), world);
         osg::ref_ptr<ElevationEnvelope> env = s_activeMap->getElevationPool()->createEnvelope(s_activeMap->getSRS(), 23u);
         float ep_elev = env->getElevation(coords.x(), coords.y());
         OE_NOTICE << "Elevations under mouse. EP=" << ep_elev << "\n";
     }
     return false;
 }
开发者ID:XenonofArcticus,项目名称:osgearth,代码行数:14,代码来源:osgearth_toc.cpp

示例12: update

  void update(double time)
  {
    double angle = (time / _time);
    angle = (angle - (int)angle) * osg::PI * 2.0;

    osg::Quat quat(angle, _up );
    osg::Vec3d spoke = quat * (_side * _radius);
    osg::Vec3d end = _center + spoke;

    GeoPoint mapPos;
    mapPos.fromWorld( _mapNode->getMapSRS(), end );
    //_mapNode->getMap()->worldPointToMapPoint(end, mapPos);

    _track->setPosition(mapPos);
  }
开发者ID:KNeal,项目名称:osgearth,代码行数:15,代码来源:osgearth_qt.cpp

示例13: getNodeCenter

void 
RadialLineOfSightTether::operator()(osg::Node* node, osg::NodeVisitor* nv)
{
    if (nv->getVisitorType() == osg::NodeVisitor::UPDATE_VISITOR)
    {
        RadialLineOfSightNode* los = static_cast<RadialLineOfSightNode*>(node);

        osg::Vec3d worldCenter = getNodeCenter( _node );

        //Convert center to mappoint since that is what LOS expects
        GeoPoint mapCenter;
        mapCenter.fromWorld( los->getMapNode()->getMapSRS(), worldCenter );
        //los->getMapNode()->getMap()->worldPointToMapPoint( worldCenter, mapCenter );

        los->setCenter( mapCenter.vec3d() );      
    }
    traverse(node, nv);
}
开发者ID:formusic,项目名称:osgearth,代码行数:18,代码来源:RadialLineOfSight.cpp

示例14:

bool
Feature::getWorldBoundingPolytope(const SpatialReference* srs,
                                  osg::Polytope&          out_polytope) const
{
    osg::BoundingSphered bs;
    if ( getWorldBound(srs, bs) && bs.valid() )
    {
        out_polytope.clear();

        // add planes for the four sides of the BS. Normals point inwards.
        out_polytope.add( osg::Plane(osg::Vec3d( 1, 0,0), osg::Vec3d(-bs.radius(),0,0)) );
        out_polytope.add( osg::Plane(osg::Vec3d(-1, 0,0), osg::Vec3d( bs.radius(),0,0)) );
        out_polytope.add( osg::Plane(osg::Vec3d( 0, 1,0), osg::Vec3d(0, -bs.radius(),0)) );
        out_polytope.add( osg::Plane(osg::Vec3d( 0,-1,0), osg::Vec3d(0,  bs.radius(),0)) );

        // for a projected feature, we're done. For a geocentric one, transform the polytope
        // into world (ECEF) space.
        if ( srs->isGeographic() && !srs->isPlateCarre() )
        {
            const osg::EllipsoidModel* e = srs->getEllipsoid();

            // add a bottom cap, unless the bounds are sufficiently large.
            double minRad = std::min(e->getRadiusPolar(), e->getRadiusEquator());
            double maxRad = std::max(e->getRadiusPolar(), e->getRadiusEquator());
            double zeroOffset = bs.center().length();
            if ( zeroOffset > minRad * 0.1 )
            {
                out_polytope.add( osg::Plane(osg::Vec3d(0,0,1), osg::Vec3d(0,0,-maxRad+zeroOffset)) );
            }
        }

        // transform the clipping planes ito ECEF space
        GeoPoint refPoint;
        refPoint.fromWorld( srs, bs.center() );

        osg::Matrix local2world;
        refPoint.createLocalToWorld( local2world );

        out_polytope.transform( local2world );

        return true;
    }
    return false;
}
开发者ID:DavidLeehome,项目名称:osgearth,代码行数:44,代码来源:Feature.cpp

示例15: iv

bool
MouseCoordsTool::handle( const osgGA::GUIEventAdapter& ea, osgGA::GUIActionAdapter& aa )
{
    if (ea.getEventType() == ea.MOVE || ea.getEventType() == ea.DRAG)
    {
        osg::Vec3d world;
        if ( _mapNode->getTerrain()->getWorldCoordsUnderMouse(aa.asView(), ea.getX(), ea.getY(), world) )
        {
            GeoPoint map;
            map.fromWorld( _mapNode->getMapSRS(), world );

            for( Callbacks::iterator i = _callbacks.begin(); i != _callbacks.end(); ++i )
                i->get()->set( map, aa.asView(), _mapNode );
        }
        else
        {
            for( Callbacks::iterator i = _callbacks.begin(); i != _callbacks.end(); ++i )
                i->get()->reset( aa.asView(), _mapNode );
        }

#if 1 // testing AGL, Dist to Point
        osg::Vec3d eye, center, up;
        aa.asView()->getCamera()->getViewMatrixAsLookAt(eye, center, up);
        DPLineSegmentIntersector* lsi = new DPLineSegmentIntersector(eye, osg::Vec3d(0,0,0));
        osgUtil::IntersectionVisitor iv(lsi);
        lsi->setIntersectionLimit(lsi->LIMIT_NEAREST);
        //iv.setUserData( new Map() );
        _mapNode->accept(iv);

        if ( !lsi->getIntersections().empty() )
        {            
            double agl = (eye - lsi->getFirstIntersection().getWorldIntersectPoint()).length();
            double dtp = (eye - world).length();
            //OE_NOTICE << "AGL = " << agl << "m; DPT = " << dtp << "m" << std::endl;
            Registry::instance()->startActivity("AGL", Stringify() << agl << " m");
            Registry::instance()->startActivity("Range", Stringify() << dtp << " m");
        }
#endif
    }

    return false;
}
开发者ID:ldelgass,项目名称:osgearth,代码行数:42,代码来源:MouseCoordsTool.cpp


注:本文中的GeoPoint::fromWorld方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。