本文整理汇总了C++中GeoExtent::height方法的典型用法代码示例。如果您正苦于以下问题:C++ GeoExtent::height方法的具体用法?C++ GeoExtent::height怎么用?C++ GeoExtent::height使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类GeoExtent
的用法示例。
在下文中一共展示了GeoExtent::height方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: s_llf
osg::Node*
GeodeticGraticule::buildTile( const TileKey& key, Map* map ) const
{
if ( _options->levels().size() <= key.getLevelOfDetail() )
{
OE_WARN << LC << "Tried to create cell at non-existant level " << key.getLevelOfDetail() << std::endl;
return 0L;
}
const GeodeticGraticuleOptions::Level& level = _options->levels()[key.getLevelOfDetail()]; //_levels[key.getLevelOfDetail()];
// the "-2" here is because normal tile paging gives you one subdivision already,
// so we only need to account for > 1 subdivision factor.
unsigned cellsPerTile = level._subdivisionFactor <= 2u ? 1u : 1u << (level._subdivisionFactor-2u);
unsigned cellsPerTileX = std::max(1u, cellsPerTile);
unsigned cellsPerTileY = std::max(1u, cellsPerTile);
GeoExtent tileExtent = key.getExtent();
FeatureList latLines;
FeatureList lonLines;
static LatLongFormatter s_llf(LatLongFormatter::FORMAT_DECIMAL_DEGREES);
double cellWidth = tileExtent.width() / cellsPerTileX;
double cellHeight = tileExtent.height() / cellsPerTileY;
const Style& lineStyle = level._lineStyle.isSet() ? *level._lineStyle : *_options->lineStyle();
const Style& textStyle = level._textStyle.isSet() ? *level._textStyle : *_options->textStyle();
bool hasText = textStyle.get<TextSymbol>() != 0L;
osg::ref_ptr<osg::Group> labels;
if ( hasText )
{
labels = new osg::Group();
//TODO: This is a bug, if you don't turn on decluttering the text labels are giant. Need to determine what is wrong with LabelNodes without decluttering.
Decluttering::setEnabled( labels->getOrCreateStateSet(), true );
}
// spatial ref for features:
const SpatialReference* geoSRS = tileExtent.getSRS()->getGeographicSRS();
// longitude lines
for( unsigned cx = 0; cx < cellsPerTileX; ++cx )
{
double clon = tileExtent.xMin() + cellWidth * (double)cx;
LineString* lon = new LineString(2);
lon->push_back( osg::Vec3d(clon, tileExtent.yMin(), 0) );
lon->push_back( osg::Vec3d(clon, tileExtent.yMax(), 0) );
lonLines.push_back( new Feature(lon, geoSRS) );
if ( hasText )
{
for( unsigned cy = 0; cy < cellsPerTileY; ++cy )
{
double clat = tileExtent.yMin() + (0.5*cellHeight) + cellHeight*(double)cy;
LabelNode* label = new LabelNode(
_mapNode.get(),
GeoPoint(geoSRS, clon, clat),
s_llf.format(clon),
textStyle );
labels->addChild( label );
}
}
}
// latitude lines
for( unsigned cy = 0; cy < cellsPerTileY; ++cy )
{
double clat = tileExtent.yMin() + cellHeight * (double)cy;
if ( clat == key.getProfile()->getExtent().yMin() )
continue;
LineString* lat = new LineString(2);
lat->push_back( osg::Vec3d(tileExtent.xMin(), clat, 0) );
lat->push_back( osg::Vec3d(tileExtent.xMax(), clat, 0) );
latLines.push_back( new Feature(lat, geoSRS) );
if ( hasText )
{
for( unsigned cx = 0; cx < cellsPerTileX; ++cx )
{
double clon = tileExtent.xMin() + (0.5*cellWidth) + cellWidth*(double)cy;
LabelNode* label = new LabelNode(
_mapNode.get(),
GeoPoint(geoSRS, clon, clat),
s_llf.format(clat),
textStyle );
labels->addChild( label );
}
}
}
osg::Group* group = new osg::Group();
GeometryCompiler compiler;
osg::ref_ptr<Session> session = new Session( map );
//.........这里部分代码省略.........
示例2: FeatureSourceIndexNode
osg::Group*
FeatureModelGraph::build( const FeatureLevel& level, const GeoExtent& extent, const TileKey* key )
{
// set up for feature indexing if appropriate:
osg::ref_ptr<osg::Group> group;
FeatureSourceIndexNode* index = 0L;
if ( _session->getFeatureSource() && (_options.featureIndexing() == true) )
{
index = new FeatureSourceIndexNode( _session->getFeatureSource() );
group = index;
}
else
{
group = new osg::Group();
}
// form the baseline query, which does a spatial query based on the working extent.
Query query;
if ( extent.isValid() )
query.bounds() = extent.bounds();
// add a tile key to the query if there is one, to support TFS-style queries
if ( key )
query.tileKey() = *key;
// now, go through any level-based selectors.
const StyleSelectorVector& levelSelectors = level.selectors();
// if there are none, just build once with the default style and query.
if ( levelSelectors.size() == 0 )
{
// attempt to glean the style from the feature source name:
const Style style = *_session->styles()->getStyle(
*_session->getFeatureSource()->getFeatureSourceOptions().name() );
osg::Node* node = build( style, query, extent, index );
if ( node )
group->addChild( node );
}
else
{
for( StyleSelectorVector::const_iterator i = levelSelectors.begin(); i != levelSelectors.end(); ++i )
{
const StyleSelector& selector = *i;
// fetch the selector's style:
const Style* selectorStyle = _session->styles()->getStyle( selector.getSelectedStyleName() );
// combine the selector's query, if it has one:
Query selectorQuery =
selector.query().isSet() ? query.combineWith( *selector.query() ) : query;
osg::Node* node = build( *selectorStyle, selectorQuery, extent, index );
if ( node )
group->addChild( node );
}
}
if ( group->getNumChildren() > 0 )
{
// account for a min-range here.
if ( level.minRange() > 0.0f )
{
osg::LOD* lod = new osg::LOD();
lod->addChild( group.get(), level.minRange(), FLT_MAX );
group = lod;
}
if ( _session->getMapInfo().isGeocentric() && _options.clusterCulling() == true )
{
const FeatureProfile* featureProfile = _session->getFeatureSource()->getFeatureProfile();
const GeoExtent& ccExtent = extent.isValid() ? extent : featureProfile->getExtent();
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 )
{
#if 1
// get the geocentric tile center:
osg::Vec3d tileCenter;
ccExtent.getCentroid( tileCenter.x(), tileCenter.y() );
osg::Vec3d centerECEF;
ccExtent.getSRS()->transformToECEF( tileCenter, centerECEF );
osg::NodeCallback* ccc = ClusterCullerFactory::create( group.get(), centerECEF );
if ( ccc )
group->addCullCallback( ccc );
#endif
}
}
}
// if indexing is enabled, build the index now.
if ( index )
index->reindex();
return group.release();
}
//.........这里部分代码省略.........
示例3: renderFeaturesForStyle
//override
bool renderFeaturesForStyle(
const Style& style,
const FeatureList& inFeatures,
osg::Referenced* buildData,
const GeoExtent& imageExtent,
osg::Image* image )
{
// local copy of the features that we can process
FeatureList features = inFeatures;
BuildData* bd = static_cast<BuildData*>( buildData );
// A processing context to use with the filters:
FilterContext context;
context.profile() = getFeatureSource()->getFeatureProfile();
const LineSymbol* masterLine = style.getSymbol<LineSymbol>();
const PolygonSymbol* masterPoly = style.getSymbol<PolygonSymbol>();
//bool embeddedStyles = getFeatureSource()->hasEmbeddedStyles();
// if only a line symbol exists, and there are polygons in the mix, draw them
// as outlines (line rings).
//OE_INFO << LC << "Line Symbol = " << (masterLine == 0L ? "null" : masterLine->getConfig().toString()) << std::endl;
//OE_INFO << LC << "Poly SYmbol = " << (masterPoly == 0L ? "null" : masterPoly->getConfig().toString()) << std::endl;
//bool convertPolysToRings = poly == 0L && line != 0L;
//if ( convertPolysToRings )
// OE_INFO << LC << "No PolygonSymbol; will draw polygons to rings" << std::endl;
// initialize:
double xmin = imageExtent.xMin();
double ymin = imageExtent.yMin();
//double s = (double)image->s();
//double t = (double)image->t();
double xf = (double)image->s() / imageExtent.width();
double yf = (double)image->t() / imageExtent.height();
// strictly speaking we should iterate over the features and buffer each one that's a line,
// rather then checking for the existence of a LineSymbol.
FeatureList linesToBuffer;
for(FeatureList::iterator i = features.begin(); i != features.end(); i++)
{
Feature* feature = i->get();
Geometry* geom = feature->getGeometry();
if ( geom )
{
// check for an embedded style:
const LineSymbol* line = feature->style().isSet() ?
feature->style()->getSymbol<LineSymbol>() : masterLine;
const PolygonSymbol* poly =
feature->style().isSet() ? feature->style()->getSymbol<PolygonSymbol>() : masterPoly;
// if we have polygons but only a LineSymbol, draw the poly as a line.
if ( geom->getComponentType() == Geometry::TYPE_POLYGON )
{
if ( !poly && line )
{
Feature* outline = new Feature( *feature );
geom = geom->cloneAs( Geometry::TYPE_RING );
outline->setGeometry( geom );
*i = outline;
feature = outline;
}
//TODO: fix to enable outlined polys. doesn't work, not sure why -gw
//else if ( poly && line )
//{
// Feature* outline = new Feature();
// geom = geom->cloneAs( Geometry::TYPE_LINESTRING );
// outline->setGeometry( geom );
// features.push_back( outline );
//}
}
bool needsBuffering =
geom->getComponentType() == Geometry::TYPE_LINESTRING ||
geom->getComponentType() == Geometry::TYPE_RING;
if ( needsBuffering )
{
linesToBuffer.push_back( feature );
}
}
}
if ( linesToBuffer.size() > 0 )
{
//We are buffering in the features native extent, so we need to use the transform extent to get the proper "resolution" for the image
GeoExtent transformedExtent = imageExtent.transform(context.profile()->getSRS());
double trans_xf = (double)image->s() / transformedExtent.width();
double trans_yf = (double)image->t() / transformedExtent.height();
// resolution of the image (pixel extents):
double xres = 1.0/trans_xf;
double yres = 1.0/trans_yf;
//.........这里部分代码省略.........
示例4: equatorialExtent
osg::Node*
SingleKeyNodeFactory::createTile(TileModel* model,
bool setupChildrenIfNecessary,
ProgressCallback* progress)
{
#ifdef EXPERIMENTAL_TILE_NODE_CACHE
osg::ref_ptr<TileNode> tileNode;
TileNodeCache::Record rec;
cache.get(model->_tileKey, rec);
if ( rec.valid() )
{
tileNode = rec.value().get();
}
else
{
tileNode = _modelCompiler->compile( model, _frame );
cache.insert(model->_tileKey, tileNode);
}
#else
// compile the model into a node:
TileNode* tileNode = _modelCompiler->compile(model, _frame, progress);
#endif
// see if this tile might have children.
bool prepareForChildren =
setupChildrenIfNecessary &&
model->_tileKey.getLOD() < *_options.maxLOD();
osg::Node* result = 0L;
if ( prepareForChildren )
{
osg::BoundingSphere bs = tileNode->getBound();
TilePagedLOD* plod = new TilePagedLOD( _engine->getUID(), _liveTiles, _deadTiles );
plod->setCenter ( bs.center() );
plod->addChild ( tileNode );
plod->setFileName( 1, Stringify() << tileNode->getKey().str() << "." << _engine->getUID() << ".osgearth_engine_mp_tile" );
double rangeFactor = _options.minTileRangeFactor().get();
if (_options.adaptivePolarRangeFactor() == true)
{
double lat = model->_tileKey.getExtent().yMin() < 0 ? -model->_tileKey.getExtent().yMax() : model->_tileKey.getExtent().yMin();
double latRad = osg::DegreesToRadians(lat);
rangeFactor -= (rangeFactor - 1.0)*sin(latRad)*sin(latRad);
}
plod->setRangeFactor(rangeFactor);
// Setup expiration.
if (_options.minExpiryFrames().isSet())
{
plod->setMinimumExpiryFrames(1, *_options.minExpiryFrames());
}
if (_options.minExpiryTime().isSet())
{
plod->setMinimumExpiryTime(1, *_options.minExpiryTime());
}
if ( _options.rangeMode().value() == osg::LOD::DISTANCE_FROM_EYE_POINT )
{
//Compute the min range based on the 2D size of the tile
GeoExtent extent = model->_tileKey.getExtent();
double radius = 0.0;
#if 0
// Test code to use the equitorial radius so that all of the tiles at the same level
// have the same range. This will make the poles page in more appropriately.
if (_frame.getMapInfo().isGeocentric())
{
GeoExtent equatorialExtent(
extent.getSRS(),
extent.west(),
-extent.height()/2.0,
extent.east(),
extent.height()/2.0 );
radius = equatorialExtent.getBoundingGeoCircle().getRadius();
}
else
#endif
{
GeoPoint lowerLeft(extent.getSRS(), extent.xMin(), extent.yMin(), 0.0, ALTMODE_ABSOLUTE);
GeoPoint upperRight(extent.getSRS(), extent.xMax(), extent.yMax(), 0.0, ALTMODE_ABSOLUTE);
osg::Vec3d ll, ur;
lowerLeft.toWorld( ll );
upperRight.toWorld( ur );
radius = (ur - ll).length() / 2.0;
}
//float minRange = (float)(radius * _options.minTileRangeFactor().value());
float minRange = radius;
plod->setRange( 0, minRange, FLT_MAX );
plod->setRange( 1, 0, minRange );
plod->setRangeMode( osg::LOD::DISTANCE_FROM_EYE_POINT );
}
else
{
// the *2 is because we page in 4-tile sets, not individual tiles.
float size = 2.0f * _options.tilePixelSize().value();
plod->setRange( 0, 0.0f, size );
//.........这里部分代码省略.........
示例5: renderFeaturesForStyle
//override
bool renderFeaturesForStyle(
Session* session,
const Style& style,
const FeatureList& features,
osg::Referenced* buildData,
const GeoExtent& imageExtent,
osg::Image* image )
{
OE_DEBUG << LC << "Rendering " << features.size() << " features for " << imageExtent.toString() << "\n";
// A processing context to use with the filters:
FilterContext context( session );
context.setProfile( getFeatureSource()->getFeatureProfile() );
const LineSymbol* masterLine = style.getSymbol<LineSymbol>();
const PolygonSymbol* masterPoly = style.getSymbol<PolygonSymbol>();
const CoverageSymbol* masterCov = style.getSymbol<CoverageSymbol>();
// sort into bins, making a copy for lines that require buffering.
FeatureList polygons;
FeatureList lines;
for(FeatureList::const_iterator f = features.begin(); f != features.end(); ++f)
{
if ( f->get()->getGeometry() )
{
bool hasPoly = false;
bool hasLine = false;
if ( masterPoly || f->get()->style()->has<PolygonSymbol>() )
{
polygons.push_back( f->get() );
hasPoly = true;
}
if ( masterLine || f->get()->style()->has<LineSymbol>() )
{
Feature* newFeature = new Feature( *f->get() );
if ( !newFeature->getGeometry()->isLinear() )
{
newFeature->setGeometry( newFeature->getGeometry()->cloneAs(Geometry::TYPE_RING) );
}
lines.push_back( newFeature );
hasLine = true;
}
// if there are no geometry symbols but there is a coverage symbol, default to polygons.
if ( !hasLine && !hasPoly )
{
if ( masterCov || f->get()->style()->has<CoverageSymbol>() )
{
polygons.push_back( f->get() );
}
}
}
}
// initialize:
RenderFrame frame;
frame.xmin = imageExtent.xMin();
frame.ymin = imageExtent.yMin();
frame.xf = (double)image->s() / imageExtent.width();
frame.yf = (double)image->t() / imageExtent.height();
if ( lines.size() > 0 )
{
// We are buffering in the features native extent, so we need to use the
// transformed extent to get the proper "resolution" for the image
const SpatialReference* featureSRS = context.profile()->getSRS();
GeoExtent transformedExtent = imageExtent.transform(featureSRS);
double trans_xf = (double)image->s() / transformedExtent.width();
double trans_yf = (double)image->t() / transformedExtent.height();
// resolution of the image (pixel extents):
double xres = 1.0/trans_xf;
double yres = 1.0/trans_yf;
// downsample the line data so that it is no higher resolution than to image to which
// we intend to rasterize it. If you don't do this, you run the risk of the buffer
// operation taking forever on very high-res input data.
if ( _options.optimizeLineSampling() == true )
{
ResampleFilter resample;
resample.minLength() = osg::minimum( xres, yres );
context = resample.push( lines, context );
}
// now run the buffer operation on all lines:
BufferFilter buffer;
double lineWidth = 1.0;
if ( masterLine )
{
buffer.capStyle() = masterLine->stroke()->lineCap().value();
if ( masterLine->stroke()->width().isSet() )
{
lineWidth = masterLine->stroke()->width().value();
//.........这里部分代码省略.........
示例6: FeatureSourceIndexNode
/**
* Builds geometry for feature data at a particular level, and constrained by an extent.
* The extent is either (a) expressed in "extent" literally, as is the case in a non-tiled
* data source, or (b) expressed implicitly by a TileKey, which is the case for a tiled
* data source.
*/
osg::Group*
FeatureModelGraph::buildLevel( const FeatureLevel& level, const GeoExtent& extent, const TileKey* key )
{
// set up for feature indexing if appropriate:
osg::ref_ptr<osg::Group> group;
FeatureSourceIndexNode* index = 0L;
if ( _session->getFeatureSource() && (_options.featureIndexing() == true) )
{
index = new FeatureSourceIndexNode( _session->getFeatureSource(), _options.storingAttributesOnFeatureIndexing() == true );
group = index;
}
else
{
group = new osg::Group();
}
// form the baseline query, which does a spatial query based on the working extent.
Query query;
if ( extent.isValid() )
query.bounds() = extent.bounds();
// add a tile key to the query if there is one, to support TFS-style queries
if ( key )
query.tileKey() = *key;
// does the level have a style name set?
if ( level.styleName().isSet() )
{
osg::Node* node = 0L;
const Style* style = _session->styles()->getStyle( *level.styleName(), false );
if ( style )
{
// found a specific style to use.
node = createStyleGroup( *style, query, index );
if ( node )
group->addChild( node );
}
else
{
const StyleSelector* selector = _session->styles()->getSelector( *level.styleName() );
if ( selector )
{
buildStyleGroups( selector, query, index, group.get() );
}
}
}
else
{
Style defaultStyle;
if ( _session->styles()->selectors().size() == 0 )
{
// attempt to glean the style from the feature source name:
defaultStyle = *_session->styles()->getStyle(
*_session->getFeatureSource()->getFeatureSourceOptions().name() );
}
osg::Node* node = build( defaultStyle, query, extent, index );
if ( node )
group->addChild( node );
}
if ( group->getNumChildren() > 0 )
{
// account for a min-range here. Do not address the max-range here; that happens
// above when generating paged LOD nodes, etc.
float minRange = level.minRange();
if ( minRange > 0.0f )
{
// minRange can't be less than the tile geometry's radius.
minRange = std::max(minRange, (float)group->getBound().radius());
osg::LOD* lod = new osg::LOD();
lod->addChild( group.get(), minRange, FLT_MAX );
group = lod;
}
if ( _session->getMapInfo().isGeocentric() && _options.clusterCulling() == true )
{
const FeatureProfile* featureProfile = _session->getFeatureSource()->getFeatureProfile();
const GeoExtent& ccExtent = extent.isValid() ? extent : featureProfile->getExtent();
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()->transformToECEF( tileCenter, centerECEF );
//.........这里部分代码省略.........
示例7: round
void
Profile::addIntersectingTiles(const GeoExtent& key_ext, 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;
}
#if 0 // works for meracator; does NOT work for cube
int precision = 5;
double eps = 0.001;
double keyWidth = round(key_ext.width(), precision);
int destLOD = 0;
double w, h;
getTileDimensions(0, w, h);
for(; (round(w,precision) - keyWidth) > eps; w*=0.5, h*=0.5, destLOD++ );
double destTileWidth, destTileHeight;
getTileDimensions( destLOD, destTileWidth, destTileHeight );
destTileWidth = round(destTileWidth, precision);
destTileHeight = round(destTileHeight, precision);
int tileMinX = quantize( ((key_ext.xMin() - _extent.xMin()) / destTileWidth), eps );
int tileMaxX = (int)((key_ext.xMax() - _extent.xMin()) / destTileWidth);
int tileMinY = quantize( ((_extent.yMax() - key_ext.yMax()) / destTileHeight), eps );
int tileMaxY = (int) ((_extent.yMax() - key_ext.yMin()) / destTileHeight);
#else
double keyWidth = key_ext.width();
double keyHeight = key_ext.height();
// bail out if the key has a null extent. This might happen is the original key represents an
// area in one profile that is out of bounds in this profile.
if ( keyWidth <= 0.0 && keyHeight <= 0.0 )
return;
double keySpan = std::min( keyWidth, keyHeight );
double keyArea = keyWidth * keyHeight;
double keyAvg = 0.5*(keyWidth+keyHeight);
int destLOD = 1;
double destTileWidth, destTileHeight;
int currLOD = 0;
destLOD = currLOD;
getTileDimensions(destLOD, destTileWidth, destTileHeight);
while( true )
{
currLOD++;
double w, h;
getTileDimensions(currLOD, w, h);
if ( w < keyAvg || h < keyAvg ) break;
destLOD = currLOD;
destTileWidth = w;
destTileHeight = h;
}
//OE_DEBUG << std::fixed << " Source Tile: " << key.getLevelOfDetail() << " (" << keyWidth << ", " << keyHeight << ")" << std::endl;
//OE_DEBUG << std::fixed << " Dest Size: " << destLOD << " (" << destTileWidth << ", " << destTileHeight << ")" << std::endl;
int tileMinX = (int)((key_ext.xMin() - _extent.xMin()) / destTileWidth);
int tileMaxX = (int)((key_ext.xMax() - _extent.xMin()) / destTileWidth);
int tileMinY = (int)((_extent.yMax() - key_ext.yMax()) / destTileHeight);
int tileMaxY = (int)((_extent.yMax() - key_ext.yMin()) / destTileHeight);
#endif
unsigned int numWide, numHigh;
getNumTiles(destLOD, 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(destLOD, i, j, this) );
}
//.........这里部分代码省略.........