Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Delimitedtext layer saves absolute path when project in relative path mode #28968

Closed
qgib opened this issue Feb 1, 2019 · 10 comments
Closed
Labels
Bug Either a bug report, or a bug fix. Let's hope for the latter! High Priority Project Regression Something which used to work, but doesn't anymore

Comments

@qgib
Copy link
Contributor

qgib commented Feb 1, 2019

Author Name: Adam Liddell (@aaliddell)
Original Redmine Issue: 21150
Affected QGIS version: 3.4.4
Redmine category:project_loading/saving
Assignee: Alessandro Pasotti


When saving a project with 'Save paths' set to 'relative', the paths for any delimited text layers are saved as absolute 'file:///...' paths in the project file.

Steps to reproduce:

  • Create new project and set 'Save paths' to 'relative'
  • Add a delimited text layer, such as a CSV file
  • Save the project
  • Inspect the produced XML file, the 'layer-tree-layer' node will have an absolute path in the 'source' attribute
  • Any vector layers etc will have correct relative paths, as expected

Expected behaviour:
When in relative paths mode, the delimited text layer should save its source as a relative path

This breaks being able to produce shareable projects.
Manually rewriting the paths to be relative (e.g. file://../data/file.csv) still works when reloading the project, but on the next save they will be overwritten with absolute paths again.

@qgib
Copy link
Contributor Author

qgib commented Feb 1, 2019

Author Name: Giovanni Manghi (@gioman)


confirmed and if I'm not wrong this is a regression.


  • regression was changed from 0 to 1
  • category_id was changed from Data Provider/Delimited Text to Project Loading/Saving
  • priority_id was changed from Normal to High

@qgib
Copy link
Contributor Author

qgib commented Feb 2, 2019

Author Name: Alessandro Pasotti (@elpaso)


  • assigned_to_id was configured as Alessandro Pasotti

@qgib
Copy link
Contributor Author

qgib commented Feb 5, 2019

Author Name: Alessandro Pasotti (@elpaso)


Applied in changeset 22c22e8.


  • status_id was changed from Open to Closed
  • done_ratio was changed from 0 to 100

@qgib
Copy link
Contributor Author

qgib commented Feb 25, 2019

Author Name: Adam Liddell (@aaliddell)


I've tested on 3.6.0, which contains the above patch, and the issue is still present when following the original steps to reproduce.


  • status_id was changed from Closed to Reopened

@qgib
Copy link
Contributor Author

qgib commented Feb 25, 2019

Author Name: Alessandro Pasotti (@elpaso)


I cannot reproduce the bug, I explain it better:

What you originally filed was a bug because the csv path was not set as relative in the tag named "datasource" that is the real path of the data source, and that bug is now fixed: I cannot reproduce it after the patch and it is proteced by a test case which is not failing.

Btw, there is another place where the path is stored and you correctly mentioned it as 'layer-tree-layer', that value is never used inside QGIS (I honestly dont' know what is its purpose).

Did you really try to move the project in another folder (with its relative data) and reproduce the issue or did you just check for 'layer-tree-layer' 'source' value?

I'm pretty sure that the behavior that you described in the ticket is now fixed, it is not fixed the 'layer-tree-layer' 'source' path because it did not produce any effect.

Can you please confirm?


  • status_id was changed from Reopened to Feedback

@qgib
Copy link
Contributor Author

qgib commented Feb 25, 2019

Author Name: Adam Liddell (@aaliddell)


Yes, the absolute path is only appearing in the layer-tree-layer source value now. I wasn't aware that the field was not used within QGIS, hence the reopening when I noticed it was still there.
If it indeed has no effect, I agree this can close again; although it seems unusual that only the CSV nodes get an absolute path in that attribute whereas vector layers do not.

@qgib
Copy link
Contributor Author

qgib commented Feb 25, 2019

Author Name: Alessandro Pasotti (@elpaso)


In any event I'm going to fix 'layer-tree-layer' + 'source' too, to avoid any confusion.

The reason why it only affected CSV (well, more precisely, the reason why does not affect shapefiles) is that the CSV uri is internally stored like this:

'file:///home/Maps/test_set/DHH_facilities.csv?type=csv&detectTypes=yes&xField=Longitude&yField=Latitude&crs=EPSG:4326&spatialIndex=no&subsetIndex=no&watchFile=no'

while shapefile is stored like this:

'file:///home/Maps/test_set/DHH_facilities.shp'

the extra URL-like stuff was making the check for file existence to fail.

@qgib
Copy link
Contributor Author

qgib commented Feb 25, 2019

Author Name: Adam Liddell (@aaliddell)


Ok, that makes sense, thank you

@qgib
Copy link
Contributor Author

qgib commented Feb 25, 2019

Author Name: Alessandro Pasotti (@elpaso)


PR, fixes 'layer-tree-layer' + 'source' too: #9273


  • status_id was changed from Feedback to In Progress

@qgib
Copy link
Contributor Author

qgib commented Mar 8, 2019

Author Name: Alessandro Pasotti (@elpaso)


  • resolution was changed from to fixed/implemented
  • status_id was changed from In Progress to Closed
  • pull_request_patch_supplied was changed from 0 to 1

@qgib qgib closed this as completed Mar 8, 2019
@qgib qgib added Bug Either a bug report, or a bug fix. Let's hope for the latter! High Priority Project Regression Something which used to work, but doesn't anymore labels May 25, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Either a bug report, or a bug fix. Let's hope for the latter! High Priority Project Regression Something which used to work, but doesn't anymore
Projects
None yet
Development

No branches or pull requests

1 participant