Toggle Individual KML Layers

classic Classic list List threaded Threaded
5 messages Options
David David
Reply | Threaded
Open this post in threaded view
|

Toggle Individual KML Layers

A KML file can have a lot of different items in it and can have nested folders to organize the data.  How is the KML data loaded from a file added to the scene?  Will osgEarth create a hierarchy of scene nodes that more or less matches the organization of the KML file?

What I'm ultimately after is the ability to create a tree view of the KML files that are loaded to let the user go in to turn layers on and off rather than simply toggling the entire KML file and all of its contents on and off.
David David
Reply | Threaded
Open this post in threaded view
|

Re: Toggle Individual KML Layers

So I loaded a sample KML file that had two Folders (siblings, not nested), and then I wrote the osg::Node to file, and it does look like it's creating a separate osg::Group for each Folder.  It does not appear that the Folder names get applied to the Folder Groups.  I'm guessing this wouldn't be very difficult to add to the KML driver.
David David
Reply | Threaded
Open this post in threaded view
|

Re: Toggle Individual KML Layers

So looking at the KML plugin, it does get the name from the Folder (for any feature, really) and sets it on the AnnotationData, just not on the node (KML_Feature.cpp, line 61, osgEarth 2.7).  This didn't get written to the .osg file, so I just didn't see it.

That's probably good enough I think?  Does this sound like the right approach to build a tree view of a loaded KML file, to just recursively parse the top level osg::Node that gets returned and read the AnnotationData for each osg::Group?
gwaldron gwaldron
Reply | Threaded
Open this post in threaded view
|

Re: Toggle Individual KML Layers

Yes, exactly. In fact the "--kml-ui" argument to osgearth_viewer does exactly that:

https://github.com/gwaldron/osgearth/blob/master/src/osgEarth/ExampleResources.cpp#L184

(It's just an example but you can get the idea.)
Glenn Waldron / Pelican Mapping
David David
Reply | Threaded
Open this post in threaded view
|

Re: Toggle Individual KML Layers

Perfect!  Just wanted to make sure I wasn't over complicating things.  Thanks!