2

I'm trying to find an open source package that can process KML-based network links. I am looking for more than a parser -- more along the lines of setting up timers for interval refreshing, handling <Update> elements, handling the <NetworkLinkControl> element, etc.

I'm am aware that Google Earth API does this for you, but I am in need of an alternate mechanism to mirror that.

3
  • @KirkKuykendall What's foss4g?
    – jglouie
    Commented Mar 15, 2013 at 13:26
  • 1
    "Free and open source software for geospatial". We probably should add more info to the tag wiki. Commented Mar 15, 2013 at 13:30
  • what about libkml - github.com/libkml/libkml ? (forked from google)
    – rkm
    Commented Mar 17, 2016 at 13:55

2 Answers 2

3

You could look at any open source software that handles the KML operations you need, and just adapt the software to suit your needs.

However since you asked for something to "help", I guess you're looking for something a bit more "library" like - an adapter that works over the top of libkml that does some of the work for you. If so, you might like to check the KMLDrawingLibrary code that is in FalconView. As I understand it, that library is really intended to be a re-usable component. There is a proof-of-concept using it in QGIS, as well as the main use in FalconView.

Disclaimer: I know of it, but I haven't tried embedding it myself.

2

The open source GIScore library within the OpenSextant project has some methods to recursively fetch contents of a Network Link feature by feature using StAX (STreaming API for XML processing) to parse the KML.

Library is written in Java and has low-level methods to manage network link content, but you'd still need to implement the timers, etc. It does, however, transparently handle absolute and relative links within both KML and KMZ files such that a referenced KML file within a KMZ with a relative link will be traversed automatically.

URL url = new URL(...);
KmlReader reader = new KmlReader(url);
// read all features from KML
for (IGISObject gisObj; (gisObj = reader.read()) != null; ) {
  // do something with the gis object; e.g. check for placemark, NetworkLink, etc.
}
// get list of network links that were retrieved from step above
List<URI> networkLinks = reader.getNetworkLinks();
if (!networkLinks.isEmpty()) {    
  // Now import features from all referenced network links.
  // if Networklinks have nested network links then they will be added to end
  // of the list and processed one after another. The handleEvent() callback method
  // below will be called with each feature (i.e. Placemark, GroundOverlay, etc.)
  // as it is processed in the target KML resources.
  reader.importFromNetworkLinks(
      new KmlReader.ImportEventHandler() {
            public boolean handleEvent(UrlRef ref, IGISObject gisObj)
        {
            // if gisObj instanceOf Feature, GroundOverlay, etc.
            // do something with the gisObj
            // return false to abort the recursive network link parsing
            return true;
        }
     });
}
1
  • +1 Very cool - I won't look into it (switched projects) but this would've been nice to know about back then :)
    – jglouie
    Commented Mar 20, 2014 at 3:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.