本文整理汇总了C++中GeoPoint::x方法的典型用法代码示例。如果您正苦于以下问题:C++ GeoPoint::x方法的具体用法?C++ GeoPoint::x怎么用?C++ GeoPoint::x使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类GeoPoint
的用法示例。
在下文中一共展示了GeoPoint::x方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: getPosition
void
PolyhedralLineOfSightNode::recalculateExtent()
{
// get a local2world matrix for the map position:
GeoPoint absMapPos = getPosition();
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;
}
示例2: 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;
}
}
}
示例3: ScreenSpaceLayoutData
void
LabelNode::updateLayoutData()
{
if (!_dataLayout.valid())
{
_dataLayout = new ScreenSpaceLayoutData();
}
// re-apply annotation drawable-level stuff as neccesary.
for (unsigned i = 0; i < _geode->getNumChildren(); ++i)
{
_geode->getChild(i)->setUserData(_dataLayout.get());
}
_dataLayout->setPriority(getPriority());
GeoPoint location = getPosition();
location.makeGeographic();
double latRad;
double longRad;
GeoMath::destination(osg::DegreesToRadians(location.y()),
osg::DegreesToRadians(location.x()),
_labelRotationRad,
2500.,
latRad,
longRad);
_geoPointProj.set(osgEarth::SpatialReference::get("wgs84"),
osg::RadiansToDegrees(longRad),
osg::RadiansToDegrees(latRad),
0,
osgEarth::ALTMODE_ABSOLUTE);
_geoPointLoc.set(osgEarth::SpatialReference::get("wgs84"),
//location.getSRS(),
location.x(),
location.y(),
0,
osgEarth::ALTMODE_ABSOLUTE);
const TextSymbol* ts = getStyle().get<TextSymbol>();
if (ts)
{
_dataLayout->setPixelOffset(ts->pixelOffset().get());
if (_followFixedCourse)
{
osg::Vec3d p0, p1;
_geoPointLoc.toWorld(p0);
_geoPointProj.toWorld(p1);
_dataLayout->setAnchorPoint(p0);
_dataLayout->setProjPoint(p1);
}
}
}
示例4: onPositionChanged
virtual void onPositionChanged(const Dragger* sender, const osgEarth::GeoPoint& position)
{
//Convert to lat/lon
GeoPoint p;
position.transform(SpatialReference::create( "epsg:4326"), p);
_overlay->setControlPoint(_controlPoint, p.x(), p.y(), _singleVert);
}
示例5: draggerLocation
void
CircleNodeEditor::updateDraggers()
{
LocalizedNodeEditor::updateDraggers();
if (_radiusDragger)
{
const osg::EllipsoidModel* em = _node->getMapNode()->getMapSRS()->getEllipsoid();
// Get the current location of the center of the circle (in lat/long, absolute Z)
GeoPoint location = _node->getPosition();
location.makeGeographic();
//location.makeAbsolute( _node->getMapNode()->getTerrain() );
//Get the radius of the circle in meters
double r = static_cast<CircleNode*>(_node.get())->getRadius().as(Units::METERS);
double lat, lon;
GeoMath::destination(
osg::DegreesToRadians( location.y() ), osg::DegreesToRadians( location.x() ),
_bearing, r, lat, lon, em->getRadiusEquator() );
GeoPoint draggerLocation(
location.getSRS(),
osg::RadiansToDegrees(lon),
osg::RadiansToDegrees(lat));
draggerLocation.z() = 0;
_radiusDragger->setPosition( draggerLocation, false );
}
}
示例6:
/* method: x of class GeoPoint */
static int tolua_Lua_ScriptEngine_tolua_GeoPoint_x00(lua_State* tolua_S)
{
#ifndef TOLUA_RELEASE
tolua_Error tolua_err;
if (
!tolua_isusertype(tolua_S,1,"GeoPoint",0,&tolua_err) ||
!tolua_isnoobj(tolua_S,2,&tolua_err)
)
goto tolua_lerror;
else
#endif
{
GeoPoint* self = (GeoPoint*) tolua_tousertype(tolua_S,1,0);
#ifndef TOLUA_RELEASE
if (!self) tolua_error(tolua_S,"invalid 'self' in function 'x'",NULL);
#endif
{
double tolua_ret = (double) self->x();
tolua_pushnumber(tolua_S,(double)tolua_ret);
}
}
return 1;
#ifndef TOLUA_RELEASE
tolua_lerror:
tolua_error(tolua_S,"#ferror in function 'x'.",&tolua_err);
return 0;
#endif
}
示例7: new_shape
FeatureList
BufferFilter::process( Feature* input, FilterEnv* env )
{
FeatureList output;
GeoShapeList& shapes = input->getShapes();
GeoShapeList new_shapes;
double b = getDistance();
if ( env->getInputSRS()->isGeographic() )
{
// for geo, convert from meters to degrees
//TODO: we SHOULD do this for each and every feature buffer segment, but
// for how this is a shortcut approximation.
double bc = b/1.4142;
osg::Vec2d vec( bc, bc ); //vec.normalize();
GeoPoint c = input->getExtent().getCentroid();
osg::Vec2d p0( c.x(), c.y() );
osg::Vec2d p1;
Units::convertLinearToAngularVector( vec, Units::METERS, Units::DEGREES, p0, p1 );
b = (p1-p0).length();
}
for( GeoShapeList::iterator i = shapes.begin(); i != shapes.end(); i++ )
{
GeoPartList new_parts;
GeoShape& shape = *i;
if ( shape.getShapeType() == GeoShape::TYPE_POLYGON )
{
GeoShape new_shape( GeoShape::TYPE_POLYGON, shape.getSRS() );
bufferPolygons( shape, b, new_shape.getParts() );
new_shapes.push_back( new_shape );
}
else if ( shape.getShapeType() == GeoShape::TYPE_LINE )
{
if ( getConvertToPolygon() )
{
GeoShape new_shape( GeoShape::TYPE_POLYGON, shape.getSRS() );
bufferLinesToPolygons( shape, b, new_shape );
new_shapes.push_back( new_shape );
}
else
{
GeoShape new_shape( GeoShape::TYPE_LINE, shape.getSRS() );
bufferLinesToLines( shape, b, new_shape );
new_shapes.push_back( new_shape );
}
}
}
if ( new_shapes.size() > 0 )
input->getShapes().swap( new_shapes );
output.push_back( input );
return output;
}
示例8: minorLocation
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);
}
}
示例9: 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;
}
示例10: visitPoint
bool visitPoint( GeoPoint& p )
{
bool ok = true;
// pull it out of the source reference frame:
p.set( p * src_rf );
// reproject it:
if ( handle )
ok = OCTTransform( handle, 1, &p.x(), &p.y(), &p.z() ) != 0;
// push it into the new reference frame:
p.set( p * to_srs->getReferenceFrame() );
p = p.getDim() == 2? GeoPoint( p.x(), p.y(), to_srs ) : GeoPoint( p.x(), p.y(), p.z(), to_srs );
return ok;
}
示例11: reclamp
void Dragger::reclamp( const TileKey& key, osg::Node* tile, const Terrain* terrain )
{
GeoPoint p;
_position.transform( key.getExtent().getSRS(), p );
// first verify that the control position intersects the tile:
if ( key.getExtent().contains( p.x(), p.y() ) )
{
updateTransform( tile );
}
}
示例12: isValid
bool
GeoPoint::operator == ( const GeoPoint& rhs ) const
{
return
isValid() && rhs.isValid() &&
SpatialReference::equivalent( getSRS(), rhs.getSRS() ) &&
getDim() == rhs.getDim() &&
x() == rhs.x() &&
(getDim() < 2 || y() == rhs.y()) &&
(getDim() < 3 || z() == rhs.z());
}
示例13:
void
CircleNodeEditor::computeBearing()
{
_bearing = osg::DegreesToRadians( 90.0 );
//Get the radius dragger's position
if (!_radiusDragger->getMatrix().isIdentity())
{
// Get the current location of the center of the circle (in lat/long)
GeoPoint location = _node->getPosition();
location.makeGeographic();
// location of the radius dragger (in lat/long)
GeoPoint radiusLocation;
radiusLocation.fromWorld( location.getSRS(), _radiusDragger->getMatrix().getTrans() );
// calculate the bearing b/w the
_bearing = GeoMath::bearing(
osg::DegreesToRadians(location.y()), osg::DegreesToRadians(location.x()),
osg::DegreesToRadians(radiusLocation.y()), osg::DegreesToRadians(radiusLocation.x()));
}
}
示例14: Stringify
std::string
LatLongFormatter::format( const GeoPoint& p ) const
{
GeoPoint geo = p;
if ( !geo.makeGeographic() )
return "";
return Stringify()
<< format( Angular(geo.y()) )
<< ", "
<< format( Angular(geo.x()) );
}
示例15: getPosition
void
RectangleNode::setLowerLeft( const GeoPoint& lowerLeft )
{
GeoPoint center = getPosition();
//Figure out the new width and height
double earthRadius = center.getSRS()->getEllipsoid()->getRadiusEquator();
double lat = osg::DegreesToRadians(center.y());
double lon = osg::DegreesToRadians(center.x());
double halfWidthMeters = _width.as(Units::METERS) / 2.0;
double halfHeightMeters = _height.as(Units::METERS) / 2.0;
double eastLon, eastLat;
double westLon, westLat;
double northLon, northLat;
double southLon, southLat;
//Get the current corners
GeoMath::destination( lat, lon, osg::DegreesToRadians( 90.0 ), halfWidthMeters, eastLat, eastLon, earthRadius );
GeoMath::destination( lat, lon, osg::DegreesToRadians( -90.0 ), halfWidthMeters, westLat, westLon, earthRadius );
GeoMath::destination( lat, lon, osg::DegreesToRadians( 0.0 ), halfHeightMeters, northLat, northLon, earthRadius );
GeoMath::destination( lat, lon, osg::DegreesToRadians( 180.0 ), halfHeightMeters, southLat, southLon, earthRadius );
if (osg::DegreesToRadians(lowerLeft.x()) < eastLon && osg::DegreesToRadians(lowerLeft.y()) < northLat)
{
westLon = osg::DegreesToRadians(lowerLeft.x());
southLat = osg::DegreesToRadians(lowerLeft.y());
double x = ( eastLon + westLon ) / 2.0;
double y = ( southLat + northLat) / 2.0;
setPosition(GeoPoint( center.getSRS(), osg::RadiansToDegrees(x), osg::RadiansToDegrees(y)));
double width = GeoMath::distance( y, westLon, y, eastLon, earthRadius);
double height = GeoMath::distance( southLat, x, northLat, x, earthRadius);
setWidth( Linear(width, Units::METERS ));
setHeight( Linear(height, Units::METERS ));
}
}