Opened 17 years ago

Closed 15 years ago

Last modified 15 years ago

#767 closed enhancement (fixed)

Only one KML vector layer loaded

Reported by: didge Owned by: mhugent
Priority: minor: annoyance Milestone:
Component: OGR Layer support Version: Trunk
Keywords: kml ogr s57 Cc: falahdab
Must Fix for Release: No Platform: Debian
Platform Version: Awaiting user input: no

Description

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.

Attachments (3)

bug767fix.diff (30.1 KB ) - added by falahdab 15 years ago.
First try at fixing the 767 OGR multilayer bug
bug767_090128.tar.gz (9.3 KB ) - added by falahdab 15 years ago.
Second try. This time, the sublayer fonctionality is added to QgisApp.
bug767_090129.diff (21.5 KB ) - added by falahdab 15 years ago.
Version 3 of the OGR multilayer patch

Download all attachments as: .zip

Change History (14)

comment:1 by timlinux, 16 years ago

Milestone: Version 1.0.0Version 2.0.0

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.

Regards

Tim

in reply to:  1 comment:2 by jef, 16 years ago

Replying to 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.

comment:3 by timlinux, 16 years ago

Hi right this should be addressed by the your proposal which suggested refactoring so we have:

  • provider
    • dataset
      • layer

(with apologies if I dont recall exact terminology). I guess it will be good to leave this bug against 2.0 for now.

comment:4 by falahdab, 15 years ago

Keywords: s57 added

Hi.

I started a discussion about S57 support in this thread: http://lists.osgeo.org/pipermail/qgis-user/2009-January/004288.html

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.

Florian

by falahdab, 15 years ago

Attachment: bug767fix.diff added

First try at fixing the 767 OGR multilayer bug

comment:5 by falahdab, 15 years ago

Hello guys.

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.

Florian

comment:6 by wonder, 15 years ago

Cc: falahdab added

Florian,

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 :)

Martin

by falahdab, 15 years ago

Attachment: bug767_090128.tar.gz added

Second try. This time, the sublayer fonctionality is added to QgisApp.

comment:7 by falahdab, 15 years ago

Hi all.

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. Florian

comment:8 by wonder, 15 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.

Martin

by falahdab, 15 years ago

Attachment: bug767_090129.diff added

Version 3 of the OGR multilayer patch

comment:9 by falahdab, 15 years ago

Hi.

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!

Florian

comment:10 by wonder, 15 years ago

Milestone: Version 2.0.0Version 1.1.0
Resolution: fixed
Status: newclosed

Florian, the patch looks fine. I've done some modifications to it and applied to trunk in r10065.

Thanks for the work!

comment:11 by (none), 15 years ago

Milestone: Version 1.1.0

Milestone Version 1.1.0 deleted

Note: See TracTickets for help on using tickets.