[gdal-dev] adding features to a layer/dataset...

Even Rouault even.rouault at spatialys.com
Wed Jun 26 13:00:05 PDT 2019


Shayne,

> 
> I have a vector GDALDataset that is shared between two applications running
> on different machines. Both applications call GDALOpenEx(...) to open the
> shapefile.shp with flags GDAL_OF_VECTOR and GDAL_OF_SHARED flags set to
> open the dataset. The dataset only has one layer associated with it and the
> shapefile format is the ESRI shapefile.
> 

GDAL_OF_SHARED is for sharing the same dataset handle in the same process, not 
for sharing datasets from several machines.

> After opening the dataset in both applications, the first application
> creates a new feature and adds it to the layer. The resulting shapefile on
> disk shows that this is working when I inspect the contents of the
> shapefile with ogrinfo -al shapefile.shp. The new feature has been added as
> expected with a feature count = 1.
> 
> Is there a way to update the second application to get the changes to the
> layer made by the first application? I've tried doing layer->SyncToDisk()
> in the second application but this has no affect. Do I have to close the
> layer/dataset and reopen it in the second application to get the changes
> made by the first application?

Yes, GDAL doesn't handle synchronization/concurrent edition of shapefiles (or 
any other file based formats), so if a file has been changed outside of GDAL, 
you have to close and reopen the dataset to be sure that GDAL sees the changes 
(sometimes you might see them, or some of them, while keeping the dataset 
open, but it would be too fragile to rely on that)

Even

-- 
Spatialys - Geospatial professional services
http://www.spatialys.com


More information about the gdal-dev mailing list