|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object de.fhg.igd.gps.maps.MapInfo
This class allows to specify a world map clipping by giving either
Subsequently, this class provides conversion methods and methods to easily move the clipping by means of its center position or to zoom.
Furthermore, the specified map can be obtained as bitmap image through a given map requester.
The geo-coordinates as well as distances within a map clipping are interpolated in a linear manner between the upper left and lower right corner, assuming that the clipping area is small against the world's total surface. The scale of a map is given in meters per pixel, whereas this scale is decisive for both horizontal and vertical map resolution.
Field Summary | |
private WGS84Coordinate |
center_
Center coordinate of the map clipping. |
private int |
height_
The height of the map clipping in pixels. |
static int |
HORIZONTAL
Flag to use as parameter in methods getMetersPerDegree() ,
getPixelsPerDegree() , and getDegreesPerPixel() . |
private WGS84Coordinate |
lowerRight_
Lower right corner of the map clipping. |
private MapRequester |
mapRequester_
Reference to the map requester |
private double |
scale_
The scale of the map clipping in meters per pixel. |
private WGS84Coordinate |
upperLeft_
Upper left corner of the map clipping. |
static int |
VERTICAL
Flag to use as parameter in methods getMetersPerDegree() ,
getPixelsPerDegree() , and getDegreesPerPixel() . |
private int |
width_
The width of the map clipping in pixels. |
Constructor Summary | |
MapInfo(MapRequester mr)
Creates a new instance of this class with the given MapRequester as
reference class for map retrieval and
scale validation. |
Method Summary | |
Point |
coordinate2point(WGS84Coordinate position)
Converts a geo-coordinate within the map clipping, into a corresponding pixel position, given as point relative to the clipping's upper left corner. |
WGS84Coordinate |
getCenterPosition()
Returns the center coordinate of the map clipping. |
double |
getDegreesPerPixel(int orientation)
Returns the amount of degrees per degree, dependent of the current map clipping and the given orientation . |
int |
getHeight()
Returns the height of the map clipping in pixels. |
WGS84Coordinate |
getLowerRightPosition()
Returns the lower right corner of the map clipping. |
BufferedImage |
getMap()
Returns a map corresponding to the specified map clipping, making use of the reference MapRequester . |
double |
getMetersPerDegree(int orientation)
Returns the length of one degree (latitude resp. |
static double |
getMetersPerDegree(Latitude latitude,
Longitude longitude,
int orientation)
Returns the length of one degree (latitude resp. |
static double |
getMetersPerDegree(WGS84Coordinate location,
int orientation)
Returns the length of one degree (latitude resp. |
double |
getPixelsPerDegree(int orientation)
Returns the amount of pixels per degree, dependent of the current map clipping and the given orientation . |
double |
getScale()
Returns the scale of the map clipping in meters per pixel. |
WGS84Coordinate |
getUpperLeftPosition()
Returns the upper left corner of the map clipping. |
int |
getWidth()
Returns the width of the map clipping in pixels. |
void |
init(Latitude latitude,
Longitude longitude,
double scale,
int width,
int height)
Initializes the world map clipping with the given geo-coordinate of the center and the map's scale together with its height and width in pixels. |
void |
init(Latitude latUpperLeft,
Longitude lonUpperLeft,
Latitude latLowerRight,
Longitude lonLowerRight,
int width,
int height)
Initializes the world map clipping with the geo-coordinates of the upper left and lower right corner together with the map's height and width in pixels. |
void |
init(WGS84Coordinate center,
double scale,
int width,
int height)
Initializes the world map clipping with the given geo-coordinate of the center and the map's scale together with its height and width in pixels. |
void |
init(WGS84Coordinate upperLeft,
WGS84Coordinate lowerRight,
int width,
int height)
Initializes the world map clipping with the geo-coordinates of the upper left and lower right corner together with the map's height and width in pixels. |
boolean |
isWithin(Point point)
Checks if the given point lies within
the map clipping or not. |
boolean |
isWithin(WGS84Coordinate position)
Checks if the given geo-coordinate lies within the map clipping or not. |
boolean |
move(double xFactor,
double yFactor)
Moves the center of the map clipping according to the translation given by the vector ( xFactor |yFactor . |
WGS84Coordinate |
point2coordinate(Point point)
Converts a point within the map clipping,
which has to be given as pixel position relative to the
clipping's upper left corner, into the corresponding
geo-coordinate. |
double |
radiusInMetersToScale(int width,
int height,
int radius)
Calculates the scale according to the given width |
String |
toString()
Returns the string representation of the class. |
double |
validateScale(double scale)
Validates the given scale , making use of
the reference MapRequester (see constructer
of the class), and then adjusts it if necessary. |
boolean |
zoom(double factor)
Method to zoom into the map clipping resp. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
public static final int HORIZONTAL
getMetersPerDegree()
,
getPixelsPerDegree()
, and getDegreesPerPixel()
.
public static final int VERTICAL
getMetersPerDegree()
,
getPixelsPerDegree()
, and getDegreesPerPixel()
.
private MapRequester mapRequester_
private WGS84Coordinate center_
private WGS84Coordinate upperLeft_
private WGS84Coordinate lowerRight_
private double scale_
private int height_
private int width_
Constructor Detail |
public MapInfo(MapRequester mr)
MapRequester
as
reference class for map retrieval and
scale validation.
mr
- the reference MapRequester
.Method Detail |
public static double getMetersPerDegree(WGS84Coordinate location, int orientation)
location
and orientation
.
location
- the current location.orientation
- HORIZONTAL
to get the length
of one degree on the current latitude line, or
VERTICAL
to get the length of one degree on
the current longitude line.
-1
if
an error occured.public static double getMetersPerDegree(Latitude latitude, Longitude longitude, int orientation)
latitude
and longitude
,
and orientation
.
latitude
- the latitude of the current location.longitude
- the longitude of the current location.orientation
- HORIZONTAL
to get the length
of one degree on the current latitude line, or
VERTICAL
to get the length of one degree on
the current longitude line.
-1
if
an error occured.public void init(Latitude latitude, Longitude longitude, double scale, int width, int height)
MapRequester
,
and then adjusted if necessary.
latitude
- latitude of the map clipping's center.longitude
- longitude of the map clipping's center.scale
- the scale of the map in meters per pixel.width
- width of the map clipping in pixels.height
- height of the map clipping in pixels.public void init(WGS84Coordinate center, double scale, int width, int height)
MapRequester
,
and then adjusted if necessary.
center
- coordinate of the map clipping's center.scale
- the scale of the map in meters per pixel.width
- width of the map clipping in pixels.height
- height of the map clipping in pixels.public void init(Latitude latUpperLeft, Longitude lonUpperLeft, Latitude latLowerRight, Longitude lonLowerRight, int width, int height)
MapRequester
,
and then adjusted if necessary.
latUpperLeft
- latitude of the map clipping's upper left corner.lonUpperLeft
- longitude of the map clipping's upper left corner.latLowerRight
- latitude of the map clipping's lower right corner.lonLowerRight
- longitude of the map clipping's lower right corner.width
- width of the map clipping in pixels.height
- height of the map clipping in pixels.public void init(WGS84Coordinate upperLeft, WGS84Coordinate lowerRight, int width, int height)
MapRequester
,
and then adjusted if necessary.
upperLeft
- coordinate of the map clipping's upper left corner.lowerRight
- coordinate of the map clipping's lower right corner.width
- width of the map clipping in pixels.height
- height of the map clipping in pixels.public WGS84Coordinate getCenterPosition()
public WGS84Coordinate getUpperLeftPosition()
public WGS84Coordinate getLowerRightPosition()
public double getScale()
public int getHeight()
public int getWidth()
public WGS84Coordinate point2coordinate(Point point)
point
within the map clipping,
which has to be given as pixel position relative to the
clipping's upper left corner, into the corresponding
geo-coordinate.
point
- the pixel position within the map clipping.
null
if the class has not been initialized, yet.public Point coordinate2point(WGS84Coordinate position)
position
- the geo-coordinate within the map clipping.
null
if the class has not been initialized, yet.public boolean isWithin(Point point)
point
lies within
the map clipping or not.
point
- the pixel position relative to the upper left corner.
true
if the given point lies within
the clipping, false
otherwise.public boolean isWithin(WGS84Coordinate position)
position
- the geo-coordinate.
true
if the given coordinate lies within
the clipping, false
otherwise.public boolean zoom(double factor)
factor
the
map clipping's scale is adjusted. The center, width,
and height of the clipping remain unchanged.
The class has to be initialized first.
The scale will be validated, making use of
the reference MapRequester
,
and then adjusted if necessary.
factor
- a factor greater than 1 to zoom in, a factor less
than 1 to zoom out (negative factors are not allowed).
true
if the opperation ended successfully,
false
otherwise.public boolean move(double xFactor, double yFactor)
xFactor
|yFactor
.
The scale, width, and height of the clipping remain unchanged.
The class has to be initialized first.
xFactor
- the translation factor on the horizontal axis, given as
factor of the clipping's width.
true
if the opperation ended successfully,
false
otherwise.public double getPixelsPerDegree(int orientation)
orientation
.
orientation
- HORIZONTAL
to get the amount
of pixels per degree on a latitude line, or VERTICAL
to get the amount of pixels per degree on a longitude line.
public double getDegreesPerPixel(int orientation)
orientation
.
orientation
- HORIZONTAL
to get the amount
of degrees per pixel on a latitude line, or VERTICAL
to get the amount of degrees per pixel on a longitude line.
public double validateScale(double scale)
scale
, making use of
the reference MapRequester
(see constructer
of the class), and then adjusts it if necessary.
If the reference MapRequester
is null
the given scale is returned unchanged.
scale
- the scale to validate.
public double radiusInMetersToScale(int width, int height, int radius)
width and
height
, so that an environment arround the center with
the given radius
in meters is visible on a corresponding
map clipping.
The scale will be validated, making use of
the reference MapRequester
,
and then adjusted if necessary.
- Parameters:
width
- width of the map clipping.radius
- radius in meters.
- Returns:
- the scale to initialize a corresponding map clipping.
public double getMetersPerDegree(int orientation)
orientation
.
orientation
- HORIZONTAL
to get the length
of one degree on the current latitude line, or
VERTICAL
to get the length of one degree on
the current longitude line.
-1
if
an error occured.public BufferedImage getMap() throws IOException
MapRequester
.
BufferedImage
, or null
if the reference MapRequester
or the class has
not been initialized, yet
IOException
- if an error occures while requesting resp.
generating the map.public String toString()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |