courselog.maputils
Class TiledMap

java.lang.Object
  extended by courselog.maputils.TiledMap
All Implemented Interfaces:
GeoGraphable

public class TiledMap
extends java.lang.Object
implements GeoGraphable

A virtual map made of several calibrated maps in a given directory.


Field Summary
static double DEFSCALERANGE
          Default scale range == 100.0d
 double dScAveragePixelOnMeters
          Map average scaling factor.
 double dScPixelOnMeters
          Map scaling factor.
 MapReferencePoint gpAverageCenter
          Map average Center position
 MapReferencePoint gpCenter
          Map Center position
protected  ewe.fx.ImageData imageDataMap
          Image data representation of the map that is used.
protected  ewe.fx.IImage imageMap
          Bitmap representation of the map that is used.
 double maxLat
          Map upper left corner latitude.
 double maxLon
          Map lower right corner longitude.
static int MAXUSAGECOUNT
          Maximum usage count == 32767
 double minLat
          Map lower right corner latitude.
 double minLon
          Map upper left corner longitude.
 java.lang.String myDirMapsFileName
          Directory name of the calibrated image files.
 ewe.util.Vector myMaps2Use
          Vector of maps.
 double myMaxLat
          Maps Max latitude.
 double myMaxLon
          Maps Max longitude.
 double myMaxSc
          Maps Max scale.
 double myMinLat
          Maps Min latitude.
 double myMinLon
          Maps Min longitude.
 double myMinSc
          Maps Min scale.
 int[] myNumberOfUsage
          Array of the number of usage for a map.
 CalibratedMap[] myTiledMaps
          Array of the used calibrated maps
 MapReferencePoint tmpMRP
          Computation Map point.
protected  ewe.fx.Rect tmpRC
          Computation rectangle.
 GeoDirection vpEast
          Center east direction
 GeoDirection vpNorth
          Center north direction
 
Constructor Summary
TiledMap(java.lang.String imageDirFileName)
          Creates a new instance from the map name
 
Method Summary
 void drawIn(ewe.fx.Graphics g, ewe.fx.Rect r, ewe.fx.Color bgC)
          Draws the computed image of this map into a graphic rectangle.
 double findCenterCloserScale()
          Find the closer scale at the current map center.
 double findCenterMaxScale()
          Find the maximum scale at the current map center.
 double findCenterMinScale()
          Find the smaller scale at the current map center.
 ewe.util.Vector findVisibleTiles(ewe.fx.Rect rD, double scaleRange)
          Compute a vector of maps which are partially visible into a graphic rectangle.
 void free()
          Free image data
 ewe.fx.Point getMapPointFromPosition(GeoPoint pos, GeoDirection tmp, ewe.fx.Point pt)
          Compute X and Y on map from geo position.
 GeoPoint getPointFromMap(int xx, int yy, GeoPoint dest)
          Compute lat and long from position on map.
 ewe.fx.Point moveCenterLimited(ewe.fx.Point ptMove, ewe.fx.Rect rFrame)
          Limit displacement of the center of map, in a given rectangle.
 void releaseUnusedMaps()
          Release maps which are not used.
 void setMapCenter(MapReferencePoint gp)
          Set the geo reference point to be used as this map center.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFSCALERANGE

public static final double DEFSCALERANGE
Default scale range == 100.0d

See Also:
Constant Field Values

MAXUSAGECOUNT

public static final int MAXUSAGECOUNT
Maximum usage count == 32767

See Also:
Constant Field Values

myMaps2Use

public ewe.util.Vector myMaps2Use
Vector of maps.


myTiledMaps

public CalibratedMap[] myTiledMaps
Array of the used calibrated maps


myNumberOfUsage

public int[] myNumberOfUsage
Array of the number of usage for a map.


imageMap

protected ewe.fx.IImage imageMap
Bitmap representation of the map that is used.


imageDataMap

protected ewe.fx.ImageData imageDataMap
Image data representation of the map that is used.


