Marble/GeoData

From KDE Community Wiki
Revision as of 21:49, 22 July 2009 by Tgridel (talk | contribs) (description moved from GraphicsViewGeoParser)

GeoData Overview

GeoData holds the data model that is internally used for any geographic information which should be rendered. It deals whith the data only, drawing is performed elsewhere.

GeoDataDocument describes a document.

A model representation is built through parsing of files and creating a stack of GeoDataObject representing its data. The Geodata objects are all modeled after the Google KML files as defined in the KML documentation.


Parsing GeoData

The GeoParser is a framework to parse xml files based on the QXMLStreamReader class in Qt (more info here).

It is specialised in GeoDataParser to handle KML, GPX, GeoRSS and OSM formats and populate the data model. The parser relies on

  • GeoTagHandler classes which define how a node in the file is to be processed and should populate the data model.
  • A GeoStackItem class that implements the Structural parts of the XML document
  • The collection class where the results of the XML parsing will be placed
  • An element dictionary that prevents the need for string comparison everywere

To implement a new XML parser you need to

  1. compile an element dictionary of all of the available tags in the namespace
  2. implement a tag handler for each of these elements
  3. register that tag handler with the GeoParser

Implementing a tag handler

Each tag handler is called when the relevant XML tag is reached by the GeoParser ( which knows what tags to call by its registered tag list ). Each tag can access the stack data structure of the GeoParser as well as the Collection Data Structure of the GeoParser. This allows the tag handler to access items from the stack and allows root elements of the XML to add themselves to the collection data structure.