本文整理汇总了C++中GeoExtent::contains方法的典型用法代码示例。如果您正苦于以下问题:C++ GeoExtent::contains方法的具体用法?C++ GeoExtent::contains怎么用?C++ GeoExtent::contains使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类GeoExtent
的用法示例。
在下文中一共展示了GeoExtent::contains方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
/* 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);
}
示例2:
bool
cropPointPart( const GeoPointList& part, const GeoExtent& extent, GeoPartList& output )
{
GeoPointList new_part;
for( UINT i=0; i<part.size(); i++ )
{
if ( extent.contains( part[i] ) )
new_part.push_back( part[i] );
}
output.push_back( new_part );
return true;
}
示例3: 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;
}
//.........这里部分代码省略.........