myMinLat

public double myMinLat
Maps Min latitude.


myMaxLat

public double myMaxLat
Maps Max latitude.


myMinLon

public double myMinLon
Maps Min longitude.


myMaxLon

public double myMaxLon
Maps Max longitude.


myMinSc

public double myMinSc
Maps Min scale.


myMaxSc

public double myMaxSc
Maps Max scale.


myDirMapsFileName

public java.lang.String myDirMapsFileName
Directory name of the calibrated image files.


gpCenter

public MapReferencePoint gpCenter
Map Center position


gpAverageCenter

public MapReferencePoint gpAverageCenter
Map average Center position


vpNorth

public GeoDirection vpNorth
Center north direction


vpEast

public GeoDirection vpEast
Center east direction


dScPixelOnMeters

public double dScPixelOnMeters
Map scaling factor.


dScAveragePixelOnMeters

public double dScAveragePixelOnMeters
Map average scaling factor.


maxLat

public double maxLat
Map upper left corner latitude.


minLon

public double minLon
Map upper left corner longitude.


minLat

public double minLat
Map lower right corner latitude.


maxLon

public double maxLon
Map lower right corner longitude.


tmpMRP

public MapReferencePoint tmpMRP
Computation Map point.


tmpRC

protected ewe.fx.Rect tmpRC
Computation rectangle.

Constructor Detail

TiledMap

public TiledMap(java.lang.String imageDirFileName)
Creates a new instance from the map name

Method Detail

setMapCenter

public void setMapCenter(MapReferencePoint gp)
Set the geo reference point to be used as this map center.


findVisibleTiles

public ewe.util.Vector findVisibleTiles(ewe.fx.Rect rD,
                                        double scaleRange)
Compute a vector of maps which are partially visible into a graphic rectangle.

Parameters:
rD - Rectangle to display.
scaleRange - Limit visibility to a scale ratio of scaleRange which shall be >1. If 0<=scaleRange<1, all maps are taken. If scaleRange<0, maps are sorted in ascending scale order
Returns:
a vector of calibrated maps supposed to be visible. A subset of myTiledMaps. Maps are sorted in order of scale further to the current scale so that last map is closer to the current scale. If scaleRange<0, maps are sorted in ascending scale order.

releaseUnusedMaps

public void releaseUnusedMaps()
Release maps which are not used.


findCenterMaxScale

public double findCenterMaxScale()
Find the maximum scale at the current map center.


findCenterCloserScale

public double findCenterCloserScale()
Find the closer scale at the current map center.


findCenterMinScale

public double findCenterMinScale()
Find the smaller scale at the current map center.


moveCenterLimited

public ewe.fx.Point moveCenterLimited(ewe.fx.Point ptMove,
                                      ewe.fx.Rect rFrame)
Limit displacement of the center of map, in a given rectangle.


free

public void free()
Free image data


getPointFromMap

public GeoPoint getPointFromMap(int xx,
                                int yy,
                                GeoPoint dest)
Compute lat and long from position on map.

Specified by:
getPointFromMap in interface GeoGraphable

getMapPointFromPosition

public ewe.fx.Point getMapPointFromPosition(GeoPoint pos,
                                            GeoDirection tmp,
                                            ewe.fx.Point pt)
Compute X and Y on map from geo position.

Specified by:
getMapPointFromPosition in interface GeoGraphable
Parameters:
pos - geo position to transpose.
tmp - GeoDirection reference to compute intermediate direction. If null a new object is allocated.
pt - point on bitmap image to compute. If null a new Point object is allocated.
Returns:
Computed point. Should be pt or a new Point object.

drawIn

public void drawIn(ewe.fx.Graphics g,
                   ewe.fx.Rect r,
                   ewe.fx.Color bgC)
Draws the computed image of this map into a graphic rectangle. The operation works provided that the center of the tiled map has been properly initialised with setCenterInImage(x,y).