Thursday, May 10, 2012

Open Source Java GPS Map Application Framework

The dinopolis gpstool package is an open source (LGPL) Java GPS application. It consists of different modules that may be used as a programmer's framework or as an application. The main application is GPSylon. A smaller command line tool (demonstration of the gpsinput library) is named GPSTool. The library that is used to communicate with the gps device can be used independently and is provided as a separate jar file (since version 0.5).

Short Description of GPSylon

GPSylon is able to show maps downloaded from the expedia map servers. It may connect to a gps device and track your position on the maps. At the moment, it is able to read gpsdata in the NMEA standard from a serial gps device, a file or a gps daemon across a network.
The main feature is the display of various maps. GPSylon allows the user to navigate around like in a digital atlas. It shows maps of different scales, so missing maps of one scale do not result in a black screen, but show the next larger scale.
It allows the download of a single map or for a given location or for multiple maps in a given rectangular area from mapblast or expedia map servers. In the download mouse mode the user may choose a single map or by dragging a rectangle with the mouse, the user may choose to download maps for a larger area. This functionality allows the user to download maps in a given scale for a larger area. Please only download maps you need and be careful not to download thousands of maps, as the map providers will discontinue their service when it is misused!
It uses the open source library openmap for various cartographic things.

Features

The following features are implemented.
  • Display different maps from mapblast or expedia server (also for maps of different scale).
  • Display current position (gps position).
  • Read gps data from serial device, file, or gpsd (daemon).
  • Uses the following NMEA sentences: GLL, HDG, RMC, GGA, GSV, DBT, VTG, HTD.
  • Display a track from gps data.
  • Save the track.
  • Load a track created from GPSylon or from gpsdrive.
  • Import maps from gpsdrive.
  • Download a map for a given position.
  • Download maps for an area.
  • Measure distance (ruler).
  • Read and display shape files (very basic, not well tested!).
  • display graticule lines
  • window to display the raw nmea data
  • Location Marker support: (creating markers, load markers from files (comma or space separated (name, latitude, longitude [,category]) - in that order!)), export markers to csv files, icons for categories, import geonet data (available from http://164.214.2.59/gns/html/index.html)
  • Database support for Location Markers - selection of categories to display.
    Different databases are supported (derby and hsqldb (both pure java, zero configuration), mysql and postgresql) - the database and all tables are created automatically
  • Level Of Detail: depending on the chosen scale, not all location markers are displayed. The level of detail is increased when the user zooms in or chooses to override the level of detail. This behaviour might be tricky, when the user creates a location marker in a category that does not show due to its higher level of detail. So the user may not see the newly created marker.
  • Search for location markers and set the center of the map to a search result. This is extremely useful in combination with the geonet data. So, after importing the geonet data, one is able to search for very small villages or other points of interest. When using mysql or postgresql as a database, the lookup for names of location markers is very fast, the (default) hsql database is about 5 to 10 times slower (but also works perfectly, just slower :-). So if one or more geonet files should be imported, I recommend mysql or postgresql (see in the installation section for configuration details).

Supported GPS Devices

In general, all gps devices that support NMEA communication should work. Garmin protocol support is built in.
There were reports of the following devices to work with GPSylon:
  • Garmin Etrex Summit/Legend (NMEA/garmin modes) tested by myself)
  • Garmin eMap (NMEA/garmin modes) (reported by Thomas Müller))
  • Trimble Lassen SK8 (NMEA mode) (reported by Didier Donsez)
  • Garmin 35 (NMEA mode) (reported by Antonio)
  • Conexant '99 embedded module (NMEA mode) (reported by Antonio)
  • LeadTek Gps-9543 embedded module (NMEA mode) (reported by Antonio)
  • Garmin Geko 201 (garmin mode) (reported by Frank Wilhelm)
  • GlobalSat Bluetooth GPS BT-338 (tested by myself)
  • Navilock NL-303P PDA-GPS-Receiver with Serial/USB converter (tested by Silverbullet)
Linux users please note: serial ports must be like /dev/ttySXX, as otherwise rxtx does not recognize the port. So for bluetooth or USB devices, a symlink is needed!
For bluetooth connection, I used the following commands under linux to create a serial connection with bluetooth. First, find the id of your bluetooth device. I used hcitool for this:
            hcitool scan
            output:
            Scanning ...
            00:0B:5D:13:91:49       BEGRZ9001001
            00:0D:B5:30:3C:0A       BT-GPS-303C0A
            
The first id is my bluetooth dongle on the pc, the second is the gps device. So, with this id, we can create a virtual serial port using rfcomm:
            rfcomm bind /dev/ttyS50 00:0D:B5:30:3C:0A
            
