Ticket #87 (defect)

Opened 2 years ago

Last modified 2 years ago

DiskFeatureStore: 3D Polygons not handled

Status: assigned

Reported by: ludwig Assigned to: seang (accepted)
Priority: major Milestone: PCL 0.12
Component: Data Stores and Sources Version:
Keywords: Cc:

Shapefiles with 3D Polygons cause disk.py to throw an exception, as an index is out of range as the GeometryType? is not correctly reported from somewhere down below:

          schema.append(GeometryProperty('the_geom', homosrs=srs,
                            homotype=GEOM_MAP[ldef.GetGeomType()]))
   

This is what I see when running it in PDB:

(Pdb) print ldef.GetGeomType()0).GetGeomType()
-2147483645
(Pdb)

I wondered for a while what was different with this particular shapefile I was using, but it must be that I have Z values in there.

linux:/www/gisdata/polygons # ogrinfo yunnanpolygon.shp 
INFO: Open of `yunnanpolygon.shp'
using driver `ESRI Shapefile' successful.
1: yunnanpolygon (3D Polygon)

I have not investigate the internals of this any further.

The annoying thing about these error is that that corrupt the entire editing of Primagis maps: as Primagis tries to get all the ZCO data stores into the combobox for selection, when only one of the ZCO datastores is f..cked in some way, it will not let you edit any map and just displays the cryptic 'index error message'.

Change History

08/16/06 02:55:07: Modified by ludwig

This is definitely a 3D Shapefile issue. While 3D (or 2.5D) data cannot be seen on mapserver maps, I think at least the X and Y data should be available.

The first bits for handling 3D shapes that are missing is the mapping in disk.py for the geometry type as reported by ogr. The GEOM_MAP does not have the mapping set out. Extending the GEOM_MAP with the other geometry types from ogr is easy.

GEOM_MAP = {
    1: 'Point',
    2: 'LineString',
    3: 'Polygon',
  ....
    
    }

On a mapping point of view I would think that is a mistake to duplicate the key values from ogr.py, the safer way of coding this would be to take the ogr values, such as

GEOM_MAP = {
    ogr.wkbPoint: 'Point',
    ogr.wkbLineString: 'LineString',
    .....
    ogr.wkbPoint25D: 'Point25D',
    ...

That not only makes it clearer where the values come from and that they should not be altered in PCL, and if the ogr lib would ever change them, PCL would not have to change.

With this change, at least inspection of the features in 3D libs is possible in PCL.

Rendering however fails with the following error:

File "/opt/python243/lib/python2.4/site-packages/cartography/engine/mapserver/rendering.py", line 235, in render
    lo.draw(mo, im)
  File "/opt/python243/lib/python2.4/site-packages/mapscript.py", line 788, in draw
    def draw(*args): return _mapscript.layerObj_draw(*args)
MapServerError: msDrawShape(): General error message. Only polygon shapes can be drawn using a POLYGON layer definition.

I think the first change suggested should be made, I am not sure what changes would be required to draw only X and Y data from a 3D shapefile and whether this would affect mapserver code or could be done in PCL.

11/03/06 15:17:21: Modified by seang

  • status changed from new to assigned.
  • milestone changed from 0.11 to 0.12.

We should defer this to 0.12. It's going to be a significant effort to test and fix this. For 0.11, I'll caution users to process their data into 2D.