|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object de.fhg.igd.gps.maps.DarmstadtMapRequester
A MapRequester
implementation that can be used to obtain map
clippings of the city of 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 |
private DarmstadtMapConfiguration configuration_
protected static final double scaleMin_
DarmstadtMapRequester
protected static final double scaleMax_
DarmstadtMapRequester
protected static MemoryCache imageCache_
Constructor Detail |
public DarmstadtMapRequester(DarmstadtMapConfiguration cfg)
DarmstadtMapRequester
to use the specified
DarmstadtMapConfiguration
. The currently selected
configuration of this DarmstadtMapConfiguration
defines
the map set to request.
cfg
- the DarmstadtMapConfiguration
to request maps forMethod Detail |
public double scaleMin()
MapRequester
MapRequester
.
scaleMin
in interface MapRequester
MapRequester
public double scaleMax()
MapRequester
MapRequester
.
scaleMax
in interface MapRequester
MapRequester
public BufferedImage getMap(WGS84Coordinate center, double scale, int width, int height) throws IOException
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
.
getMap
in interface MapRequester
center
- the center position of the mapscale
- scale of the map, measured in meters per pixelwidth
- width of the requested BufferedImage, measured in pixelsheight
- height of the requested BufferedImage, measured in pixels
BufferedImage
or null
if
the image could not be retrieved
IllegalArgumentException
- if center
is not within the
city of Darmstadt
IOException
- if an input or output exception occurred during
retrievalDarmstadtMapConfiguration.getGeoX1()
,
DarmstadtMapConfiguration.getGeoY1()
,
DarmstadtMapConfiguration.getGeoX2()
,
DarmstadtMapConfiguration.getGeoY2()
public BufferedImage getMap(Latitude latitude, Longitude longitude, double scale, int width, int height) throws IOException
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
.
getMap
in interface MapRequester
latitude
- latitude of the map's centerlongitude
- longitude of the map's centerscale
- scale of the map, measured in meters per pixelwidth
- width of the requested BufferedImage, measured in pixelsheight
- height of the requested BufferedImage, measured in pixels
BufferedImage
or null
if
the image could not be retrieved
IllegalArgumentException
- if latitude and / or longitude are not
within the city of Darmstadt
IOException
- if an input or output exception occurred during
retrievalDarmstadtMapConfiguration.getGeoX1()
,
DarmstadtMapConfiguration.getGeoY1()
,
DarmstadtMapConfiguration.getGeoX2()
,
DarmstadtMapConfiguration.getGeoY2()
public boolean inside(Latitude lat, Longitude lon)
lat
and
lon
is inside the map of Darmstadt.
true
if the geoposition specified by
lat
and lon
is inside the map of Darmstadt,
otherwise false
public double xPixelsPerDegree()
public double yPixelsPerDegree()
private double getXZoom(Latitude lat, Longitude lon, double scale)
scale
argument.
lat
- the Latitude
of the map's center positionlon
- the Longitude
of the map's center positionscale
- the scale factor to zoom to
private double getYZoom(Latitude lat, Longitude lon, double scale)
scale
argument.
lat
- the Latitude
of the map's center positionlon
- the Longitude
of the map's center positionscale
- the scale factor to zoom to
private Point getOffset(Longitude longitude, Latitude latitude, Dimension mapImageDimension, double xZoom, double yZoom)
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.
mapImageDimension
- the Dimension
of the map clippingxZoom
- the horizontal zoom factoryZoom
- the vertical zoom factor
Point
object, measured in pixels
IllegalArgumentException
- if the geoposition specified by
Latitude
and Longitude
is not inside the city
of Darmstadtprivate Rectangle getImageRect(Longitude longitude, Latitude latitude, Dimension mapImageDimension, double xZoom, double yZoom)
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.
mapImageDimension
- the Dimension
of the map clippingxZoom
- the horizontal zoom factoryZoom
- the vertical zoom factor
Rectangle
object
IllegalArgumentException
- if the geoposition specified by
Latitude
and Longitude
is not inside the city
of Darmstadtprivate Dimension getTilesDimension()
Dimension
object.
Dimension
object.private Rectangle getTilesRect(Rectangle imageRect)
imageRect
as a Rectangle
object.
imageRect
- the map clipping, measured in pixels
Rectangle
object
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |