当前位置: 首页>>代码示例>>C++>>正文


C++ GeoExtent::getSoutheast方法代码示例

本文整理汇总了C++中GeoExtent::getSoutheast方法的典型用法代码示例。如果您正苦于以下问题:C++ GeoExtent::getSoutheast方法的具体用法?C++ GeoExtent::getSoutheast怎么用?C++ GeoExtent::getSoutheast使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在GeoExtent的用法示例。


在下文中一共展示了GeoExtent::getSoutheast方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: if

bool
cropLinePart( const GeoPointList& part, const GeoExtent& extent, GeoPartList& output )
{
    GeoPartList working_parts;
    working_parts.push_back( part );

    for( UINT s=0; s<4; s++ )
    {
        GeoPartList new_parts;

        GeoPoint s1, s2;
        switch( s )
        {
            case 0: s1 = extent.getSouthwest(), s2 = extent.getSoutheast(); break;
            case 1: s1 = extent.getSoutheast(), s2 = extent.getNortheast(); break;
            case 2: s1 = extent.getNortheast(), s2 = extent.getNorthwest(); break;
            case 3: s1 = extent.getNorthwest(), s2 = extent.getSouthwest(); break;
        }

        for( UINT part_i = 0; part_i < working_parts.size(); part_i++ )
        {
            bool inside = true;
            GeoPoint prev_p;
            GeoPointList current_part;

            const GeoPointList& working_part = working_parts[ part_i ];
            for( UINT point_i = 0; point_i < working_part.size(); point_i++ )
            {
                const GeoPoint& p = working_part[ point_i ];

                if ( pointInsideOrOnLine( p, s1, s2 ) )
                {
                    if ( inside )
                    {
                        current_part.push_back( p );
                    }
                    else if ( prev_p.isValid() )
                    {
                        GeoPoint isect_p;
                        if ( getIsectPoint( prev_p, p, s1, s2, /*out*/ isect_p ) )
                        {
                            current_part.push_back( isect_p );
                            current_part.push_back( p );
                        }
                    }
                    inside = true;
                }
                else // outside.
                {
                    if ( inside && point_i > 0 ) // inside heading out
                    {
                        GeoPoint isect_p;
                        if ( getIsectPoint( prev_p, p, s1, s2, /*out*/ isect_p ) )
                        {
                            current_part.push_back( isect_p );
                            if ( current_part.size() > 1 )
                                new_parts.push_back( current_part );
                            current_part = GeoPointList();
                        }
                    }
                    inside = false;
                }

                prev_p = p;
            }

            if ( current_part.size() > 1 )
                new_parts.push_back( current_part );
        }

        working_parts.swap( new_parts );
    }

    output.swap( working_parts );
    return true;
}
开发者ID:aarnchng,项目名称:osggis,代码行数:76,代码来源:CropFilter.cpp

示例2: 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;
                        }
//.........这里部分代码省略.........
开发者ID:aarnchng,项目名称:osggis,代码行数:101,代码来源:CropFilter.cpp


注:本文中的GeoExtent::getSoutheast方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。