[gdal-dev] Symlinks to VRTs

Even Rouault even.rouault at spatialys.com
Wed Mar 8 12:28:34 PST 2017


On mercredi 8 mars 2017 19:38:24 CET Luis Ressel wrote:
> Hello,
> 
> VRTs can reference other files by relative paths. Upon reading such a
> VRT, GDAL will evaluate the relative path based on the directory where
> the VRT resides. Now, imagine the following situation:
> 
> * There's a directory a/ containing several raster files and a VRT
>   referencing them.
> 
> * There's a second directory b/ containing a symlink to the VRT in a/ .
> 
> When I point GDAL at b/symlink.vrt, it will dereference the symlink
> before evaluating the relative paths inside the VRT (and thus search
> for the rasters in a/), whereas I would've expected GDAL to handle
> the symlink transparently and search for the rasters in b/ .
> 
> Is this the intended behaviour?

Given that the existing behaviour is a reasonable one, I'd say yes. That's said your use can can 
probably also makes sense.


> Unfortunately, I can't make much
> sense of the relevant code in gdal/frmts/vrt/vrtsources.cpp.

The relevant piece of code is in
https://github.com/OSGeo/gdal/blob/trunk/gdal/frmts/vrt/vrtdataset.cpp#L739

If you look a bit below in
https://github.com/OSGeo/gdal/blob/trunk/gdal/frmts/vrt/vrtdataset.cpp#L814
there's an open option ROOT_PATH that could be set to b/ to get the behaviour you wish.

Or you could add an open option, RESOLVE_SYMLINK=NO, to disable the stuff at
https://github.com/OSGeo/gdal/blob/trunk/gdal/frmts/vrt/vrtdataset.cpp#L745

Evn

-- 
Spatialys - Geospatial professional services
http://www.spatialys.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/gdal-dev/attachments/20170308/1f391496/attachment.html>


More information about the gdal-dev mailing list