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

Handle 'inbuilt:' vector uri #39656

Merged
merged 2 commits into from Oct 29, 2020
Merged

Handle 'inbuilt:' vector uri #39656

merged 2 commits into from Oct 29, 2020

Conversation

rduivenvoorde
Copy link
Contributor

This is take 2 to make it possible to use the inbuilt-vector data (world map etc) to be used in PyQGIS etc:

iface.addVectorLayer('inbuilt:/data/world_map.gpkg|layername=countries', 'Countries', 'ogr')

First take was: #39175 There @nyalldawson proposed to do it not ogr-specific but on a higher level. This is my first attempt to do it as he described there: #39175 (review)

Not sure if that was what he meant. I think more code has to get rewritten here (as for example now a inbuilt-uri WITHOUT layername-part will not load AND not popup the 'choose layer dialog', because the vectorLayerPath is const...
Should I create a copy of it and use that in the whole function?
Or am I totally wrong anyway.

One argument why I like #39175 actually better is that (untill now) inbuild is only used with OGR provider (and it is/was a oneline change). But feel free to disagree/comment or stop me from trying :-)

Also note that my proposed plan B in #39175

iface.addVectorLayer(QgsApplication.pkgDataPath() + '/resources/data/world_map.gpkg|layername=Countries', '', 'ogr')

actually does not work on Linux distro installs, because the gpkg in the resource is not readable by the average user apparently.

@github-actions github-actions bot added this to the 3.18.0 milestone Oct 27, 2020
src/app/qgisapp.cpp Outdated Show resolved Hide resolved
@rduivenvoorde
Copy link
Contributor Author

Thanks @nyalldawson this is what it should be. Now I understand better your reasoning. And also removing the "|layername=countries" from the uri results in he 'choose layer' popup!
If tests pass, is this something to be backported into 3.16?

@rduivenvoorde
Copy link
Contributor Author

I'm looking into adding a python test (for the inbuilt: uri), but wondering where to put it...

@nyalldawson nyalldawson merged commit 1132494 into qgis:master Oct 29, 2020
@nyalldawson
Copy link
Collaborator

I'm looking into adding a python test (for the inbuilt: uri), but wondering where to put it...

There's no real infrastructure in place for unit test QgisApp methods.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants