Thanks Even,

I coded up a similar test program, and the works here so I'm looking elsewhere.

Looks like ogdi on Debian installs libgdal.so so I just uninstalled ogdi, since I don't think I use it. And I'm rebuilding gdal without that just to make sure I have a clean system without any rouge libs hanging around.

Then I will get back to debugging this.

-Steve W

On 9/3/2010 1:43 PM, Even Rouault wrote:
Le vendredi 03 septembre 2010 18:45:56, Stephen Woodbridge a écrit :
Hi all,

Trying to convert a shapelib program over to OGR and have to say it is
very complicated.

No, it's just that you are not yet accustomed to use it ;-)


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

Well, this is really weird. I've just tried the following code that is really
a stand-alone version of your code:

#include<ogr_api.h>

int main(int argc, char* argv[])
{
     OGRRegisterAll();
     OGRDataSourceH  hDSin = OGROpen( argv[1], FALSE, NULL );
     OGRLayerH hLayerIn = OGR_DS_GetLayer( hDSin, 0 );
     OGRFieldDefnH hFDefnIn = OGR_L_GetLayerDefn( hLayerIn );
     OGRwkbGeometryType layerGeomType = OGR_FD_GetGeomType( hFDefnIn );
     printf("%d\n", layerGeomType == wkbLineString);
     return 0;
}

when passed a shapefile with linestrings, it prints 1 as expected with both
trunk and 1.7 branch. You should try it on your streets.shp. If it returns 1,
so there must something subtly wrong on your code that perhaps valgrind could
detect. If it returns 0, hum, well no idea...


And OGR_L_GetGeomType( hLayerIn )  does not appear until 1.8.

You don't need it. This is just a convenience method that can provide speed-up
for some drivers. But as documented, it will be strictly equivalent to
OGR_FD_GetGeomType(OGR_L_GetLayerDefn(hLayerIn)).


ogrinfo -so Streets.shp Streets
INFO: Open of `Streets.shp'
        using driver `ESRI Shapefile' successful.

Layer name: Streets
Geometry: Line String
Feature Count: 102958
Extent: (-71.888528, 42.156701) - (-71.020913, 42.734315)
Layer SRS WKT:
(unknown)
LINK_ID: Integer (10.0)
NAME: String (80.0)
...

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

-Steve
_______________________________________________
gdal-dev mailing list
[email protected]
http://lists.osgeo.org/mailman/listinfo/gdal-dev

_______________________________________________
gdal-dev mailing list
[email protected]
http://lists.osgeo.org/mailman/listinfo/gdal-dev

Reply via email to