On 9/3/2010 1:04 PM, Frank Warmerdam wrote:
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).
Hi Frank,
One thing that would be very nice is to change the name space for the
embedded shapelib function so libshp can be linked to a program with
ogr. I can see that using ogr has lots of benefits, but it is
complicated relative shapelib if that is all you need.
Back to the current problem, here is what shpdump reports and ogrinfo.
These both look ok.
-Steve
wood...@mappy:~/dev/elevation$ shpdump Streets.shp | head
Shapefile Type: Arc # of Shapes: 102958
File Bounds: ( -71.889, 42.157,0,0)
to ( -71.021, 42.734,0,0)
Shape:0 (Arc) nVertices=3, nParts=1
Bounds:( -71.563, 42.267, 0, 0)
to ( -71.563, 42.267, 0, 0)
( -71.563, 42.267, 0, 0) Ring
( -71.563, 42.267, 0, 0)
ogrinfo 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)
L_REFADDR: Integer (10.0)
L_NREFADDR: Integer (10.0)
L_SQLNUMF: String (12.0)
L_SQLFMT: String (16.0)
L_CFORMAT: String (16.0)
R_REFADDR: Integer (10.0)
R_NREFADDR: Integer (10.0)
R_SQLNUMF: String (12.0)
R_SQLFMT: String (16.0)
R_CFORMAT: String (16.0)
L_AC5: String (35.0)
L_AC4: String (35.0)
L_AC3: String (35.0)
L_AC2: String (35.0)
L_AC1: String (35.0)
R_AC5: String (35.0)
R_AC4: String (35.0)
R_AC3: String (35.0)
R_AC2: String (35.0)
R_AC1: String (35.0)
L_POSTCODE: String (11.0)
R_POSTCODE: String (11.0)
MTFCC: Integer (5.0)
PASSFLG: String (1.0)
DIVROAD: String (1.0)
OGRFeature(Streets):0
LINK_ID (Integer) = 40037470
NAME (String) = I- 90
L_REFADDR (Integer) = 0
L_NREFADDR (Integer) = 0
L_SQLNUMF (String) = (null)
L_SQLFMT (String) = (null)
L_CFORMAT (String) = (null)
R_REFADDR (Integer) = 0
R_NREFADDR (Integer) = 0
R_SQLNUMF (String) = (null)
R_SQLFMT (String) = (null)
R_CFORMAT (String) = (null)
L_AC5 (String) = (null)
L_AC4 (String) = (null)
L_AC3 (String) = Middlesex
L_AC2 (String) = MA
L_AC1 (String) = US
R_AC5 (String) = (null)
R_AC4 (String) = Hopkinton
R_AC3 (String) = Middlesex
R_AC2 (String) = MA
R_AC1 (String) = US
L_POSTCODE (String) = (null)
R_POSTCODE (String) = (null)
MTFCC (Integer) = 1100
PASSFLG (String) = (null)
DIVROAD (String) = Y
LINESTRING (-71.563116999999991
42.267372999999999,-71.563024999999996 42.267412999999998,-71.562956
42.267443)
...
_______________________________________________
gdal-dev mailing list
[email protected]
http://lists.osgeo.org/mailman/listinfo/gdal-dev