예제 #1
0
static Symbology::Geometry*
exportPolygon( const geom::Polygon* input )
{
    Symbology::Polygon* output = 0L;
    const geom::LineString* outerRing = input->getExteriorRing();
    if ( outerRing )
    {
        const geom::CoordinateSequence* s = outerRing->getCoordinates();
        output = new Symbology::Polygon( s->getSize() );
        for( int j=0; j<s->getSize(); j++ ) 
        {
            const geom::Coordinate& c = s->getAt( j );
            output->push_back( osg::Vec3d( c.x, c.y, 0 ) ); 
        }
        output->rewind( Symbology::Ring::ORIENTATION_CCW );

        for( int k=0; k < input->getNumInteriorRing(); k++ )
        {
            const geom::LineString* inner = input->getInteriorRingN( k );
            const geom::CoordinateSequence* s = inner->getCoordinates();
            Symbology::Ring* hole = new Symbology::Ring( s->getSize() );
            for( int m = 0; m<s->getSize(); m++ )
            {
                const geom::Coordinate& c = s->getAt( m );
                hole->push_back( osg::Vec3d( c.x, c.y, 0 ) );
            }
            hole->rewind( Symbology::Ring::ORIENTATION_CW );
            output->getHoles().push_back( hole );
        }
    }
    return output;
}
예제 #2
0
Symbology::Polygon*
OgrUtils::createPolygon( OGRGeometryH geomHandle )
{
    Symbology::Polygon* output = 0L;

    int numParts = OGR_G_GetGeometryCount( geomHandle );
    if ( numParts == 0 )
    {
        int numPoints = OGR_G_GetPointCount( geomHandle );
        output = new Symbology::Polygon( numPoints );
        populate( geomHandle, output, numPoints );
        output->open();
    }
    else if ( numParts > 0 )
    {
        for( int p = 0; p < numParts; p++ )
        {
            OGRGeometryH partRef = OGR_G_GetGeometryRef( geomHandle, p );
            int numPoints = OGR_G_GetPointCount( partRef );
            if ( p == 0 )
            {
                output = new Symbology::Polygon( numPoints );
                populate( partRef, output, numPoints );
                //output->open();
                output->rewind( Symbology::Ring::ORIENTATION_CCW );
            }
            else
            {
                Symbology::Ring* hole = new Symbology::Ring( numPoints );
                populate( partRef, hole, numPoints );
                //hole->open();
                hole->rewind( Symbology::Ring::ORIENTATION_CW );
                output->getHoles().push_back( hole );
            }
        }
    }
    return output;
}