Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

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.

share|improve this question
    
@KirkKuykendall What's foss4g? –  jglouie Mar 15 '13 at 13:26
1  
"Free and open source software for geospatial". We probably should add more info to the tag wiki. –  Kirk Kuykendall Mar 15 '13 at 13:30
add comment

2 Answers 2

up vote 3 down vote accepted

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.

share|improve this answer
add comment

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;
        }
     });
}
share|improve this answer
    
+1 Very cool - I won't look into it (switched projects) but this would've been nice to know about back then :) –  jglouie Mar 20 at 3:29
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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