de.fhg.igd.gps.maps
Class DarmstadtMapRequester

java.lang.Object
  extended byde.fhg.igd.gps.maps.DarmstadtMapRequester
All Implemented Interfaces:
MapRequester

public class DarmstadtMapRequester
extends Object
implements MapRequester

A MapRequester implementation that can be used to obtain map clippings of the city of Darmstadt.

Author:
Dennis Bartussek
See Also:
Darmstadt

Field Summary
private  DarmstadtMapConfiguration configuration_
           
protected static MemoryCache imageCache_
          cache to store already requested images
protected static double scaleMax_
          largest scale factor that is valid for this DarmstadtMapRequester
protected static double scaleMin_
          smallest scale factor that is valid for this DarmstadtMapRequester
 
Constructor Summary
DarmstadtMapRequester(DarmstadtMapConfiguration cfg)
          Creates a new DarmstadtMapRequester to use the specified DarmstadtMapConfiguration.
 
Method Summary
private  Rectangle getImageRect(Longitude longitude, Latitude latitude, Dimension mapImageDimension, double xZoom, double yZoom)
          Returns a clipping of the entire map of Darmstadt as a Rectangle object.
 BufferedImage getMap(Latitude latitude, Longitude longitude, double scale, int width, int height)
          Returns a map clipping of the city of Darmstadt as a BufferedImage object.
 BufferedImage getMap(WGS84Coordinate center, double scale, int width, int height)
          Returns a map clipping of the city of Darmstadt as a BufferedImage object.
private  Point getOffset(Longitude longitude, Latitude latitude, Dimension mapImageDimension, double xZoom, double yZoom)
          Returns the offset of the upper, left corner of the specified map clipping as a Point object, measured in pixels.
private  Dimension getTilesDimension()
          Returns the horizontal and vertical number of tile images of the entire map as a Dimension object.
private  Rectangle getTilesRect(Rectangle imageRect)
          Returns the tile image indices that overlap with imageRect as a Rectangle object.
private  double getXZoom(Latitude lat, Longitude lon, double scale)
          Returns the horizontal zoom factor that is used to shrink or enlarge a map image to fit the specified scale argument.
private  double getYZoom(Latitude lat, Longitude lon, double scale)
          Returns the vertical zoom factor that is used to shrink or enlarge a map image to fit the specified scale argument.
 boolean inside(Latitude lat, Longitude lon)
          Checks whether or not the geoposition specified by lat and lon is inside the map of Darmstadt.
 double scaleMax()
          Returns the maximum scale that is valid for this MapRequester.
 double scaleMin()
          Returns the minimum scale that is valid for this MapRequester.
 double xPixelsPerDegree()
          Returns the horizontal scale factor, measured in pixels per degree.
 double yPixelsPerDegree()
          Returns the vertical scale factor, measured in pixels per degree.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

configuration_

private DarmstadtMapConfiguration configuration_

scaleMin_

protected static final double scaleMin_
smallest scale factor that is valid for this DarmstadtMapRequester

See Also:
Constant Field Values

scaleMax_

protected static final double scaleMax_
largest scale factor that is valid for this DarmstadtMapRequester

See Also:
Constant Field Values

imageCache_

protected static MemoryCache imageCache_
cache to store already requested images

Constructor Detail

DarmstadtMapRequester

public DarmstadtMapRequester(DarmstadtMapConfiguration cfg)
Creates a new DarmstadtMapRequester to use the specified DarmstadtMapConfiguration. The currently selected configuration of this DarmstadtMapConfiguration defines the map set to request.

Parameters:
cfg - the DarmstadtMapConfiguration to request maps for
Method Detail

scaleMin

public double scaleMin()
Description copied from interface: MapRequester
Returns the minimum scale that is valid for this MapRequester.

Specified by:
scaleMin in interface MapRequester
Returns:
the minimum scale for this MapRequester

scaleMax

public double scaleMax()
Description copied from interface: MapRequester
Returns the maximum scale that is valid for this MapRequester.

Specified by:
scaleMax in interface MapRequester
Returns:
the maximum scale for this MapRequester

getMap

public BufferedImage getMap(WGS84Coordinate center,
                            double scale,
                            int width,
                            int height)
                     throws IOException
Returns a map clipping of the city of Darmstadt as a BufferedImage object. The center of the requested map is specified by center and expected to be within the area of Darmstadt. Validation of the specified WGS84Coordinate is based on the DarmstadtMapConfiguration which has been supplied to the constructor.

The scale argument is expected to be equal to or more than scaleMin() and equal to or less than scaleMax() and will be adjusted to the appropriate level if not within the expected range. The width and height arguments define the dimension of the returned BufferedImage.

Specified by:
getMap in interface MapRequester
Parameters:
center - the center position of the map
scale - scale of the map, measured in meters per pixel
width - width of the requested BufferedImage, measured in pixels
height - height of the requested BufferedImage, measured in pixels
Returns:
the requested BufferedImage or null if the image could not be retrieved
Throws:
IllegalArgumentException - if center is not within the city of Darmstadt
IOException - if an input or output exception occurred during retrieval
See Also:
DarmstadtMapConfiguration.getGeoX1(), DarmstadtMapConfiguration.getGeoY1(), DarmstadtMapConfiguration.getGeoX2(), DarmstadtMapConfiguration.getGeoY2()

