org.gicentre.utils.spatial
Class WebMercator

java.lang.Object
  extended by org.gicentre.utils.spatial.WebMercator
All Implemented Interfaces:
MapProjection

public class WebMercator
extends java.lang.Object
implements MapProjection

Class for representing the Web Mercator coordinate system. This is a Mercator projection assuming a spherical rather than ellipsoidal figure of the earth. Used for transforming to/from projected GoogleMaps, OpenStreetMaps and BingMaps.

Version:
3.3, 27th June, 2012.
Author:
Jo Wood, giCentre, City University London.

Field Summary
static int FROM_LAT_LONG
          Indicates a transformation from longitude/latitude.
static int TO_LAT_LONG
          Indicates a transformation to longitude/latitude.
 
Constructor Summary
WebMercator()
          Initialises the transformer assuming a forward transformation is from longitude/latitude WGS84 to Web (spherical) Mercator coordinates.
WebMercator(int direction)
          Initialises the transformer in the given direction.
 
Method Summary
 boolean doInterpolation()
          Indicates whether the transformation should use nearest neighbour (false) or some interpolator (true).
 java.lang.String getDescription()
          Provides a general description of the transformation.
 Ellipsoid getEllipsoid()
          Reports the ellipsoid used in the transformation.
 processing.core.PVector invTransformCoords(processing.core.PVector p)
          Performs an inverse Web Mercator grid to longitude/latitude transform on the given location.
 processing.core.PVector latLongToWebMercator(processing.core.PVector p)
          Converts the given longitude/latitude coordinates into Web (spherical) Mercator coordinates.
 void setInterpolation(boolean doInterpolation)
          Sets whether the transformation should use nearest neighbour (false) or some interpolator (true).
 processing.core.PVector transformCoords(processing.core.PVector p)
          Performs a forward longitude/latitude to Web Mercator grid transform on the given location.
 processing.core.PVector webMercatorToLatLong(processing.core.PVector p)
          Converts the given Web Mercator coordinates to WGS84 longitude/latitude location.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

FROM_LAT_LONG

public static final int FROM_LAT_LONG
Indicates a transformation from longitude/latitude.

See Also:
Constant Field Values

TO_LAT_LONG

public static final int TO_LAT_LONG
Indicates a transformation to longitude/latitude.

See Also:
Constant Field Values
Constructor Detail

WebMercator

public WebMercator()
Initialises the transformer assuming a forward transformation is from longitude/latitude WGS84 to Web (spherical) Mercator coordinates. This is equivalent to calling the constructor with FROM_LAT_LONG as the parameter.


WebMercator

public WebMercator(int direction)
Initialises the transformer in the given direction.

Parameters:
direction - Indicates whether transforming to or from longitude/latitude.
Method Detail

latLongToWebMercator

public processing.core.PVector latLongToWebMercator(processing.core.PVector p)
Converts the given longitude/latitude coordinates into Web (spherical) Mercator coordinates. Longitude/latitude should be in decimal degrees with positive North and negative East.

Parameters:
p - Longitude/latitude point. Longitude varies within +-180 degrees, latitude within +-88 degrees.
Returns:
Web Mercator coordinates of the given longitude/latitude location or null if input coordinates are out of bounds.

webMercatorToLatLong

public processing.core.PVector webMercatorToLatLong(processing.core.PVector p)
Converts the given Web Mercator coordinates to WGS84 longitude/latitude location.

Parameters:
p - Location of point as an easting and northing in the Web Mercator projection.
Returns:
Longitude/latitude coordinates of the given location (decimal degrees).

transformCoords

public processing.core.PVector transformCoords(processing.core.PVector p)
Performs a forward longitude/latitude to Web Mercator grid transform on the given location.

Specified by:
transformCoords in interface MapProjection
Parameters:
p - Point coordinates to transform.
Returns:
Transformed footprint.

invTransformCoords

public processing.core.PVector invTransformCoords(processing.core.PVector p)
Performs an inverse Web Mercator grid to longitude/latitude transform on the given location.

Specified by:
invTransformCoords in interface MapProjection
Parameters:
p - Point coordinates to transform.
Returns:
Transformed footprint.

getDescription

public java.lang.String getDescription()
Provides a general description of the transformation.

Specified by:
getDescription in interface MapProjection
Returns:
Description of the transformation.

doInterpolation

public boolean doInterpolation()
Indicates whether the transformation should use nearest neighbour (false) or some interpolator (true).

Returns:
True if transformation should perform some local interpolation.

setInterpolation

public void setInterpolation(boolean doInterpolation)
Sets whether the transformation should use nearest neighbour (false) or some interpolator (true).

Parameters:
doInterpolation - True if transformation should perform some local interpolation.

getEllipsoid

public Ellipsoid getEllipsoid()
Reports the ellipsoid used in the transformation.

Returns:
Ellipsoid used in the transformation.


giCentre Utilities V.3.3, API documentation generated 6th April, 2013