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


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

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


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

示例1: getMapNode

void
PolyhedralLineOfSightNode::recalculateExtent()
{
    // get a local2world matrix for the map position:
    GeoPoint absMapPos = _mapPosition;
    absMapPos.makeAbsolute( getMapNode()->getTerrain() );
    osg::Matrix local2world;
    absMapPos.createLocalToWorld( local2world );

    // local offsets (east and north)
    osg::Vec3d x( _distance.as(Units::METERS), 0.0, 0.0 );
    osg::Vec3d y( 0.0, _distance.as(Units::METERS), 0.0 );

    // convert these to map coords:
    GeoPoint easting, northing;
    easting.fromWorld( getMapNode()->getMapSRS(), x * local2world );
    northing.fromWorld( getMapNode()->getMapSRS(), y * local2world );

    // calculate the offsets:
    double d_easting = easting.x() - absMapPos.x();
    double d_northing = northing.y() - absMapPos.y();

    // update the extent.
    _extent = GeoExtent(
        getMapNode()->getMapSRS(),
        absMapPos.x() - d_easting, absMapPos.y() - d_northing,
        absMapPos.x() + d_easting, absMapPos.y() + d_northing );

    OE_INFO << LC << "Cached extent = " << _extent.toString() << std::endl;
}
开发者ID:Brucezhou1979,项目名称:osgearth,代码行数:30,代码来源:PolyhedralLineOfSight.cpp

示例2: iv

void
PolyhedralLineOfSightNode::updateSamples()
{
    if ( _geode->getNumDrawables() == 0 )
        rebuildGeometry();

    osg::Geometry* geom  = _geode->getDrawable(0)->asGeometry();
    osg::Vec3Array* verts = dynamic_cast<osg::Vec3Array*>( geom->getVertexArray() );

    double distance = _distance.as(Units::METERS);

    // get the world coords and a l2w transform for the origin:
    osg::Vec3d  originWorld;
    osg::Matrix local2world, world2local;

    Terrain* t = getMapNode()->getTerrain();
    GeoPoint origin = getPosition();
    origin.makeAbsolute( t );
    origin.toWorld( originWorld, t );
    origin.createLocalToWorld( local2world );
    world2local.invert( local2world );

    // set up an intersector:
    osgUtil::LineSegmentIntersector* lsi = new osgUtil::LineSegmentIntersector( originWorld, originWorld );
    osgUtil::IntersectionVisitor iv( lsi );

    // intersect the verts (skip the origin point) with the map node.
    for( osg::Vec3Array::iterator v = verts->begin()+1; v != verts->end(); ++v )
    {
        osg::Vec3d unit = *v;
        unit.normalize();
        unit *= distance;

        osg::Vec3d world = unit * local2world;

        if ( osg::equivalent(unit.length(), 0.0) )
        {
            OE_WARN << "problem." << std::endl;
        }

        lsi->reset();
        lsi->setStart( originWorld );
        lsi->setEnd( world );

        OE_DEBUG << LC << "Ray: " <<
            originWorld.x() << "," << originWorld.y() << "," << originWorld.z() << " => "
            << world.x() << "," << world.y() << "," << world.z()
            << std::endl;


        getMapNode()->getTerrain()->accept( iv );

        osgUtil::LineSegmentIntersector::Intersections& hits = lsi->getIntersections();
        if ( !hits.empty() )
        {
            const osgUtil::LineSegmentIntersector::Intersection& hit = *hits.begin();
            osg::Vec3d newV = hit.getWorldIntersectPoint() * world2local;
            if ( newV.length() > 1.0 )
                *v = newV;
            else
                *v = unit;
        }
        else
        {
            *v = unit;
        }

        //OE_NOTICE << "Radial point = " << v->x() << ", " << v->y() << ", " << v->z() << std::endl;
    }

    verts->dirty();
    geom->dirtyBound();
}
开发者ID:Brucezhou1979,项目名称:osgearth,代码行数:73,代码来源:PolyhedralLineOfSight.cpp

示例3:

bool
GeoTransform::setPosition(const GeoPoint& position)
{
    if ( !position.isValid() )
        return false;

    _position = position;

    // relative Z or reprojection require a terrain:
    osg::ref_ptr<Terrain> terrain;
    _terrain.lock(terrain);

    // relative Z requires a terrain:
    if (position.altitudeMode() == ALTMODE_RELATIVE && !terrain.valid())
    {
        OE_TEST << LC << "setPosition failed condition 1\n";
        return false;
    }

    GeoPoint p;

    // transform into terrain SRS if neccesary:
    if (terrain.valid() && !terrain->getSRS()->isEquivalentTo(position.getSRS()))
        p = position.transform(terrain->getSRS());
    else
        p = position;

    // bail if the transformation failed:
    if ( !p.isValid() )
    {
        OE_TEST << LC << "setPosition failed condition 2\n";
        return false;
    }

    // convert to absolute height:
    if ( !p.makeAbsolute(_terrain.get()) )
    {
        OE_TEST << LC << "setPosition failed condition 3\n";
        return false;
    }

    // assemble the matrix:
    osg::Matrixd local2world;
    p.createLocalToWorld( local2world );
    this->setMatrix( local2world );

    // install auto-recompute?
    if (_autoRecompute &&
        _position.altitudeMode() == ALTMODE_RELATIVE &&
        !_autoRecomputeReady)
    {
        // by using the adapter, there's no need to remove
        // the callback then this object destructs.
        terrain->addTerrainCallback(
           new TerrainCallbackAdapter<GeoTransform>(this) );

        _autoRecomputeReady = true;
    }

    return true;
}
开发者ID:469447793,项目名称:osgearth,代码行数:61,代码来源:GeoTransform.cpp


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