[gdal-dev] Fail to open DBF without SHAPE_RESTORE_SHX options

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

[gdal-dev] Fail to open DBF without SHAPE_RESTORE_SHX options

vincent.loppin

Hello,

 

This mail is related to https://github.com/OSGeo/gdal/issues/1525

 

Quick recall :

 

We try to open DBF file using shapefile driver, but in our dataset we have empty SHP & SHX files (provided by customers, so we can't remove it).
To be able to open it, we use the SHAPE_RESTORE_SHX option to bypass shp reading.

 

This option usage sounds to be a bit dirty workaround, especially when there are a parameter bForceSingleFileDataSource   on OGRShapeDataSource::Open() method.

 

https://github.com/OSGeo/gdal/blob/0d7d762895f268d0c3ddaed5ddac3605c727e501/gdal/ogr/ogrsf_frmts/shape/ogrshapedatasource.cpp#L150

 

Maybe an open option could help us to deal with this case ? (FORCE_SINGLE_FILE_DATA_SOURCE)

 

Thanks,

 

--

Vincent Loppin

VirtualGeo SDK Technical Expert

DIGINEXT - Virtual Reality Division


_______________________________________________
gdal-dev mailing list
[hidden email]
https://lists.osgeo.org/mailman/listinfo/gdal-dev
Reply | Threaded
Open this post in threaded view
|

Re: Fail to open DBF without SHAPE_RESTORE_SHX options

Even Rouault-2
Vincent,

> Hello,
>
> This mail is related to https://github.com/OSGeo/gdal/issues/1525
>
> Quick recall :
>
> We try to open DBF file using shapefile driver, but in our dataset we have
> empty SHP & SHX files (provided by customers, so we can't remove it). To be
> able to open it, we use the SHAPE_RESTORE_SHX option to bypass shp reading.
>
> This option usage sounds to be a bit dirty workaround, especially when there
> are a parameter bForceSingleFileDataSource   on OGRShapeDataSource::Open()
> method.

Yes, a bit confusing. It means that you have a single layer dataset instead of
opening a directory of several shapefiles.

>
> https://github.com/OSGeo/gdal/blob/0d7d762895f268d0c3ddaed5ddac3605c727e501/
> gdal/ogr/ogrsf_frmts/shape/ogrshapedatasource.cpp#L150
>
> Maybe an open option could help us to deal with this case ?
> (FORCE_SINGLE_FILE_DATA_SOURCE)

This is a super particular use case to have 0-byte large .shp & .shx files
alongside a valid .dbf. Not sure we really want to support this, and I guess
other implementations would probably not like such datasets.

Another possibility is that you copy the .dbf file in a temporary directory
and open it. Or if you don't want to create a temporary file on the regular
filesystem, you could ingest it into RAM in a /vsimem/temp.dbf file and open
that one. You can use VSIIngestFile() for that.

Even

--
Spatialys - Geospatial professional services
http://www.spatialys.com
_______________________________________________
gdal-dev mailing list
[hidden email]
https://lists.osgeo.org/mailman/listinfo/gdal-dev