[Gdal-dev] FeatureDefn.getGeometryType and actual geometry type

Frank Warmerdam warmerdam at pobox.com
Sun Feb 4 15:01:14 EST 2007

Andrea Aime wrote:
> Frank Warmerdam ha scritto:
>> Andrea Aime wrote:
>> Andrea,
>> It is a known bug that I am very nervous about changing.  If I
>> were to change the declaration to multipolygon then I would have
>> to convert all polygon geometries to multipolygons which would no
>> doubt confuse and confound many users and applications.
> That's what we do, in fact, in the shapefile datastore.
> But we have always been doing this, so we don't have backwards
> compatibility issues.
> Maybe, you could add a flag to allow


Well, i'm not a huge fan of "adding more flags to control..." such things.
Perhaps though we could or should add a config option to enforce
rigerous geometry typing and then ensure it is enforced for all drivers.

>> I'm more likely to fallback to considering the layers of type Geometry -
>> ie. no known type of geometry.
>> In summary, you shouldn't trust the geometry types too much currently.
> Ouch... the issue is, in Geotools we need consistency between the
> declared geometry type and the actual one, or our internal checks will
> throw exceptions.
> Do you have a list of inconsistencies, or should I always use multi 
> geometry types, even when OGR tells me that we're going to get simple 
> ones? Oh, another possibility is to give up the classification and
> say I just have a generic Geometry, that may break some SLD styles 
> though...

It isn't necessarily always the case that the only problem is getting
multi types when expecting non-multi-types.  But that is generally the
issue.  For now the only way to be certain to be rigerous would be to
ignore the geometry types and treat all layers as generic geometries.

But from a practical point of view, I think the shapefile driver
is the only one likely to trigger problems.  So you could just add
an exception for it - perhaps forcing everything to the multi types
in your code.

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    | President OSGeo, http://osgeo.org

More information about the Gdal-dev mailing list