Global Positioning System Reference
In-Depth Information
public static void main(String[] args) throws IOException
{
String path = "D:/virtex/workspace/resources/gps/HD/",
nameIn = path + "demo.gpslog",
smallNMEA = path + "HDcastle.nmea";
reduceNMEA( nameIn, smallNMEA );
parseNMEA( smallNMEA, path + "HDcastle.csv");
parseNMEA( smallNMEA, path + "HDcastleBody.gpx");
}
The NMEA converter creates a HDcastleBody.gpx file. This file (and
later the map image of JavaGPS) will serve as a reference to compare the
results with JavaGPS.
XML and Java in a Nutshell
The GPS eXchange format GPX is a widely available XML format sup-
ported by most GPS devices and applications. You can find traces at
www.openstreetmap.org for working on development in your location.
A
GPSinfo element is represented as
<trkpt lat="49.40940666666667" lon="8.713693333333334">
<ele>201.7</ele>
<time>2002-03-01T13:40:30Z</time>
</trkpt>
The great advantage of XML is the strict definition of structures. XML
documents are organized as a hierarchy of elements with start and end tags
and were designed for ease of parsing. There are many XML parsers on
the market. The SAX and DOM parsers are standards available in several
different languages. In Java, you can instantiate the parsers by using the
Java API for XML Parsing (JAXP) and parse XML documents through
the Simple API for XML (SAX) and the Document Object Model (DOM)
interfaces.
SAX is an event-driven model to parse serial file streams with good
performance and low memory consumption. In the case of a connected GPS
device, SAX can be used to fire events with every new reported position,
but it is not designed to modify the data. In Chapter 7, osmosis will be
introduced. Osmosis is built around a SAX parser, and you can easily
install and study the sources in your IDE.
The DOM model is easier to use. It loads the entire GPX file into
memory, and the application can randomly navigate through its structure,
adding, removing, or modifying elements (and writing them back to the
file system). The application can basically reorganize the data in a useful
way. When the DOM parser reads an XML file, it builds a tree struc-
ture in memory and makes it available to APIs of the programming lan-
guage. At the core of the DOM API are the Document and Node interfaces.
 
Search WWH ::




Custom Search