Opened 13 years ago

Closed 13 years ago

Last modified 12 years ago

#1211 closed enhancement (fixed)

Relative paths within QGIS project file

Reported by: springmeyer Owned by: nobody
Priority: minor: annoyance Milestone: Version 1.0.3
Component: Project Loading / Saving Version: Trunk
Keywords: relative path Cc:
Must Fix for Release: No Platform: Debian
Platform Version: Awaiting user input: no

Description

It would be extremely useful to allow for the use of relative paths to files loaded within a Qgis project file that rest on the filesystem. This would be a user controlled setting so that when checked project files by default store the relative paths to loaded files.

Change History (8)

comment:1 Changed 13 years ago by jef

see also #1665

comment:2 Changed 13 years ago by springmeyer

Any core devs able to give a broad overview of where and how this patch might be implemented?

I've yet to dive into qgis c++ code, but I may have an occasion to soon, and any head starts would be very welcome.

Also, if/once relative paths are supported QGIS may have the same issue as Mapnik - e.g. what are they relative too? Ideally the paths will be interpreted relative to the XML project file (rather than the location of the QGIS process), and in Mapnik this took some extra effort: http://trac.mapnik.org/ticket/326

See also http://trac.mapnik.org/ticket/324

comment:3 Changed 13 years ago by wonder

Some insights:

  • raster layers are instantiated with a GDAL specific string, I believe currently only file-based datasets are supported in qgis
  • vector layers are instantiated with their URI strings which are specific for every vector data provider
  • some vector providers are file based (gpx), others database based (postgres) and I think ogr provider is mixed (supporting both files / databases)

So, being able to detect which URI is a file would enable you cut the paths to relative when saving projects. Being relative to project's path is surely the most intuitive way.

Maybe there are some more places in project file that use absolute paths... but these are the critical ones.

I would suggest to keep absolute paths default and just allow relative paths as an option. I don't know where - maybe to project settings dialog.

Hope that helps Martin

comment:4 in reply to:  3 Changed 13 years ago by jef

Resolution: fixed
Status: newclosed

Should be fixed in r10854 for single layer file data datasources

QGIS now tries to interpret the data source name of each maplayer as filename and if that doesn't exists tries to prepend the project files path, if that succeeds, that filename is taken, otherwise the data source uri is left untouched.

Obviously that'll only work if the uri actually just contains the filename. This is true for instance for single layer OGR data sources like shapefiles.

SVG symbol are now also looked up in the project path if everything else fails.

Feel free to reopen, if you think this isn't sufficient or inadvisable.

comment:5 Changed 13 years ago by springmeyer

for reference: http://www.mail-archive.com/qgis-user@lists.osgeo.org/msg02353.html

I'm not quite following what the above commit does. I'll need to look more closely.

In general though, don't we need a user option like Martin wrote about in the above thread? Projects should either be in absolute path storage mode (if users want the ability to move project files around freely) or in relative path mode (if users want to move project files along with their file datasources in the same folder bundle).

comment:6 in reply to:  5 Changed 13 years ago by jef

Replying to springmeyer:

Projects should either be in absolute path storage mode (if users want the ability to move project files around freely) or in relative path mode (if users want to move project files along with their file datasources in the same folder bundle).

added in r10874

comment:7 Changed 12 years ago by Coatman

The ability to store relative paths for raster files should be incorporated in QGIS version 1.2.0 Daphnis project files. I am using the 1 Sep 2009 version of QGIS 1.2.0, but do not see the ability to specify storing a relative, as opposed to an absolute, path for a raster file. Please advise how to specify storing a relative path.

comment:8 in reply to:  7 Changed 12 years ago by lutra

Replying to Coatman:

The ability to store relative paths for raster files should be incorporated in QGIS version 1.2.0 Daphnis project files. I am using the 1 Sep 2009 version of QGIS 1.2.0, but do not see the ability to specify storing a relative, as opposed to an absolute, path for a raster file. Please advise how to specify storing a relative path.

see #1905

Note: See TracTickets for help on using tickets.