[Gdal-dev] Shapefile feature deletion and feature count

Andrea Aime aaime at openplans.org
Sat Mar 10 11:24:24 EST 2007


Mateusz Loskot ha scritto:
> Andrea Aime wrote:
> It is also described in the manual of ESRI Shapefile format:
> 
> "The OGR shapefile driver supports rewriting existing shapes in a
> shapefile as well as deleting shapes. Deleted shapes are marked for
> deletion in the .dbf file, and then ignored by OGR. To actually remove
> them permanently (resulting in renumbering of FIDs)
> invoke the SQL 'REPACK ' via the datasource ExecuteSQL() method."
> 
> http://www.gdal.org/ogr/drv_shapefile.html

Ah, thank you :-)
Hmm... I'm wondering, is it really possible to use OGR without knowing
what kind of datasource you're dealing with? What I'm doing, is writing
a bridge between Geotools Datastore API and OGR, which should work for
any format supported by OGR, trying to cope with OGR driver differences
using only capabilities checks.

I'm using shapefile at the moment, but it's really one of the formats
I don't need to support, we already have a good shapefile reader/writer
in Geotools, I'm only using it because I can compare the OGR behaviour
with the gt2 one.

So far it seems I'll have to write a generic base infrastructure, and
then provide variant behavior with helper classes/subclasses to handle
the difference between various drivers. For example, Geotools
API requires me either not writing at all, or support all writing
features. To cope with this, I'll have to create classes that allow
me to move and rename layers for each different format I want to 
support, since most of the OGR data sources I'm interested with
do not support delete/update (Geotools is lacking on file based
data sources). That is, the idea is that if I want to mimic in place
update/delete, I'll really have to rewrite the file with a different
name/location, delete the original one, and finally move/rename the
new one.

Am I taking the right direction? OGR and Geotools API do not
have big differences on the surface, but quite a bit of significant
details are making me go from one blind spot to another :)

Cheers
Andrea



More information about the Gdal-dev mailing list