vanetsim.map.OSM
Class OSMLoader

java.lang.Object
  extended by vanetsim.map.OSM.OSMLoader

public final class OSMLoader
extends java.lang.Object

A class including functionality to import streets from the OpenStreetMap project. Implemented as Singleton.


Method Summary
static OSMLoader getInstance()
          Gets the single instance of OSM_Loader.
 void loadOSM(java.io.File file)
          Function to load in an OSM map in OSM Protocol version 0.5.
 boolean WGS84toUTM(double[] result, double longitude, double latitude, boolean calculateZone, double longitudeMiddle, boolean highPrecision)
          Convert a WGS84 coordinate to the Universal Transverse Mercator coordinate system.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getInstance

public static OSMLoader getInstance()
Gets the single instance of OSM_Loader.

Returns:
single instance of OSM_Loader

loadOSM

public void loadOSM(java.io.File file)
Function to load in an OSM map in OSM Protocol version 0.5. See the protocol specifications the other wiki entries and the source annotations for details. This functions expects an already downloaded file from a bounding box link like http://api.openstreetmap.org/api/0.5/map?bbox=11.54,48.14,11.543,48.145 or created by Osmosis as an input.
The parsing code assumes that all nodes are declared before the first way comes (which is so in all currently known OSM files).

Notes:

Parameters:
file - the file to import

WGS84toUTM

public boolean WGS84toUTM(double[] result,
                          double longitude,
                          double latitude,
                          boolean calculateZone,
                          double longitudeMiddle,
                          boolean highPrecision)
Convert a WGS84 coordinate to the Universal Transverse Mercator coordinate system.

Parameters:
result - an array which can be used to store the results. The array must consist of at least two elements. The x coordinate will be stored in result[0], the y coordinate in result[1] (both have meters as scale)
latitude - the latitude in the WGS84 system
longitude - the longitude in the WGS84 system
calculateZone - true if the zone should be calculated, false if you want to set your own longitudeOrigin
longitudeMiddle - used to set your own longitude as the middle of the UTM zone (only used if calculateZone=false!). Note that using this gives results which are not conforming to UTM anymore.
If you have multiple locations in normally different UTM zones you can use this to get correct distances between all locations. The value for this variable should be the same for all your locations and it should also be near your other locations (ideally the one in the middle of all).
highPrecision - If some higher order terms for calculation should be used. Setting to true needs more performance but gives more precision in the sub-millimeter-range.
Normally setting to false should be fine!
Returns:
true if calculation succeeded, else false (error in your input!)