As rxtx does not allow /dev/rfcomm0 as serial device, I used /dev/ttyS50 (all ttys below 50 were already existent in my installation). A symlink from ttyS50 to rfcomm0 also works! After this, I set some port parameter (I'm not sure, if this is really needed!):
            stty -F/dev/ttyS50 -raw -onlcr
            
Now, GPSTool or GPSylon can use the serial port /dev/ttyS50 for communication with the nmea bluetooth gps device. After closing the application, one should release the bluetooth serial port:
            rfcomm release /dev/ttyS50
            
Please note, that all these commands (except for the application start) need to be run as root!

Installation

No installation of GPSylon itself is needed. Nevertheless, some dependencies exist:
  • Java in Version 1.4 (or better) is needed. It can be obtained from Sun's Website. Development is currently done with version 1.5, but tests are done for version 1.4. Java version 1.3 will NOT work!
  • Starting from Gpsylon V0.5.2, NO installation of the Java serial libraries are needed anymore! The native libraries are shipped with Gpsylon and start scripts are provided (for Linux and Windows) for Gpsylon and Gpstool (ther command line application). So just unpack the archive, and run (or double click) gpsylon.cmd, gpstool.cmd (for Windows) respectivly gpsylon.sh, gpstool.sh for Unix (Native Libraries for Linux, Sun Solaris and MacOSX are provided). As there is no Apple computer around for testing, I am not sure, if the unix scripts will work. Feedback is welcome!
    Jan van Haarst reported that comfoolery can be used to forward the serial data to a network socket. GPSylon may connect to this socket when it is configured to use gpsd instead of the serial device.

Database for Location Markers

GPSylon is able to store and retrieve location markers from relational databases via JDBC. By default it uses the pure java open source Hypersonic DB (hsqldb). It has the advantage that no installation is needed and GPSylon creates a database on demand without any hassle.
As the geonet dataset is quite large (e.g. Austria 50 thousand entries, Germany 170 thousand entries), hsqldb seemed quite slow. So I gave it a try with mysql and it seems to be faster! Especially searching for location markers is faster by a factor 5 to 10! So I added a script that creates the table(s) needed (syntax differs slightly from the hsqldb syntax). The following steps are needed to use a mysql database instead of the built in hsqldb:
  • Install MySQL :-)
  • Create the database: e.g. with the command mysqladmin create gpsmap
  • Start GPSylon and edit database settings in the preferences (Location Marker tab):
    • JDBC Url: jdbc:mysql://localhost/gpsmap
    • JDBC Driver: com.mysql.jdbc.Driver
    • SQL Script to create the Database: sql/create_loation_mysql.sql
  • quit GPSylon
  • on the next start, GPSylon tries to access the new database, but cannot (as the tables are missing). It asks for administrators username/password (try "root" and empty password :-) so it can create the table(s). It will also add a user "sa" with no password for normal usage (access limited to gpsmap database).
  • That should be it! From now on, all location markers are stored and retrieved from the MySQL database.
For Postgresql support use the following configuration:
  • JDBC Url: jdbc:postgresql://localhost/gpsmap
  • JDBC Driver: org.postgresql.Driver
  • SQL Script to create the Database: sql/create_loation_postgresql.sql
The rest of the postgresql configuration is similar to the mysql configuration (install database, create a gpsmap database, create user and user rights, ...)

Run GPSylon

To start GPSylon, download the gpstool-archive, unpack it and call
java -jar gpssylon.jar
or if your environment is setup to handle jar-archives correctly, simply double click on the jar-archive (should work under windows). All needed classes are contained in the jar file. If you have the ant environment installed, call ant run.
For commandline arguments (everything may be configured in the application as well!), call
java -jar gpsylon.jar --help

Mouse Modes

GPSylon supports different mouse modes. Mouse modes may be added as plugins. At the moment, two mouse modes are available:
  • Navigation Mode: click anywhere in the map to zoom in and center at the clicked position. If the shift-key is held, a click zooms out. More navigational functionality will be implemented soon (pan, ...)
  • Download Mode: If the download mode is used, a window opens that displays some information about the map(s) to download. In the map window, a red rectangle (with crossed lines) shows the current location and size (size may not be exact and varies slightly from one internet map server to another). The user may change the location either by clicking in the map or by changing the coordinates in the download window. The coordinates may be entered in different formats (decimal, using the degree sign, etc.). The user may click and drag in the map to draw a rectangle. If the rectangle is larger that a single map, more than one rectangle is shown and the number of maps to download is shown in the download window. Please do not download maps excessively, as the companies that provide the maps do not like that and will stop their service if it is misused!

Plugins

GPSylon supports plugins of various kinds. The plugin-jars are used without the need to set the CLASSPATH. All jars in the directories [home]/.gpsylon/plugins and in the plugins directory of the applicaton are used.

Download

Please download the latest distribution of GPSylon at the download page on sourceforge.

Status

GPSylon is in beta-status. It runs quite stable, but many features are not implemented yet.

Articles about GPSylon

Elliotte Rusty Harold, the author of quite a few books about Java, mentioned GPSylon in his Cafe au Lait blog.

Other Projects

Other projects that use parts of the gpsinput/gpsylon code are:
  • GPS Position Producer
Projects that are somehow related to this project:
  • Gpsdrive was the main inspiration to write gpsylon.
  • MapGeneration tries to create free vector data from NMEA streams - this was one of the goals gpsylon was written for!
  • Maps4Free tries to do the same as a community project.

To Do List

urgent:
  • option to use always info from gpsdrive
  • optionally draw rectangle for small scale maps that do not show (done (map manager plugin)): done
  • download maps also larger than 1280x1024
  • use repaint(int,int,int,int): mostly done
  • are there GPS devices, that do not send RMC (for gps speed)??
  • check for speed sent from gps (calculation of distance s=v*t) (tachometer)
  • window showing NMEA data: done
Todo (wishlist):
routes
  • define route with mouse (like distant mouse mode)
  • name route
  • show table with available routes
  • download maps for a given route in a given scale (and image size)
  • follow a given route with gps
waypoints
  • different lists of waypoints: done, categories should do the job
  • display different list of waypoints: done, categories should do it
  • different symbols for waypoints: done, for a couple of categories, more to come
  • store waypoints in database (hsqldb, mysql): done
overlays
  • show major cities (CSV), use them as waypoints
  • shape files: done (experimental)
  • GML
location database (GNR)
  • search for name in GNR (zipped files) (done, when gnr is imported)
  • goto location (done)
GPS Device
  • upload/download waypoints
  • download Tracks: download is done
  • upload Tracks
gps tracking
  • pursuit mode: done, cdaller 2002/09/06
  • as soon as manual navigation on screen, disable pursuit mode.
  • different color for height or speed
  • save gps tracks: done
  • load gps tracks from gps device: done
  • load gps tracks from file: done for own tracks, track of gpdsrive and gml tracks
  • autoscale (set scale, depending on speed)
vectorize tracks
  • define nodes (crossings) and arcs between nodes
  • define type of arcs (highway, smaller road, bicycle path)
  • export as GML
  • import as GML
communication to other applications
  • import/export maps, tracks, waypoints to gpsdrive, gpspoint (partly done)
  • option to leave maps there or copy them to .gpsylon/maps directory
maps
  • import scanned maps
  • download from different servers (expedia, mapblast, ...): done
  • allow proxy authentication: done
  • show table of maps (allow to delete, rename?, ...): partly done
  • download an area of maps: done<
autoroute calculation
    need vector data for this!
speech
  • output
  • input
distance notification
  • provide notifications for specific points (e.g. radar warning)
context menus (right mouse) / one button mouse (touchscreen) support????
  • set position
  • set destination
  • set waypoint
  • let each layer add menu for this

Compile Source Distribution

To compile the source distribution, the java make tool Ant from the apache project is needed. When correctly installed, a ant compile should be enough to compile the source.
ant help gives all ant-tasks.

Commandline tool GPSTool

GPSTool is a small command line application that demonstrates the usage of the classes to read data from a gps device. The main class is org.dinopolis.gpstool.GPSTool and it may be started using the provided gpstool-<version>.jar file (execute in a command window java -jar gpsylon-<version>.jar - double click does not make much sense, as it is a commandline application). Use "--help" to see all commandline switches.
The following features are implemented in GPSTool:
  • Show current position/altitude/speed/heading/info about satellites.
  • Use NMEA or Garmin protocol.
  • Download tracks, routes, and/or waypoints and print them in GPX format.
  • Make screenshots from the display of the gps device. This is tested with the following models: Garmin eTrex Summit, eTrex Legend, eMap, Geko201, Streetpilot III (partly, needs more work - could not finish due to the device powered down after sending the 10th line of the image).
  • Supprts Velocity templates to print tracks, routes, waypoints. These templates are easy to write. Use command line switch " --printdefaulttemplate" to show the gpx template. Other templates are provided in the auxiliary directory. 

Link: http://www.tegmento.org/gpsylon/

No comments:

Post a Comment