Shayne,
To solve your problem, given the constraints the Even explained, you
probably need to do something like:
* program that is writing to shapefile
- creates a socket or pipe
- open the file for exclusive access
- after it updates the shapefile
- close the file
- writes to the socket a message like "updated"
* program that need to read the shapefile
- opens socket or pipe created by first program
- waits on read from socket for a message
- on getting "updated" message
- opens the shapefile for read
- reads the data, then closes the file
- processes the shape data
- loops back to wait on read from socket
You also need a shared network filesystem that supports opening the
shapefile exclusively for both read and write operations so the file is
not overwritten while it is being accessed.
All that said, this is not really a GDAL issue, and you probably need to
get advice from a network programming expert because there are issues
like handling trying to open the file when its locked, stale locks,
network failures, etc.
-Steve
On 6/26/2019 4:00 PM, Even Rouault wrote:
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
---
This email has been checked for viruses by Avast antivirus software.
https://www.avast.com/antivirus
_______________________________________________
gdal-dev mailing list
gdal-dev@lists.osgeo.org
https://lists.osgeo.org/mailman/listinfo/gdal-dev