com.maryanovsky.map.client.widgets.scale
Class EarthScale

java.lang.Object
  extended by com.maryanovsky.map.client.widgets.scale.EarthScale
All Implemented Interfaces:
ScaleWidget.Scale

public class EarthScale
extends Object
implements ScaleWidget.Scale

Implements ScaleWidget.Scale for maps of the planet earth. The earth is modelled as a perfect sphere of its actual equatorial radius. This scale is therefore imprecise, especially at locations far from the equator (but it's good enough for most uses).

Author:
Maryanovsky Alexander

Field Summary
static double EARTH_RADIUS_METERS
          The equatorial radius of the earth in meters.
 
Constructor Summary
EarthScale(int preferredSize, double[] sizes, String[] sizeNames)
          Creates a new EarthScale with the specified preferred pixel size, array of possible sizes and their names.
 
Method Summary
static double getArcLength(LatLng loc1, LatLng loc2)
          Returns the angle of the shortest arc between the two specified locations, on a sphere of the given radius.
static EarthScale getEnglishImperialInstance(int preferredSize)
          Returns an instance of EarthScale which displays imperial sizes in English.
static EarthScale getEnglishMetricInstance(int preferredSize)
          Returns an instance of EarthScale which displays metric sizes in English.
static double getMetersPerPixel(MapWidget mapWidget)
          Returns the number of meters in a pixel displayed by the specified MapWidget.
 int getSizePixels(MapWidget mapWidget)
          Returns the size of the displayed scale, in pixels, or 0 if the scale should not be displayed.
 String getSizeText(MapWidget mapWidget)
          Returns the value displayed on the scale widget, or null if the scale value should not be displayed.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

EARTH_RADIUS_METERS

public static final double EARTH_RADIUS_METERS
The equatorial radius of the earth in meters.

See Also:
Constant Field Values
Constructor Detail

EarthScale

public EarthScale(int preferredSize,
                  double[] sizes,
                  String[] sizeNames)
Creates a new EarthScale with the specified preferred pixel size, array of possible sizes and their names.

Parameters:
preferredSize - The preferred size of the scale, in pixels.
sizes - The possible displayed sizes, in meters, in increasing order.
sizeNames - The names of the possible displayed sizes, in the same order as sizes.
Method Detail

getEnglishMetricInstance

public static EarthScale getEnglishMetricInstance(int preferredSize)
Returns an instance of EarthScale which displays metric sizes in English.

Parameters:
preferredSize - The preferred size of the scale, in pixels.

getEnglishImperialInstance

public static EarthScale getEnglishImperialInstance(int preferredSize)
Returns an instance of EarthScale which displays imperial sizes in English.

Parameters:
preferredSize - The preferred size of the scale, in pixels.

getSizePixels

public int getSizePixels(MapWidget mapWidget)
Returns the size of the displayed scale, in pixels, or 0 if the scale should not be displayed.

Specified by:
getSizePixels in interface ScaleWidget.Scale

getSizeText

public String getSizeText(MapWidget mapWidget)
Returns the value displayed on the scale widget, or null if the scale value should not be displayed.

Specified by:
getSizeText in interface ScaleWidget.Scale

getMetersPerPixel

public static double getMetersPerPixel(MapWidget mapWidget)
Returns the number of meters in a pixel displayed by the specified MapWidget. Returns 0 if unable to determine.


getArcLength

public static double getArcLength(LatLng loc1,
                                  LatLng loc2)
Returns the angle of the shortest arc between the two specified locations, on a sphere of the given radius.