[Gdal-dev] OGR: C API for Polygon/Multipolygon?

Frank Warmerdam warmerdam at pobox.com
Tue Dec 9 16:58:25 EST 2003


gdal-dev-admin at remotesensing.org wrote:
> On Tue, 9 Dec 2003 gdal-dev-admin at remotesensing.org wrote:
> 
> 
>>For reasons that seemed good at the time, I did not make some of the C
>>geometry functions mirror the C++ that closely.  To access the rings of
>>polygons you use OGR_G_GetGeometryRef().  To find out how many rings there
>>are use OGR_G_GetGeometryCount().  This essentially treats polygons as a
>>contain of rings.  You then fetch the points from the rings the same way
>>you would with a linestring.
> 
> 
> Thank you!  I have polygons getting drawn now.  Was pulling my hair
> out trying to decide whether I needed to implement some C wrappers
> for some C++ functions myself.
> 
> Here are the types that I have in my code:
> 
>   case 1:             // Point
>   case 4:             // MultiPoint
>   case 0x80000001:    // Point25D
>   case 0x80000004:    // MultiPoint25D
>   case 2:             // LineString (polyline)
>   case 5:             // MultiLineString
>   case 0x80000002:    // LineString25D
>   case 0x80000005:    // MultiLineString25D
>   case 3:             // Polygon
>   case 6:             // MultiPolygon
>   case 0x80000003:    // Polygon25D
>   case 0x80000006:    // MultiPolygon25D
>   case 7:             // GeometryCollection
>   case 0x80000007:    // GeometryCollection25D
> 
> Should I assume that for ALL of the more complicated types I just
> need to check how many Geometries there are via
> OGR_G_GetGeometryCount() and then iterate through each of these
> subgeometries, treating them as the simpler types?

Curt,

Yes. Everything but Point, Point25D, LineString, and LineString25D
are treated as if there were collections from the C API point of
view.

Best regards,
-- 
---------------------------------------+--------------------------------------
I set the clouds in motion - turn up   | Frank Warmerdam, warmerdam at pobox.com
light and sound - activate the windows | http://pobox.com/~warmerdam
and watch the world go round - Rush    | Geospatial Programmer for Rent





More information about the Gdal-dev mailing list