Frank,
I have a few considerations about NHD database support in the OGR that I'd like to discuss before I start fixing it.
1) Incomplete geometry types coverage
In OGRPGeoTableLayer::Initialize(), switch block decoding SHPT_* values to OGRwkbGeometryType does not include surface types like Polygon or MultiPolygon.
There are only Point, LineString and MultiPoint types decoded.
Is this intentional and correct or something is not finished here?
2) OGR geometry type is not set
The type decoded in point 1) is not set for PGeo layer.
The poFeatureDefn->SetGeomType() call in
ogr/ogrsf_frmts/pgeo/ogrpgeotablelayer.cpp:188
is commented and has no effect.
It results in setting wkbUnknown type for all layers in PGeo database.
There is a comment that seems to explain it:
So for now we just always return wkbUnknown.
but I'm not sure if it should apply to all geometry types or it is supposed to apply only to linear types.
Anyway, setting geometry to wkbUnknown, for PGeo->PG translation, results in setting PostGIS geometry type to GEOMETRY.
3) Reading Shape of unknown type
AFAI debugged and analysed the problem correctly, the main reason of empty geometries transfer to PostGIS is that PGeo Shape features are incorrectly recognized in OGR,
and these geometries are not transfered to PostGIS.
For example - layer NDHArea
- PGeo features include geometry
- layer NHDArea reports Shape type = 19 which value does not exist in Shapefile types (shapefil.h:152).
- OGRPGeoLayer::createFromShapeBin() returns NULL geometry
What is the geometry of ShapeType = 19 ?
Does list of Shape types defined in Shapelib cover all types from ESRI Personal Geodatabase, or are there extensions to Shapefile types possible in PGeo?
4) Commented blocks of PGeo driver
Why the code reading MultiPoint geometries in createFromShapeBin() function is commented?
Also, there is code reading surface geometries, but as I'm writing in point 1) above, these types like Polygon and MultiPolygon are not set anywhere.
I think these issues above should be reviewed and solved in order to fix geometry transfer problem.