本文整理汇总了C++中GeoExtent::intersects方法的典型用法代码示例。如果您正苦于以下问题:C++ GeoExtent::intersects方法的具体用法?C++ GeoExtent::intersects怎么用?C++ GeoExtent::intersects使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类GeoExtent
的用法示例。
在下文中一共展示了GeoExtent::intersects方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
bool
GeoPointList::intersects( const GeoExtent& ex ) const
{
if ( ex.isInfinite() )
return true;
//TODO: srs transform
if ( ex.isPoint() ) // do a point-in-polygon test
{
const GeoPoint& point = ex.getSouthwest();
bool result = false;
const GeoPointList& polygon = *this;
for( unsigned int i=0, j=polygon.size()-1; i<polygon.size(); j = i++ )
{
if ((((polygon[i].y() <= point.y()) && (point.y() < polygon[j].y())) ||
((polygon[j].y() <= point.y()) && (point.y() < polygon[i].y()))) &&
(point.x() < (polygon[j].x()-polygon[i].x()) * (point.y()-polygon[i].y())/(polygon[j].y()-polygon[i].y())+polygon[i].x()))
{
result = !result;
}
}
return result;
}
else // check for all points within extent -- not actually correct //TODO
{
GeoExtent e;
for( GeoPointList::const_iterator i = begin(); i != end(); i++ )
{
if ( i == begin() ) e = GeoExtent( *i, *i );
else e.expandToInclude( *i );
}
return e.intersects( ex );
}
}
示例2: 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 );
}
}
}
示例3: exclusive
//NOTE: this method assumes the input extent is the same SRS as
// the terrain profile SRS.
void
TileNodeRegistry::setDirty(const GeoExtent& extent,
unsigned minLevel,
unsigned maxLevel)
{
Threading::ScopedWriteLock exclusive( _tilesMutex );
bool checkSRS = false;
for( TileNodeMap::iterator i = _tiles.begin(); i != _tiles.end(); ++i )
{
const TileKey& key = i->first;
if (minLevel <= key.getLOD() &&
maxLevel >= key.getLOD() &&
extent.intersects(i->first.getExtent(), checkSRS) )
{
i->second->setDirty();
}
}
}
示例4:
bool
TileSource::hasDataInExtent( const GeoExtent& extent ) const
{
//If no data extents are provided, just return true
if ( _dataExtents.size() == 0 )
return true;
bool intersects = false;
for (DataExtentList::const_iterator itr = _dataExtents.begin(); itr != _dataExtents.end(); ++itr)
{
if ( extent.intersects( *itr ) )
{
intersects = true;
break;
}
}
return intersects;
}
示例5: switch
// poly clipping algorithm Aug 2007
bool
cropPolygonPart( const GeoPointList& initial_input, const GeoExtent& window, GeoPartList& final_outputs )
{
// trivial rejection for a non-polygon:
if ( initial_input.size() < 3 )
{
return false;
}
// check for trivial acceptance.
if ( window.contains( initial_input ) )
{
final_outputs.push_back( initial_input );
return true;
}
// prepare the list of input parts to process.
GeoPartList inputs;
inputs.push_back( initial_input );
// run the algorithm against all four sides of the window in succession.
for( UINT stage = 0; stage < 4; stage++ )
{
GeoPoint s1, s2;
switch( stage )
{
case STAGE_SOUTH: s1 = window.getSouthwest(), s2 = window.getSoutheast(); break;
case STAGE_EAST: s1 = window.getSoutheast(), s2 = window.getNortheast(); break;
case STAGE_NORTH: s1 = window.getNortheast(), s2 = window.getNorthwest(); break;
case STAGE_WEST: s1 = window.getNorthwest(), s2 = window.getSouthwest(); break;
}
// output parts to send to the next stage (or to return).
GeoPartList outputs;
// run against each input part.
for( GeoPartList::iterator i = inputs.begin(); i != inputs.end(); i++ )
{
//GeoPointList& input = *i;
GeoPointList input = *i;
scrubPart( input );
// trivially reject a degenerate part (should never happen ;)
if ( input.size() < 3 )
{
continue;
}
// trivially accept if the window contains the entire extent of the part:
GeoExtent input_extent;
input_extent.expandToInclude( input );
// trivially accept when the part lies entirely within the line:
if ( extentInsideOrOnLine( input_extent, s1, s2 ) )
{
outputs.push_back( input );
continue;
}
// trivially reject when there's no overlap:
if ( !window.intersects( input_extent ) || extentInsideOrOnLine( input_extent, s2, s1 ) )
{
continue;
}
// close the part in preparation for cropping. The cropping process with undo
// this automatically.
input.push_back( input.front() );
// 1a. Traverse the part and find all intersections. Insert them into the input shape.
// 1b. Create a traversal-order list, ordering the isect points in the order in which they are encountered.
// 1c. Create a spatial-order list, ordering the isect points along the boundary segment in the direction of the segment.
GeoPointList working;
UINTList traversal_order;
UINTList spatial_order;
GeoPoint prev_p;
bool was_inside = true;
for( UINT input_i = 0; input_i < input.size(); input_i++ )
{
const GeoPoint& p = input[ input_i ];
bool is_inside = pointInsideOrOnLine( p, s1, s2 );
if ( input_i > 0 )
{
if ( was_inside != is_inside ) // entering or exiting
{
GeoPoint isect_p;
if ( getIsectPoint( prev_p, p, s1, s2, /*out*/ isect_p ) )
{
working.push_back( isect_p );
traversal_order.push_back( working.size()-1 );
spatialInsert( spatial_order, working.size()-1, stage, working );
}
else
{
osgGIS::notify( osg::WARN )
<< "getIsectPoint failed" << std::endl;
}
//.........这里部分代码省略.........