getMap

public BufferedImage getMap(Latitude latitude,
                            Longitude longitude,
                            double scale,
                            int width,
                            int height)
                     throws IOException
Returns a map clipping of the city of Darmstadt as a BufferedImage object. The center of the requested map is specified by latitude and longitude and expected to be within the area of Darmstadt. Validation of the specified Latitude and Longitude is based on the DarmstadtMapConfiguration which has been supplied to the constructor.

The scale argument is expected to be equal to or more than scaleMin() and equal to or less than scaleMax() and will be adjusted to the appropriate level if not within the expected range. The width and height arguments define the dimension of the returned BufferedImage.

Specified by:
getMap in interface MapRequester
Parameters:
latitude - latitude of the map's center
longitude - longitude of the map's center
scale - scale of the map, measured in meters per pixel
width - width of the requested BufferedImage, measured in pixels
height - height of the requested BufferedImage, measured in pixels
Returns:
the requested BufferedImage or null if the image could not be retrieved
Throws:
IllegalArgumentException - if latitude and / or longitude are not within the city of Darmstadt
IOException - if an input or output exception occurred during retrieval
See Also:
DarmstadtMapConfiguration.getGeoX1(), DarmstadtMapConfiguration.getGeoY1(), DarmstadtMapConfiguration.getGeoX2(), DarmstadtMapConfiguration.getGeoY2()

inside

public boolean inside(Latitude lat,
                      Longitude lon)
Checks whether or not the geoposition specified by lat and lon is inside the map of Darmstadt.

Returns:
true if the geoposition specified by lat and lon is inside the map of Darmstadt, otherwise false

xPixelsPerDegree

public double xPixelsPerDegree()
Returns the horizontal scale factor, measured in pixels per degree.

Returns:
the horizontal scale factor, measured in pixels per degree

yPixelsPerDegree

public double yPixelsPerDegree()
Returns the vertical scale factor, measured in pixels per degree.

Returns:
the vertical scale factor, measured in pixels per degree

getXZoom

private double getXZoom(Latitude lat,
                        Longitude lon,
                        double scale)
Returns the horizontal zoom factor that is used to shrink or enlarge a map image to fit the specified scale argument.

Parameters:
lat - the Latitude of the map's center position
lon - the Longitude of the map's center position
scale - the scale factor to zoom to
Returns:
the horizontal zoom factor as percentage

getYZoom

private double getYZoom(Latitude lat,
                        Longitude lon,
                        double scale)
Returns the vertical zoom factor that is used to shrink or enlarge a map image to fit the specified scale argument.

Parameters:
lat - the Latitude of the map's center position
lon - the Longitude of the map's center position
scale - the scale factor to zoom to
Returns:
the horizontal zoom factor as percentage

getOffset

private Point getOffset(Longitude longitude,
                        Latitude latitude,
                        Dimension mapImageDimension,
                        double xZoom,
                        double yZoom)
Returns the offset of the upper, left corner of the specified map clipping as a Point object, measured in pixels. If the specified map clipping fits entirely into the map of Darmstadt the Point(0,0) is returned. The center of the map clipping specified by latitude and longitude is expected to be inside the city of Darmstadt, otherwise an IllegalArgumentException is thrown.

Parameters:
mapImageDimension - the Dimension of the map clipping
xZoom - the horizontal zoom factor
yZoom - the vertical zoom factor
Returns:
the offset of the upper, left corner of the specified map clipping as a Point object, measured in pixels
Throws:
IllegalArgumentException - if the geoposition specified by Latitude and Longitude is not inside the city of Darmstadt

getImageRect

private Rectangle getImageRect(Longitude longitude,
                               Latitude latitude,
                               Dimension mapImageDimension,
                               double xZoom,
                               double yZoom)
Returns a clipping of the entire map of Darmstadt as a Rectangle object. The center of the map clipping specified by latitude and longitude is expected to be inside the city of Darmstadt, otherwise an IllegalArgumentException is thrown. The returned Rectangle object will be adjusted to fit into the map of Darmstadt.

Parameters:
mapImageDimension - the Dimension of the map clipping
xZoom - the horizontal zoom factor
yZoom - the vertical zoom factor
Returns:
a clipping of the entire map of Darmstadt as a Rectangle object
Throws:
IllegalArgumentException - if the geoposition specified by Latitude and Longitude is not inside the city of Darmstadt

getTilesDimension

private Dimension getTilesDimension()
Returns the horizontal and vertical number of tile images of the entire map as a Dimension object.

Returns:
the horizontal and vertical number of tile images of the enitre map as a Dimension object.

getTilesRect

private Rectangle getTilesRect(Rectangle imageRect)
Returns the tile image indices that overlap with imageRect as a Rectangle object.

Parameters:
imageRect - the map clipping, measured in pixels
Returns:
the tile image indices as a Rectangle object


Copyright © Fraunhofer Gesellschaft. All Rights Reserved.