本文整理汇总了C++中GeoExtent类的典型用法代码示例。如果您正苦于以下问题:C++ GeoExtent类的具体用法?C++ GeoExtent怎么用?C++ GeoExtent使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了GeoExtent类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: createImage
// override
// Creates an image.
osg::Image* createImage(const TileKey& key,
ProgressCallback* progress )
{
if ( !_imageLayer.valid() || !_featureSource.valid() )
return 0L;
// fetch the image for this key:
GeoImage image = _imageLayer->createImage(key, progress);
if ( !image.valid() )
return 0L;
// fetch a set of features for this key. The features are in their
// own SRS, so we need to transform:
const SpatialReference* featureSRS = _featureSource->getFeatureProfile()->getSRS();
GeoExtent extentInFeatureSRS = key.getExtent().transform( featureSRS );
// assemble a spatial query. It helps if your features have a spatial index.
Query query;
query.bounds() = extentInFeatureSRS.bounds();
//query.expression() = ... // SQL expression compatible with data source
osg::ref_ptr<FeatureCursor> cursor = _featureSource->createFeatureCursor(query);
// create a new image to return.
osg::Image* output = new osg::Image();
//output->allocateImage(128, 128, 1, GL_RGB, GL_UNSIGNED_BYTE);
// do your magic here.
return output;
}
示例2: tolua_Lua_ScriptEngine_tolua_GeoExtent_contains02
/* method: contains of class GeoExtent */
static int tolua_Lua_ScriptEngine_tolua_GeoExtent_contains02(lua_State* tolua_S)
{
tolua_Error tolua_err;
if (
!tolua_isusertype(tolua_S,1,"GeoExtent",0,&tolua_err) ||
!tolua_isusertype(tolua_S,2,"GeoExtent",0,&tolua_err) ||
!tolua_isnoobj(tolua_S,3,&tolua_err)
)
goto tolua_lerror;
else
{
GeoExtent* self = (GeoExtent*) tolua_tousertype(tolua_S,1,0);
GeoExtent e = *((GeoExtent*) tolua_tousertype(tolua_S,2,0));
#ifndef TOLUA_RELEASE
if (!self) tolua_error(tolua_S,"invalid 'self' in function 'contains'",NULL);
#endif
{
bool tolua_ret = (bool) self->contains(e);
tolua_pushboolean(tolua_S,(bool)tolua_ret);
}
}
return 1;
tolua_lerror:
return tolua_Lua_ScriptEngine_tolua_GeoExtent_contains01(tolua_S);
}
示例3: tolua_Lua_ScriptEngine_tolua_GeoExtent_getArea00
/* method: getArea of class GeoExtent */
static int tolua_Lua_ScriptEngine_tolua_GeoExtent_getArea00(lua_State* tolua_S)
{
#ifndef TOLUA_RELEASE
tolua_Error tolua_err;
if (
!tolua_isusertype(tolua_S,1,"GeoExtent",0,&tolua_err) ||
!tolua_isnoobj(tolua_S,2,&tolua_err)
)
goto tolua_lerror;
else
#endif
{
GeoExtent* self = (GeoExtent*) tolua_tousertype(tolua_S,1,0);
#ifndef TOLUA_RELEASE
if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getArea'",NULL);
#endif
{
double tolua_ret = (double) self->getArea();
tolua_pushnumber(tolua_S,(double)tolua_ret);
}
}
return 1;
#ifndef TOLUA_RELEASE
tolua_lerror:
tolua_error(tolua_S,"#ferror in function 'getArea'.",&tolua_err);
return 0;
#endif
}
示例4: extentInsideOrOnLine
bool
extentInsideOrOnLine( const GeoExtent& p, const GeoPoint& s1, const GeoPoint& s2 )
{
return
pointInsideOrOnLine( p.getSouthwest(), s1, s2 ) &&
pointInsideOrOnLine( p.getNortheast(), s1, s2 );
}
示例5: tolua_Lua_ScriptEngine_tolua_GeoExtent_contains00
/* method: contains of class GeoExtent */
static int tolua_Lua_ScriptEngine_tolua_GeoExtent_contains00(lua_State* tolua_S)
{
#ifndef TOLUA_RELEASE
tolua_Error tolua_err;
if (
!tolua_isusertype(tolua_S,1,"GeoExtent",0,&tolua_err) ||
!tolua_isnumber(tolua_S,2,0,&tolua_err) ||
!tolua_isnumber(tolua_S,3,0,&tolua_err) ||
!tolua_isnoobj(tolua_S,4,&tolua_err)
)
goto tolua_lerror;
else
#endif
{
GeoExtent* self = (GeoExtent*) tolua_tousertype(tolua_S,1,0);
double x = ((double) tolua_tonumber(tolua_S,2,0));
double y = ((double) tolua_tonumber(tolua_S,3,0));
#ifndef TOLUA_RELEASE
if (!self) tolua_error(tolua_S,"invalid 'self' in function 'contains'",NULL);
#endif
{
bool tolua_ret = (bool) self->contains(x,y);
tolua_pushboolean(tolua_S,(bool)tolua_ret);
}
}
return 1;
#ifndef TOLUA_RELEASE
tolua_lerror:
tolua_error(tolua_S,"#ferror in function 'contains'.",&tolua_err);
return 0;
#endif
}
示例6: transform
GeoExtent
OGR_SpatialReference::transform( const GeoExtent& input ) const
{
GeoPoint sw = transform( input.getSouthwest() );
GeoPoint ne = transform( input.getNortheast() );
return GeoExtent( sw, ne );
}
示例7: if
void
FeatureNode::updateClusterCulling()
{
// install a cluster culler.
if ( getMapNode()->isGeocentric() && _clusterCulling && !_clusterCullingCallback)
{
const GeoExtent& ccExtent = _extent;
if ( ccExtent.isValid() )
{
// if the extent is more than 90 degrees, bail
GeoExtent geodeticExtent = ccExtent.transform( ccExtent.getSRS()->getGeographicSRS() );
if ( geodeticExtent.width() < 90.0 && geodeticExtent.height() < 90.0 )
{
// get the geocentric tile center:
osg::Vec3d tileCenter;
ccExtent.getCentroid( tileCenter.x(), tileCenter.y() );
osg::Vec3d centerECEF;
ccExtent.getSRS()->transform( tileCenter, getMapNode()->getMapSRS()->getECEF(), centerECEF );
_clusterCullingCallback = ClusterCullingFactory::create2( this, centerECEF );
if ( _clusterCullingCallback )
this->addCullCallback( _clusterCullingCallback );
}
}
}
else if (!_clusterCulling && _clusterCullingCallback)
{
this->removeCullCallback( _clusterCullingCallback );
_clusterCullingCallback = 0;
}
}
示例8: addIntersectingTiles
void
UnifiedCubeProfile::getIntersectingTiles(const GeoExtent& remoteExtent,
unsigned localLOD,
std::vector<TileKey>& out_intersectingKeys ) const
{
if ( getSRS()->isHorizEquivalentTo( remoteExtent.getSRS() ) )
{
addIntersectingTiles( remoteExtent, localLOD, out_intersectingKeys );
}
else
{
// the cube profile is non-contiguous. so there may be multiple local extents required
// to fully intersect the remote extent.
// first transform the remote extent to lat/long.
GeoExtent remoteExtent_gcs = remoteExtent.getSRS()->isGeographic()
? remoteExtent
: remoteExtent.transform( remoteExtent.getSRS()->getGeographicSRS() );
// Chop the input extent into three separate extents: for the equatorial, north polar,
// and south polar tile regions.
for( int face=0; face<6; ++face )
{
GeoExtent partExtent_gcs = _faceExtent_gcs[face].intersectionSameSRS( remoteExtent_gcs );
if ( partExtent_gcs.isValid() )
{
GeoExtent partExtent = transformGcsExtentOnFace( partExtent_gcs, face );
addIntersectingTiles( partExtent, localLOD, out_intersectingKeys );
}
}
}
}
示例9: clampAndTransformExtent
void
Profile::getIntersectingTiles(const GeoExtent& extent, unsigned localLOD, std::vector<TileKey>& out_intersectingKeys) const
{
GeoExtent ext = extent;
// reproject into the profile's SRS if necessary:
if ( !getSRS()->isHorizEquivalentTo( extent.getSRS() ) )
{
// localize the extents and clamp them to legal values
ext = clampAndTransformExtent( extent );
if ( !ext.isValid() )
return;
}
if ( ext.crossesAntimeridian() )
{
GeoExtent first, second;
if (ext.splitAcrossAntimeridian( first, second ))
{
addIntersectingTiles( first, localLOD, out_intersectingKeys );
addIntersectingTiles( second, localLOD, out_intersectingKeys );
}
}
else
{
addIntersectingTiles( ext, localLOD, out_intersectingKeys );
}
}
示例10: TileMap
TileMap*
TileMap::create(const std::string& url,
const Profile* profile,
const DataExtentList& dataExtents,
const std::string& format,
int tile_width,
int tile_height)
{
const GeoExtent& ex = profile->getExtent();
TileMap* tileMap = new TileMap();
tileMap->setProfileType(profile->getProfileType());
tileMap->setExtents(ex.xMin(), ex.yMin(), ex.xMax(), ex.yMax());
tileMap->setOrigin(ex.xMin(), ex.yMin());
tileMap->_filename = url;
tileMap->_srs = getHorizSRSString(profile->getSRS());
tileMap->_vsrs = profile->getSRS()->getVertInitString();
tileMap->_format.setWidth( tile_width );
tileMap->_format.setHeight( tile_height );
profile->getNumTiles( 0, tileMap->_numTilesWide, tileMap->_numTilesHigh );
// format can be a mime-type or an extension:
std::string::size_type p = format.find('/');
if ( p == std::string::npos )
{
tileMap->_format.setExtension(format);
tileMap->_format.setMimeType( Registry::instance()->getMimeTypeForExtension(format) );
}
else
{
tileMap->_format.setMimeType(format);
tileMap->_format.setExtension( Registry::instance()->getExtensionForMimeType(format) );
}
//Add the data extents
tileMap->getDataExtents().insert(tileMap->getDataExtents().end(), dataExtents.begin(), dataExtents.end());
// If we have some data extents specified then make a nicer bounds than the
if (!tileMap->getDataExtents().empty())
{
// Get the union of all the extents
GeoExtent e(tileMap->getDataExtents()[0]);
for (unsigned int i = 1; i < tileMap->getDataExtents().size(); i++)
{
e.expandToInclude(tileMap->getDataExtents()[i]);
}
// Convert the bounds to the output profile
GeoExtent bounds = e.transform(profile->getSRS());
tileMap->setExtents(bounds.xMin(), bounds.yMin(), bounds.xMax(), bounds.yMax());
}
tileMap->generateTileSets();
tileMap->computeMinMaxLevel();
return tileMap;
}
示例11: getTileDimensions
void
Profile::addIntersectingTiles(const GeoExtent& key_ext, unsigned localLOD, std::vector<TileKey>& out_intersectingKeys) const
{
// assume a non-crossing extent here.
if ( key_ext.crossesAntimeridian() )
{
OE_WARN << "Profile::addIntersectingTiles cannot process date-line cross" << std::endl;
return;
}
int tileMinX, tileMaxX;
int tileMinY, tileMaxY;
double destTileWidth, destTileHeight;
getTileDimensions(localLOD, destTileWidth, destTileHeight);
//OE_DEBUG << std::fixed << " Source Tile: " << key.getLevelOfDetail() << " (" << keyWidth << ", " << keyHeight << ")" << std::endl;
//OE_DEBUG << std::fixed << " Dest Size: " << destLOD << " (" << destTileWidth << ", " << destTileHeight << ")" << std::endl;
double east = key_ext.xMax() - _extent.xMin();
bool xMaxOnTileBoundary = fmod(east, destTileWidth) == 0.0;
double south = _extent.yMax() - key_ext.yMin();
bool yMaxOnTileBoundary = fmod(south, destTileHeight) == 0.0;
tileMinX = (int)((key_ext.xMin() - _extent.xMin()) / destTileWidth);
tileMaxX = (int)(east / destTileWidth) - (xMaxOnTileBoundary ? 1 : 0);
tileMinY = (int)((_extent.yMax() - key_ext.yMax()) / destTileHeight);
tileMaxY = (int)(south / destTileHeight) - (yMaxOnTileBoundary ? 1 : 0);
unsigned int numWide, numHigh;
getNumTiles(localLOD, numWide, numHigh);
// bail out if the tiles are out of bounds.
if ( tileMinX >= (int)numWide || tileMinY >= (int)numHigh ||
tileMaxX < 0 || tileMaxY < 0 )
{
return;
}
tileMinX = osg::clampBetween(tileMinX, 0, (int)numWide-1);
tileMaxX = osg::clampBetween(tileMaxX, 0, (int)numWide-1);
tileMinY = osg::clampBetween(tileMinY, 0, (int)numHigh-1);
tileMaxY = osg::clampBetween(tileMaxY, 0, (int)numHigh-1);
OE_DEBUG << std::fixed << " Dest Tiles: " << tileMinX << "," << tileMinY << " => " << tileMaxX << "," << tileMaxY << std::endl;
for (int i = tileMinX; i <= tileMaxX; ++i)
{
for (int j = tileMinY; j <= tileMaxY; ++j)
{
//TODO: does not support multi-face destination keys.
out_intersectingKeys.push_back( TileKey(localLOD, i, j, this) );
}
}
}
示例12: getFeatures
/**
* Gets all the features that intersect the extent
*/
void getFeatures(const GeoExtent& extent, FeatureList& features)
{
GeoExtent localExtent = extent.transform( _featureSource->getFeatureProfile()->getSRS() );
Query query;
query.bounds() = localExtent.bounds();
if (localExtent.intersects( _featureSource->getFeatureProfile()->getExtent()))
{
osg::ref_ptr< FeatureCursor > cursor = _featureSource->createFeatureCursor( query );
if (cursor)
{
cursor->fill( features );
}
}
}
示例13: out
bool
GeoLocator::createScaleBiasMatrix(const GeoExtent& window, osg::Matrixf& out) const
{
float scalex = window.width() / _dataExtent.width();
float scaley = window.height() / _dataExtent.height();
float biasx = (window.xMin()-_dataExtent.xMin()) / _dataExtent.width();
float biasy = (window.yMin()-_dataExtent.yMin()) / _dataExtent.height();
out(0,0) = scalex;
out(1,1) = scaley;
out(3,0) = biasx;
out(3,1) = biasy;
return true;
}
示例14: getExtent
GeoImage
GeoImage::crop( const GeoExtent& extent, bool exact, unsigned int width, unsigned int height ) const
{
//Check for equivalence
if ( extent.getSRS()->isEquivalentTo( getSRS() ) )
{
//If we want an exact crop or they want to specify the output size of the image, use GDAL
if (exact || width != 0 || height != 0 )
{
OE_DEBUG << "[osgEarth::GeoImage::crop] Performing exact crop" << std::endl;
//Suggest an output image size
if (width == 0 || height == 0)
{
double xRes = (getExtent().xMax() - getExtent().xMin()) / (double)_image->s();
double yRes = (getExtent().yMax() - getExtent().yMin()) / (double)_image->t();
width = osg::maximum(1u, (unsigned int)((extent.xMax() - extent.xMin()) / xRes));
height = osg::maximum(1u, (unsigned int)((extent.yMax() - extent.yMin()) / yRes));
OE_DEBUG << "[osgEarth::GeoImage::crop] Computed output image size " << width << "x" << height << std::endl;
}
//Note: Passing in the current SRS simply forces GDAL to not do any warping
return reproject( getSRS(), &extent, width, height);
}
else
{
OE_DEBUG << "[osgEarth::GeoImage::crop] Performing non-exact crop " << std::endl;
//If an exact crop is not desired, we can use the faster image cropping code that does no resampling.
double destXMin = extent.xMin();
double destYMin = extent.yMin();
double destXMax = extent.xMax();
double destYMax = extent.yMax();
osg::Image* new_image = ImageUtils::cropImage(
_image.get(),
_extent.xMin(), _extent.yMin(), _extent.xMax(), _extent.yMax(),
destXMin, destYMin, destXMax, destYMax );
//The destination extents may be different than the input extents due to not being able to crop along pixel boundaries.
return new_image?
GeoImage( new_image, GeoExtent( getSRS(), destXMin, destYMin, destXMax, destYMax ) ) :
GeoImage::INVALID;
}
}
else
{
//TODO: just reproject the image before cropping
OE_NOTICE << "[osgEarth::GeoImage::crop] Cropping extent does not have equivalent SpatialReference" << std::endl;
return GeoImage::INVALID;
}
}
示例15:
void
MPTerrainEngineNode::invalidateRegion(const GeoExtent& extent,
unsigned minLevel,
unsigned maxLevel)
{
if (_terrainOptions.incrementalUpdate() == true && _liveTiles.valid())
{
GeoExtent extentLocal = extent;
if ( !extent.getSRS()->isEquivalentTo(this->getMap()->getSRS()) )
{
extent.transform(this->getMap()->getSRS(), extentLocal);
}
_liveTiles->setDirty(extentLocal, minLevel, maxLevel);
}
}