本文整理汇总了C++中Bounds::isValid方法的典型用法代码示例。如果您正苦于以下问题:C++ Bounds::isValid方法的具体用法?C++ Bounds::isValid怎么用?C++ Bounds::isValid使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Bounds
的用法示例。
在下文中一共展示了Bounds::isValid方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: isValid
bool
Bounds::contains(const Bounds& rhs) const
{
return
isValid() && rhs.isValid() &&
xMin() <= rhs.xMin() && xMax() >= rhs.xMax() &&
yMin() <= rhs.yMin() && yMax() >= rhs.yMax();
}
示例2: inBounds
bool
CubeSpatialReference::transformExtentToMBR(const SpatialReference* to_srs,
double& in_out_xmin,
double& in_out_ymin,
double& in_out_xmax,
double& in_out_ymax ) const
{
// input bounds:
Bounds inBounds(in_out_xmin, in_out_ymin, in_out_xmax, in_out_ymax);
Bounds outBounds;
// for each CUBE face, find the intersection of the input bounds and that face.
for (int face = 0; face < 6; ++face)
{
Bounds faceBounds( (double)(face), 0.0, (double)(face+1), 1.0);
Bounds intersection = faceBounds.intersectionWith(inBounds);
// if they intersect (with a non-zero area; abutting doesn't count in this case)
// transform the intersection and include in the result.
if (intersection.isValid() && intersection.area2d() > 0.0)
{
double
xmin = intersection.xMin(), ymin = intersection.yMin(),
xmax = intersection.xMax(), ymax = intersection.yMax();
if (transformInFaceExtentToMBR(to_srs, face, xmin, ymin, xmax, ymax))
{
outBounds.expandBy(Bounds(xmin, ymin, xmax, ymax));
}
}
}
if (outBounds.valid())
{
in_out_xmin = outBounds.xMin();
in_out_ymin = outBounds.yMin();
in_out_xmax = outBounds.xMax();
in_out_ymax = outBounds.yMax();
return true;
}
else
{
return false;
}
}
示例3: i
osg::Vec3d
Geometry::localize()
{
osg::Vec3d offset;
Bounds bounds = getBounds();
if ( bounds.isValid() )
{
osg::Vec2d center = bounds.center2d();
offset.set( center.x(), center.y(), 0 );
GeometryIterator i( this );
while( i.hasMore() )
{
Geometry* part = i.next();
for( Geometry::iterator j = part->begin(); j != part->end(); ++j )
{
*j = *j - offset;
}
}
}
return offset;
}
示例4: usage
/** Packages an image layer as a TMS folder. */
int
makeTMS( osg::ArgumentParser& args )
{
// see if the user wants to override the type extension (imagery only)
std::string extension;
args.read( "--ext", extension );
// verbosity?
bool verbose = !args.read( "--quiet" );
// find a .earth file on the command line
std::string earthFile = findArgumentWithExtension( args, ".earth" );
/* if ( earthFile.empty() )
return usage( "Missing required .earth file" );
*/
// folder to which to write the TMS archive.
std::string rootFolder;
if( !args.read( "--out", rootFolder ) )
rootFolder = Stringify() << earthFile << ".tms_repo";
// whether to overwrite existing tile files
bool overwrite = false;
if( args.read( "--overwrite" ) )
overwrite = true;
// write out an earth file
std::string outEarth;
args.read( "--out-earth", outEarth );
std::string dbOptions;
args.read( "--db-options", dbOptions );
std::string::size_type n = 0;
while( (n = dbOptions.find( '"', n )) != dbOptions.npos )
{
dbOptions.erase( n, 1 );
}
osg::ref_ptr<osgDB::Options> options = new osgDB::Options( dbOptions );
std::vector< Bounds > bounds;
// restrict packaging to user-specified bounds.
double xmin = DBL_MAX, ymin = DBL_MAX, xmax = DBL_MIN, ymax = DBL_MIN;
while( args.read( "--bounds", xmin, ymin, xmax, ymax ) )
{
Bounds b;
b.xMin() = xmin, b.yMin() = ymin, b.xMax() = xmax, b.yMax() = ymax;
bounds.push_back( b );
}
// max level to which to generate
unsigned maxLevel = ~0;
args.read( "--max-level", maxLevel );
// whether to keep 'empty' tiles
bool keepEmpties = args.read( "--keep-empties" );
bool continueSingleColor = args.read( "--continue-single-color" );
// max level to which to generate
unsigned elevationPixelDepth = 32;
args.read( "--elevation-pixel-depth", elevationPixelDepth );
// load up the map
osg::ref_ptr<MapNode> mapNode = MapNode::load( args );
if( !mapNode.valid() )
return usage( "Failed to load a valid .earth file" );
// create a folder for the output
osgDB::makeDirectory( rootFolder );
if( !osgDB::fileExists( rootFolder ) )
return usage( "Failed to create root output folder" );
Map* map = mapNode->getMap();
// fire up a packager:
TMSPackager packager( map->getProfile(), options );
packager.setVerbose( verbose );
packager.setOverwrite( overwrite );
packager.setKeepEmptyImageTiles( keepEmpties );
packager.setSubdivideSingleColorImageTiles( continueSingleColor );
packager.setElevationPixelDepth( elevationPixelDepth );
if( maxLevel != ~0 )
packager.setMaxLevel( maxLevel );
if( bounds.size() > 0 )
{
for( unsigned int i = 0; i < bounds.size(); ++i )
{
Bounds b = bounds[i];
if( b.isValid() )
packager.addExtent( GeoExtent( map->getProfile()->getSRS(), b ) );
}
}
// new map for an output earth file if necessary.
//.........这里部分代码省略.........
示例5: newExtent
FilterContext
CropFilter::push( FeatureList& input, FilterContext& context )
{
if ( !context.extent().isSet() )
{
OE_WARN << LC << "Extent is not set (and is required)" << std::endl;
return context;
}
const GeoExtent& extent = *context.extent();
GeoExtent newExtent( extent.getSRS() );
if ( _method == METHOD_CENTROID )
{
for( FeatureList::iterator i = input.begin(); i != input.end(); )
{
bool keepFeature = false;
Feature* feature = i->get();
Geometry* featureGeom = feature->getGeometry();
if ( featureGeom && featureGeom->isValid() )
{
Bounds bounds = featureGeom->getBounds();
if ( bounds.isValid() )
{
osg::Vec3d centroid = bounds.center();
if ( extent.contains( centroid.x(), centroid.y() ) )
{
keepFeature = true;
newExtent.expandToInclude( bounds.xMin(), bounds.yMin() );
}
}
}
if ( keepFeature )
++i;
else
i = input.erase( i );
}
}
else // METHOD_CROPPING (requires GEOS)
{
#ifdef OSGEARTH_HAVE_GEOS
// create the intersection polygon:
osg::ref_ptr<Symbology::Polygon> poly;
for( FeatureList::iterator i = input.begin(); i != input.end(); )
{
bool keepFeature = false;
Feature* feature = i->get();
Symbology::Geometry* featureGeom = feature->getGeometry();
if ( featureGeom && featureGeom->isValid() )
{
// test for trivial acceptance:
const Bounds bounds = featureGeom->getBounds();
if ( !bounds.isValid() )
{
//nop
}
else if ( extent.contains( bounds ) )
{
keepFeature = true;
newExtent.expandToInclude( bounds );
}
// then move on to the cropping operation:
else
{
if ( !poly.valid() )
{
poly = new Symbology::Polygon();
poly->push_back( osg::Vec3d( extent.xMin(), extent.yMin(), 0 ));
poly->push_back( osg::Vec3d( extent.xMax(), extent.yMin(), 0 ));
poly->push_back( osg::Vec3d( extent.xMax(), extent.yMax(), 0 ));
poly->push_back( osg::Vec3d( extent.xMin(), extent.yMax(), 0 ));
}
osg::ref_ptr<Geometry> croppedGeometry;
if ( featureGeom->crop( poly.get(), croppedGeometry ) )
{
if ( croppedGeometry->isValid() )
{
feature->setGeometry( croppedGeometry.get() );
keepFeature = true;
newExtent.expandToInclude( croppedGeometry->getBounds() );
}
}
}
}
if ( keepFeature )
++i;
else
//.........这里部分代码省略.........
示例6: main
//.........这里部分代码省略.........
{
cropMethod = CropFilter::METHOD_CROPPING;
}
std::string destSRS;
while(arguments.read("--dest-srs", destSRS));
// Custom bounding box
Bounds bounds;
double xmin=DBL_MAX, ymin=DBL_MAX, xmax=DBL_MIN, ymax=DBL_MIN;
while (arguments.read("--bounds", xmin, ymin, xmax, ymax ))
{
bounds.xMin() = xmin;
bounds.yMin() = ymin;
bounds.xMax() = xmax;
bounds.yMax() = ymax;
}
std::string filename;
//Get the first argument that is not an option
for(int pos=1;pos<arguments.argc();++pos)
{
if (!arguments.isOption(pos))
{
filename = arguments[ pos ];
break;
}
}
if (filename.empty())
{
return usage( "Please provide a filename" );
}
//Open the feature source
OGRFeatureOptions featureOpt;
featureOpt.url() = filename;
osg::ref_ptr< FeatureSource > features = FeatureSourceFactory::create( featureOpt );
if (!features.valid())
{
OE_NOTICE << "Failed to open " << filename << std::endl;
return 1;
}
features->initialize();
const FeatureProfile* profile = features->getFeatureProfile();
if (!profile)
{
OE_NOTICE << "Failed to create a valid profile for " << filename << std::endl;
return 1;
}
std::string method = cropMethod == CropFilter::METHOD_CENTROID ? "Centroid" : "Cropping";
OE_NOTICE << "Processing " << filename << std::endl
<< " FirstLevel=" << firstLevel << std::endl
<< " MaxLevel=" << maxLevel << std::endl
<< " MaxFeatures=" << maxFeatures << std::endl
<< " Destination=" << destination << std::endl
<< " Layer=" << layer << std::endl
<< " Description=" << description << std::endl
<< " Expression=" << queryExpression << std::endl
<< " OrderBy=" << queryOrderBy << std::endl
<< " Method= " << method << std::endl
<< " DestSRS= " << destSRS << std::endl
<< std::endl;
Query query;
if (!queryExpression.empty())
{
query.expression() = queryExpression;
}
if (!queryOrderBy.empty())
{
query.orderby() = queryOrderBy;
}
osg::Timer_t startTime = osg::Timer::instance()->tick();
//buildTFS( features.get(), firstLevel, maxLevel, maxFeatures, destination, layer, description, query, cropMethod);
TFSPackager packager;
packager.setFirstLevel( firstLevel );
packager.setMaxLevel( maxLevel );
packager.setMaxFeatures( maxFeatures );
packager.setQuery( query );
packager.setMethod( cropMethod );
packager.setDestSRS( destSRS );
if (bounds.isValid())
{
packager.setLod0Extent(GeoExtent(osgEarth::SpatialReference::create( destSRS ), bounds));
}
packager.package( features, destination, layer, description );
osg::Timer_t endTime = osg::Timer::instance()->tick();
OE_NOTICE << "Completed in " << osg::Timer::instance()->delta_s( startTime, endTime ) << " s " << std::endl;
return 0;
}