[gdal-dev] Need help if OGR C-API

Frank Warmerdam warmerdam at pobox.com
Fri Sep 3 13:04:13 EDT 2010


Stephen Woodbridge wrote:
> Hi all,
> 
> Trying to convert a shapelib program over to OGR and have to say it is 
> very complicated.
> 
> I'm using: GDAL 1.7.2, released 2010/04/23
> 
> At the moment I stuck on:
> 
>   hDSin = OGROpen( "Streets.shp", FALSE, NULL );
>   hLayerIn = OGR_DS_GetLayerByName( hDSin, "Streets" );
> 
>   hFDefnIn = OGR_L_GetLayerDefn( hLayerIn );
>   layerGeomType = OGR_FD_GetGeomType( hFDefnIn );
> 
> And always returns:   layerGeomType == wkbUnknown
> 
> And OGR_L_GetGeomType( hLayerIn )  does not appear until 1.8.
...

> So how do I get the geometry type of the shapefile?

Steve,

Hmm, that's odd.  You should be getting wkbLineString or wkbLineString25D.
Does ogrinfo report the layer type properly?   It is essentially using
the same mechanism.  Perhaps GDAL/OGR 1.7.2 did not always return the layer
geometry type - it is technically inaccurate to return wkbLineString since
the shapefile could also contain multilinestrings and we can't know unless
they are all read which we don't want to do on open.

The current trunk code reports linestring, but this is an area of behavior
on which I have vacillated (correctness vs. handiness).

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