3

I have a project QGIS used in both Linux and Windows, synchronizing the working directory with dropbox. The project uses relative paths, so that the directory structure is observed only from the parent folder of the project.

Everything works fine except when I try to use a style with a "marker SVG" where I use to define "myFile.svg" that represent "defined by data properties".

The problem is that if I write the path of file in Windows format (path with backslashes), Linux (path with common bar) does not work and vice versa.

Is there any function to translate paths depending on the operating system used for? Or is there any way of knowing, in the expression editor which OS I'm using? I solve the latter case using a "case" and setting the appropriate path in each case.

5
  • May I ask you what do you mean by "synchronizing the working directory with dropbox" and how you do it? Commented Jan 16, 2015 at 13:36
  • I have the proyect in ProyectQGIS (a folder inside a dropbox directory in UBUNTU), sharinag myProectQGIS whit other dropbox user, in a Win7 PC. The proyect can be opened and saved in UBUNTU or Win7. Commented Jan 17, 2015 at 19:48
  • Ok. A bit off-topic: If you both happen to update your Dropbox folder very frequently, you can use the Synchronize QGIS with a directory plugin to get notifications in QGIS. Commented Jan 17, 2015 at 20:08
  • I couldn't replicate the problem you're facing. I tested it on GNU/Linux and WinXP (on a Virtual Machine), QGIS 2.6.1. The field value I used to set the path to the SVG file is: ./data/svg/myFile.svg. It doesn't matter where I open it (Lin or Win), the file is displayed properly without any change in the path. Might it be an issue of Win7 only? Commented Feb 12, 2015 at 16:14
  • Any reply on my last comment? I couldn't replicate your issue, are you still experiencing this or is the problem solved? Commented Feb 23, 2015 at 19:59

2 Answers 2

1

If you are only working on the data cross-platform, but retain the layer structure and styling, you could set up a Linux and a Windows project file, still sharing the same data sources.

Exchanging backslashes to slashes is a simple task with any good text editor, so updating the project files to the other OS should not be a great problem if necessary.

1
  • It's a good idea, but is a dinamic proyect, and the styling change constantly, and I want only save the proyect in one OS and open in the other. Commented Jan 17, 2015 at 19:55
0

There is a global variable qgis_os_name which can have values "windows", "linux" or "osx". You can use it to fix the separators if needed:

if(@qgis_os_name = 'windows',
replace("foo", '/', '\\'),
"foo")

(Remember to escape the \.)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.