All Downloads are FREE. Search and download functionalities are using the official Maven repository.

src.gov.nasa.worldwind.ogc.kml.package.html Maven / Gradle / Ivy






    KML Parser Package


Provides classes for parsing KML and KMZ files and streams.

How to Parse a KML or KMZ File or Stream

  1. Create a {@link gov.nasa.worldwind.ogc.kml.KMLRoot} via one of its constructors, such as {@link gov.nasa.worldwind.ogc.kml.KMLRoot#KMLRoot(java.io.File)}, passing the KML or KMZ source to the constructor. A KMLRoot provides access to the KML contents. The source can be either a file, an input stream or a URL.
  2. Call {@link gov.nasa.worldwind.ogc.kml.KMLRoot#parse(Object[])} to parse the document.
  3. The KMLRoot class provides accessor methods for the kml element of the KML file, its root. The content includes the element's single attribute, hint, and the NetworkLinkControl and Feature elements it may contain. Once the root is parsed, use these methods to obtain objects representing these elements, and use the accessor methods of those objects in turn to obtain their contents.
  4. Each KML element defined in the KML specification has a corresponding class provided in this package. Each of those classes contains methods to obtain the element's contents as defined by the specification. The same is true for the other specifications KML uses: Atom, XAL and the GX extensions defined by Google. Use these classes to obtain the contents of individual elements of the KML file.
The classes in this package only read and parse a KML file. Mapping them to shapes, annotations and other World Wind objects is a separate step. World Wind provides default mappings for many KML elements, but an application is fully able to provide its own, and in some cases is expected to.

Extending the Classes

This package's classes are designed for easy behavior modification and replacement, and for straightforward addition of operations to be performed during parsing. See the description of {@link gov.nasa.worldwind.util.xml.AbstractXMLEventParser} for further information.

Relative References

Because the KML specification requires relative references within KML files to be resolved relative to the location of the file, a context is provided to resolve these references. The context is specific to the document type — file, stream, KML or KMZ — and is provided by the {@link gov.nasa.worldwind.ogc.kml.io.KMLDoc} interface and its implementing classes. It's available from the {@link gov.nasa.worldwind.ogc.kml.KMLRoot}. See the description of the KMLDoc interface for further information.





© 2015 - 2024 Weber Informatics LLC | Privacy Policy