Feature request #767
Only one KML vector layer loaded
|Pull Request or Patch supplied:||Resolution:||fixed|
|Easy fix?:||No||Copied to github as #:||10826|
Current SVN of gdal has read support for KML now.
I added extention to QGIS so I can open KML files.
When I open the KML example of Google only one, the first layer is displayed but the file contains six layers of different type:
ogrinfo KML_Samples.kml 1: Placemarks (Point) 2: Highlighted Icon (Point) 3: Paths (Line String) 4: Google Campus (Polygon) 5: Extruded Polygon (Polygon) 6: Absolute and Relative (Polygon)
Only the placemarks are displayed.
#2 Updated by Jürgen Fischer about 13 years ago
Replying to [comment:1 timlinux]:
This is because QGIS doesnt support mixed geometry datasets. Future versions will, but for now I'm going to shift this to milestone 2.0.0 as it seems beyond what we can reasonably manage by 1.0.0.
I'm don't know if KML support mixed geometry layers. But this issue is because QGIS just considers the first layer of an OGR data source.
In this case there is no problem with mixed geometries. The six layers are of distinct geometry types and the user just needs be able to select one of them.
I proposed something like that in the "OGR merge", but didn't find the time yet to follow up on that.
#4 Updated by falahdab - over 12 years ago
I started a discussion about S57 support in this thread:
I have started working on the matter of multiple OGR layers support and I have modified the ogrprovider so as to be able to get the list of available layers back to a user plugin written in C++. This work is still sketchy, but I hope I will find time to improve it so as to include it soon into the main branch.
I will post a rapid explanation of what I have done so far soon so that you can send comments about this matter and my way of handling things.
#5 Updated by falahdab - over 12 years ago
I've juste posted a patch to this ticket.
This patch includes:
- a modified ogrprovider which implements the QStringList subLayers() method and which parses the uri to select the loaded layer. It is still supposed to be fully backward compatible. (Would require testing...)
- a plugin named ogrsublayers (in C++) which allows the user to select the layers he wants to load into qgis from an OGR datasource thanks to the new provider. The plugin is limited to ogr provider because it uses some ogr provider specific methods... You will find an included README file which explains how to use the plugin. I haven't done any art, so the icons are still the default plugin ones. No doubt you will agree with the fact that this not essential at this time.
I have successfully tested my work with my S57 datasource but I haven't tried other data formats.
Looking forward to hearing from you about this.
#6 Updated by Martin Dobias over 12 years ago
I've tried your plugin and it seems to work with one test layer I have.
While it does its job, I have some suggestions:
- I really think that this should be implemented directly in qgis application, not as a plugin. It's not very intuitive for users. I recommend you to do it in QgisApp::addVectorLayers() function. The logic can be simple - if the layer has only one sublayer, keep it as is. If there are more sublayers, let the user choose which ones he would like to load.
- use tree view (or widget) instead of table. Tree view with multiple columns and without decorated root items look much better than a table - despite the name, it's not necessary to use it just for trees :)
- it would be better to support selects with shift and ctrl
- it would be good to include also sublayer type (point/line/polygon) if possible
- the patch you've posted is missing CMakeLists.txt and ogrsublayers.png in plugin's directory. People usually don't like patches that fail to compile :)
#7 Updated by falahdab - over 12 years ago
wonder, thanks to your comments on my previous work.
I've posted my new work as bug767_090128.tar.gz.
The archive contains a new icon and the diff file for the other files that were modified/added.
The addVectorLayers method of QgisApp has been modified to call the sublayer selection dialog if there is any sublayer available in the file selected by the user. Moreover, a new menu entry and a new toolbar entry have been added so as to allow the user to load additionnal sublayers without having to browse the files again, just by selecting a layer from the same datasource (to save some time...)
The QListView has been converted to a QTreeWidget and now displays the geometry type of the layers. The user can also select the layers to load with Ctrl and Shift as usual.
This has been tested on the same datasources as before without problem.
Enjoy and comment.
#8 Updated by Martin Dobias over 12 years ago
Florian,I like the changes, good work! There are some small things I would like to resolve before commiting to trunk:
- the dialog should be implemented in src/app/ and not src/gui/ directory (that one is only for GUI library with reusable components)
- in my opinion it would be better not to have a special button for loading additional layers. My concern is that it's not clear what it should do with other providers etc. A better option for me is to do the choice only when loading a newly selected file. If the user wants to load some more sublayers, he can open that vector file again.
#9 Updated by falahdab - over 12 years ago
I have posted the third version of my patch in bug767_090129.diff.
The dialog is now part of src/app. Therefore, there is no modification to src/gui.
I've removed the QAction, the associated code in qgisapp and the icon. The user now has to select the "open vector layer" command each time he wants to change the loaded sublayers.
I've tested the new version with my previous dataset and with a multilayer KML file. Both work as expected.
Please test and comment!