de.yaina.trackrenderer
Class MapCanvas

java.lang.Object
  extended by de.yaina.trackrenderer.TileCollection
      extended by de.yaina.trackrenderer.TileCanvas
          extended by de.yaina.trackrenderer.DrawCanvas
              extended by de.yaina.trackrenderer.MapCanvas

public class MapCanvas
extends DrawCanvas

A mercator-projected tiled map to draw positions on


Constructor Summary
MapCanvas(int tileDimX, int tileDimY, int zoom)
          Create a tiled map for a certain zoom level
 
Method Summary
 void drawLine(double lat1, double lon1, double lat2, double lon2, byte colour, int pixmap)
          Draw a line on the map.
 int getZoom()
          Get the zoom level of this map
 double lat_to_merkator_y(double lat)
          Calculate the mercator projected latitude
 int lat_to_tile_y(double lat)
          Calculate the vertical tile number from the latitude
 int lat_to_y(double lat)
          Calculate the vertical position on the tile
 double lon_to_merkator_x(double lon)
          Calculate the mercator projected longitude
 int lon_to_tile_x(double lon)
          Calculate the horizontal tile number from the longitude
 int lon_to_x(double lon)
          Calculate the horizontal position on the tile
 TileCoordinates positionToPoint(double lat, double lon)
          Convert a WGT84 position to a points on the map
 void setPoint(double lat, double lon, byte colour, int pixmap)
          Set a point on the map
 double tile_x_to_lon(int x)
          Calculate the longitude of the upper-left corner of a tile
 double tile_y_to_lat(int y)
          Calculate the latitude of the upper-left corner of a tile
 
Methods inherited from class de.yaina.trackrenderer.DrawCanvas
drawLine, setPoint
 
Methods inherited from class de.yaina.trackrenderer.TileCanvas
getPoint, setPoint
 
Methods inherited from class de.yaina.trackrenderer.TileCollection
getCollection, getDimensionX, getDimensionY, getImage, getTile
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MapCanvas

public MapCanvas(int tileDimX,
                 int tileDimY,
                 int zoom)
Create a tiled map for a certain zoom level

Parameters:
tileDimX - horizontal size of a tile
tileDimY - vertical size of a tile
zoom - zoom level
Method Detail

getZoom

public int getZoom()
Get the zoom level of this map

Returns:
zoom level

tile_x_to_lon

public double tile_x_to_lon(int x)
Calculate the longitude of the upper-left corner of a tile

Parameters:
x - tile number
Returns:
longitude

tile_y_to_lat

public double tile_y_to_lat(int y)
Calculate the latitude of the upper-left corner of a tile

Parameters:
y -
Returns:
latitude

lon_to_merkator_x

public double lon_to_merkator_x(double lon)
Calculate the mercator projected longitude

Parameters:
lon - longitude
Returns:
horizontal value

lat_to_merkator_y

public double lat_to_merkator_y(double lat)
Calculate the mercator projected latitude

Parameters:
lat - latitude
Returns:
vertical value

lat_to_tile_y

public int lat_to_tile_y(double lat)
Calculate the vertical tile number from the latitude

Parameters:
lat - latitude
Returns:
tile number

lon_to_tile_x

public int lon_to_tile_x(double lon)
Calculate the horizontal tile number from the longitude

Parameters:
lon - longitude
Returns:
tile number

lon_to_x

public int lon_to_x(double lon)
Calculate the horizontal position on the tile

Parameters:
lon - longitude
Returns:
x value

lat_to_y

public int lat_to_y(double lat)
Calculate the vertical position on the tile

Parameters:
lat - latitude
Returns:
y value

positionToPoint

public TileCoordinates positionToPoint(double lat,
                                       double lon)
Convert a WGT84 position to a points on the map

Parameters:
lat - latitude
lon - longitude
Returns:
point on the map

setPoint

public void setPoint(double lat,
                     double lon,
                     byte colour,
                     int pixmap)
Set a point on the map

Parameters:
lat - latitude
lon - longitude
colour - colour index
pixmap - point style

drawLine

public void drawLine(double lat1,
                     double lon1,
                     double lat2,
                     double lon2,
                     byte colour,
                     int pixmap)
Draw a line on the map. It will be a straight line on the projection, however of course not the shortest distance between the two coordinates

Parameters:
lat1 - latitude of start coordinate
lon1 - longitude of start coordinate
lat2 - latitude of end coordinate
lon2 - latitude of end coordinate
colour - colour index
pixmap - line style