?? sw_design.tex
字號:
%% Template for an article following the Dino Documentation%% Guidelines.%%%% Please read the Dino Documentation Guidelines first before writing%% any Dino document as it is mandatory to fully make use of the dino.sty%% document style. This especially applies for the macros in there%% that define images, references, etc...\documentclass[a4paper]{article} %% never change options or the%% document class!!!\usepackage[dinodraft]{dino} %% never change this line!!!%% insert necessary additional packages here - please keep in mind%% that dino.sty itself already includes the necessary standard%% packages like graphicx, etc... please read the Dino%% Documentation Guidelines for details.%% never change any latex variables like pagestyle, baselineskip,%% etc... here!!!\begin{document}\begin{Form}\end{Form}%% ======================================== start document header\title{Software Design of the GPSTool Package} %% insert title here\author{(Christof Dallermassl)\\ %% insert names of authors here in %% Dino Document Style form, %% e.g. \cdaller, \hhaub $Revision: 1.5 $} %% never change this line!!!\maketitle\vspace{1cm}\begin{abstract}This document describes the rough design of the modules in the\packagename{org.dinopolis.gpstool} package and the modules of the\classname{GPSylon} application.\end{abstract}\newpage\tableofcontents\newpage%######################################################################%######################################################################\section{Architectural Design}\label{SoftwareDesignOfTheGpstoolPackage-ArchitecturalDesign}This section describes the modules contained in the\packagename{org.dinopolis.gpstool} package and explains the structureof the \classname{GPSylon} application.%######################################################################\subsection{GPS Data Sources}\label{SoftwareDesignOfTheGpstoolPackage-GpsDataSources}One of the major modules in the \packagename{org.dinopolis.gpstool}package is the one that reads and interprets data from a gpsdevice. This module is named\packagename{org.dinopolis.gpstool.gpsinput}.The module was designed to be independent of the format of the dataand of the source of the data. An example for different formats of thedata could be NMEA or the proprietary Garmin protocol, the sourcecould either be the serial port, a file or a network server thatprovides any clients with gps data (like\externalref{gpsd}{http://freshmeat.net/projects/gpsd/} does).So to be able to get gps information (like position, altitude, speed,etc.), the source in the form of a \classname{GPSDevice} has to bechosen and a way to interpret the data coming from the device, in theform of a \classname{GPSDataProcessor}.These two classes are connected and from this moment on, gpsinformation can be obtained. This information is delivered in the formof events, anyone can register for. The listener can register for allgps events or just for a specific one. In\stdref{tab:SoftwareDesignOfTheGpstoolPackage-EventsFiredFromTheGpsdataprocessor}are the events and its value types listed.\begin{table}[ht] \begin{center} \begin{tabular}{|l|l|} \hline Event Type & Value of Event \\ \hline Location & \classname{GPSPosition}\\ Heading & \classname{Float}\\ Speed & \classname{Float}\\ Number of Satellites & \classname{Integer}\\ Altitude (in meters)& \classname{Float}\\ Satellite Info & \classname{SatelliteInfo}\\ Depth & \classname{Float}\\ Estimated Pos Error (EPE) & \classname{GPSPositionError}\\ \hline \end{tabular} \end{center} \caption{Events fired from the GPSDataProcessor} \label{tab:SoftwareDesignOfTheGpstoolPackage-EventsFiredFromTheGpsdataprocessor}\end{table}A short code snipped shows how to read NMEA data from a serial device:\begin{lstlisting}{Read gps data from the serial device.}// create processor for NMEA data: GPSDataProcessor gps_data_processor = new GPSNmeaDataProcessor();// create gps device for serial port: Hashtable environment = new Hashtable(); environment.put(GPSSerialDevice.PORT_NAME_KEY,"/dev/ttyS1"); environment.put(GPSSerialDevice.PORT_SPEED_KEY,new Integer(4800)); GPSDevice gps_device = new GPSSerialDevice(); gps_device.init(environment);// connect processor with device and open it: gps_data_processor.setGPSDevice(gps_device); gps_data_processor.open();// create property change listener for gps events:PropertyChangeListener listener = new ProperyChangeListener(){ public void propertyChange(PropertyChangeEvent event) { Object value = event.getNewValue(); String name = event.getPropertyName(); if(name.equals(GPSDataProcessor.LOCATION)) { System.out.println("The new location is" +(GPSPosition)value.getLatitude() + "/" +(GPSPosition)value.getLongitude()); } }};// register as listener for location events: gps_data_processor.addGPSDataChangeListener(GPSDataProcessor.LOCATION,listener);\end{lstlisting}A little example that demonstrates the features of this module is thejava application\classname{org.dinopolis.gpstool.gpsinput.GPSTool}. It shows how toread from a file or from the serial interface and how to register forgps events. As a matter of fact, this application was the beginning ofthe whole module.%######################################################################\subsection{GPSylon Application}\label{SoftwareDesignOfTheGpstoolPackage-GpsmapApplication}GPSylon is the main application of the \packagename{org.dinopolis.gpstool}package. It is a moving map application that is able to show thecurrent position on maps that may be downloaded from the internet, atrack of the positions in the past, location markers for points ofinterest, etc.GPSylon uses some parts of the open source\externalref{openmap}{http://openmap.bbn.com} framework. Although theopenmap framework provides a lot of functionality, some was not reusedbut re-implemented to keep the dependencies to the library low.Nevertheless, GPSylon uses openmap's \classname{MapBean} class as itscentral component. A MapBean consists of layers that hold geographicinformation to be drawn for a specific area and scale. The main class of the GPSylon application is\classname{org.dinopolis.gpstool.GPSylon}.%----------------------------------------------------------------------%----------------------------------------------------------------------\subsubsection{Resources}\label{SoftwareDesignOfTheGpstoolPackage-Resources}GPSylon reads some command line parameters, but most if theconfiguration is read from a properties file(\texttt{Gpsylon.properties}). This file must be in the classpath ofthe application and is read via the\classname{org.dinopolis.util.Resources} class. Any changes of theconfiguration are saved into a file into the directory\texttt{.gpsylon} under the user' home directory. Not all resources canbe edited via the ``Preferences'' dialog, so if you are missing somescrews to turn, try the file itself.The resources also hold the information for the resource editor(title, description, type).%----------------------------------------------------------------------%----------------------------------------------------------------------\subsubsection{User Interface}\label{SoftwareDesignOfTheGpstoolPackage-UserInterface}The user interface is widely configured in the resource files. Thestructure of the menu is completely defined in the resource file andthe actions that are executed by selecting a menu entry are named inthe resource file as well.Localization can be done by creating a localized version of theresource file.%----------------------------------------------------------------------%----------------------------------------------------------------------\subsubsection{Projection}\label{SoftwareDesignOfTheGpstoolPackage-Projection}This data is projected from the geoid coordinates (latitude,longitude) to screen coordinates. As the projections provided byopenmap did not work for the maps of\externalref{mapblast}{http://www.mapblast.com} or\externalref{expedia}{http://www.expedia.com}, a new projection wasdeveloped. The maths was taken from the\externalref{gpsdrive}{http://www.gpsdrive.de} project of FritzGanter.This projection provides the calculation from latitude/longitude toscreen (\methodname{forward} methods) and from screen coordinates tolatitude/longitude (\methodname{inverse} methods).The class that implements the projection is\classname{org.dinopolis.gpstool.projection.FlatProjection}. For a full understanding of this class it is necessary to read thedocumentation of the projections of the openmap framework.%----------------------------------------------------------------------%----------------------------------------------------------------------\subsubsection{Layers}\label{SoftwareDesignOfTheGpstoolPackage-Layers}GPSylon organizes its data in layers that are administered by a\classname{com.bbn.openmap.MapBean}. Whenever the projection changes(scale or center is changed), the map bean informs all layers aboutthis change (\methodname{projectionChanged} method). The layers haveto recalculate (project) their data from latitude/longitude to thescreen coordinates and paint them. As the calculation may take itstime, this is usually done in a different task by a\classname{SwingWorker}. As soon as the calculation is done, the datais painted on the screen (\methodname{paintComponent} method).The usage of background tasks also explains the behavior of GPSylon,that after panning the map, other elements (in other layers) are drawnslightly later at their correct position.If one wants to add geographic information (e.g.~position offriends/cars, etc.) the best solution is to add a new layer thatimplements the \methodname{projectionChanged} and the\methodname{paintComponent} methods. That's all! Using the projectionpassed in the \methodname{projectionChanged} method, the conversion ofgeographical to screen coordinates is easy. Lengthy calculationsshould use a \classname{SwingWorker}, so the user interface is notblocked. In the following, some detailed information about different layers isgiven.%----------------------------------------------------------------------%----------------------------------------------------------------------\subsubsection{Map Layer}\label{SoftwareDesignOfTheGpstoolPackage-Map-Layer}The map layer is probably the most important layer at the moment. Itdisplays raster maps that were previously downloaded form expedia ormapblast and stored locally on the hard disk (directory\path{<home>/.gpsylon/maps}). The informations about the files is keptin the file \path{<home>/.gpsylon/maps.txt} (name of file,
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -