com.esri.adf.web.ve.util
Class VEUtil

java.lang.Object
  extended by com.esri.adf.web.ve.util.VEUtil
All Implemented Interfaces:
VEConstants, Serializable

public class VEUtil
extends Object
implements VEConstants, Serializable

This class contains many useful methods for Bing™ Maps (formerly known as Virtual Earth) Web Services.

See Also:
Serialized Form

Field Summary
 
Fields inherited from interface com.esri.adf.web.ve.data.VEConstants
MAP_STYLE_AERIAL, MAP_STYLE_AERIAL_WITH_LABEL, MAP_STYLE_ROAD, MAX_LEVEL_OF_DETAIL, MIN_LEVEL_OF_DETAIL, TILE_HEIGHT, TILE_WIDTH, VIRTUAL_EARTH_GEOCODE_WKID, VIRTUAL_EARTH_SPATIAL_REFERENCE_WKID, VIRTUAL_EARTH_XMAX, VIRTUAL_EARTH_XMIN, VIRTUAL_EARTH_YMAX, VIRTUAL_EARTH_YMIN
 
Method Summary
static javax.media.jai.PlanarImage assembleTiles(String genericURL, int levelOfDetail)
          Returns an image composed with all the tiles for a given level of detail.
static byte[] assembleTiles(String genericURL, int levelOfDetail, String imageFormat)
          Returns an image composed with all the tiles for a given level of detail.
static javax.media.jai.PlanarImage assembleTiles(String genericURL, WebExtent extent, int widthImg, int heightImg, Collection<WebLodInfo> lodInfos)
          Returns an image composed with all the tiles for a given extent and to the size requested.
static javax.media.jai.PlanarImage assembleTiles(String genericURL, WebExtent extent, VETileFunctionality veFunc)
          Returns an image composed with all the tiles for a given extent.
static CandidateTileInfo getCandidateTileInfo(WebExtent extent, VETileFunctionality tileFunc)
          Returns the Candidate Tile information for a given extent.
static WebLodInfo getClosestLevelOfDetail(WebExtent extent, int widthImg, int heightImg, Collection<WebLodInfo> lodInfos)
          Returns the closest level of detail for a given extent.
static WebLodInfo getClosestLevelOfDetail(WebExtent extent, VETileFunctionality veFunc)
          Returns the closest level of detail for a given extent and a VE functionality.
static ContainingTile getOriginContainingTile(WebExtent extent, VETileFunctionality veFunc)
          Retrieves the tile containing the origin point for the provided extent.
static ContainingTile getOriginContainingTile(WebExtent extent, VETileFunctionality veFunc, WebLodInfo lod)
          Retrieves the tile containing the origin point for the provided extent.
static String getQuadKey(int col, int row, int levelOfDetail)
          Returns a quad key according to a column, a row and a level of detail
static String getVEToken(String username, String password, String url, String clientIPAddress, int timeToLive)
          Retrieves a token for Microsoft Virtual Earth web services.
static int pixelXToColumn(double x, WebLodInfo lod)
          Returns the column of the tiles for an X coordinate in the Web Mercator spatial reference at a specified level of detail.
static VETile pixelXYToTile(double x, double y, WebLodInfo lod)
          Converts pixel XY coordinates into VE tile XY coordinates.
static int pixelYToRow(double y, WebLodInfo lod)
          Returns the row of the tiles for a Y coordinate in the Web Mercator spatial reference at a specified level of detail.
static String requestVirtualEarthToken(VEUser user, VETokenInfo tokenInfo)
          Retrieves a token for Microsoft Virtual Earth web services.
static boolean scalesEqual(double scale1, double scale2)
          Determines if 2 scales are equal with a tolerance based on whether or not the difference between the 2 scales would be noticeable once the tiles are displayed.
static ContainingTile webPointToTile(WebPoint containedPoint, WebLodInfo lod, WebPoint origin)
          Returns a Containing tile for a given point at a particular level of detail.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

pixelXYToTile

public static VETile pixelXYToTile(double x,
                                   double y,
                                   WebLodInfo lod)
Converts pixel XY coordinates into VE tile XY coordinates.

Parameters:
x - the pixel X coordinate
y - the pixel Y coordinate
lod - the Level of Detail of the tile to retrieve
Returns:
the VE tile containing the pixel

pixelXToColumn

public static int pixelXToColumn(double x,
                                 WebLodInfo lod)
Returns the column of the tiles for an X coordinate in the Web Mercator spatial reference at a specified level of detail.

Parameters:
x - the X coordinate in the Web Mercator spatial reference
lod - the specified level of detail
Returns:
the column of the tiles

pixelYToRow

public static int pixelYToRow(double y,
                              WebLodInfo lod)
Returns the row of the tiles for a Y coordinate in the Web Mercator spatial reference at a specified level of detail.

Parameters:
y - the Y coordinate in the Web Mercator spatial reference
lod - the specified level of detail
Returns:
the row of the tiles

webPointToTile

public static ContainingTile webPointToTile(WebPoint containedPoint,
                                            WebLodInfo lod,
                                            WebPoint origin)
Returns a Containing tile for a given point at a particular level of detail.

Parameters:
containedPoint - the point the tile has to contain
lod - the level of detail for the containing tile
origin - the point of origin
Returns:
the tile containing the provided point

getClosestLevelOfDetail

public static WebLodInfo getClosestLevelOfDetail(WebExtent extent,
                                                 VETileFunctionality veFunc)
Returns the closest level of detail for a given extent and a VE functionality. The size of the image is assumed to be the size of the WebMap associated with the VE functionality.

Parameters:
extent - the extent the level of detail has to match to
veFunc - the VE tile functionality
Returns:
WebLodInfo

getClosestLevelOfDetail

public static WebLodInfo getClosestLevelOfDetail(WebExtent extent,
                                                 int widthImg,
                                                 int heightImg,
                                                 Collection<WebLodInfo> lodInfos)
Returns the closest level of detail for a given extent.

Parameters:
extent - the extent the level of detail has to match to
veFunc - the VE tile functionality
widthImg - the width desired for the image
heightImg - the width desired for the image
lodInfos - the levels of details available
Returns:
WebLodInfo

assembleTiles

public static javax.media.jai.PlanarImage assembleTiles(String genericURL,
                                                        int levelOfDetail)
Returns an image composed with all the tiles for a given level of detail.

Parameters:
genericURL - the generic URL used to fetch the tiles
levelOfDetail - the level of details of the tiles
Returns:
a PlanarImage

assembleTiles

public static javax.media.jai.PlanarImage assembleTiles(String genericURL,
                                                        WebExtent extent,
                                                        VETileFunctionality veFunc)
Returns an image composed with all the tiles for a given extent.

Parameters:
genericURL - the generic URL used to fetch the tiles
extent - the extent
Returns:
a PlanarImage

assembleTiles

public static javax.media.jai.PlanarImage assembleTiles(String genericURL,
                                                        WebExtent extent,
                                                        int widthImg,
                                                        int heightImg,
                                                        Collection<WebLodInfo> lodInfos)
Returns an image composed with all the tiles for a given extent and to the size requested.

Parameters:
genericURL - the generic URL used to fetch the tiles
extent - the extent
widthImg - the width desired for the image
heightImg - the width desired for the image
lodInfos - the levels of details available
Returns:
a PlanarImage

assembleTiles

public static byte[] assembleTiles(String genericURL,
                                   int levelOfDetail,
                                   String imageFormat)
Returns an image composed with all the tiles for a given level of detail.

Parameters:
genericURL - the generic URL used to fetch the tiles
levelOfDetail - the level of details of the tiles
imageFormat - format of the image returned
Returns:
a Byte array

getQuadKey

public static String getQuadKey(int col,
                                int row,
                                int levelOfDetail)
Returns a quad key according to a column, a row and a level of detail

Parameters:
col - the column of the tile
row - the row of the tile
levelOfDetail - the level of detail of the tile

requestVirtualEarthToken

public static String requestVirtualEarthToken(VEUser user,
                                              VETokenInfo tokenInfo)
Retrieves a token for Microsoft Virtual Earth web services.

Parameters:
user - a VEUser
tokenInfo - a VETokenInfo
Returns:
String the token

getVEToken

public static String getVEToken(String username,
                                String password,
                                String url,
                                String clientIPAddress,
                                int timeToLive)
Retrieves a token for Microsoft Virtual Earth web services.

Parameters:
username - a valid username
password - the password associated to the username
url - the URL of the service providing tokens
clientIPAddress - the IP address of the client
timeToLive - The time the token will be valid for
Returns:
String the token

getOriginContainingTile

public static ContainingTile getOriginContainingTile(WebExtent extent,
                                                     VETileFunctionality veFunc,
                                                     WebLodInfo lod)
Retrieves the tile containing the origin point for the provided extent.

Parameters:
extent - the extent
veFunc - the VE functionality
lod - the level of detail
Returns:
ContainingTile the tile containing the origin point of the extent

getOriginContainingTile

public static ContainingTile getOriginContainingTile(WebExtent extent,
                                                     VETileFunctionality veFunc)
Retrieves the tile containing the origin point for the provided extent.

Parameters:
extent - the extent
veFunc - the VE functionality
Returns:
ContainingTile the tile containing the origin point of the extent

getCandidateTileInfo

public static CandidateTileInfo getCandidateTileInfo(WebExtent extent,
                                                     VETileFunctionality tileFunc)
Returns the Candidate Tile information for a given extent.

Parameters:
extent - the extent
tileFunc - the VE tile functionality
Returns:
CandidateTileInfo

scalesEqual

public static boolean scalesEqual(double scale1,
                                  double scale2)
Determines if 2 scales are equal with a tolerance based on whether or not the difference between the 2 scales would be noticeable once the tiles are displayed.

Parameters:
scale1 - - first scale to compare
scale2 - - second scale to compare
Returns:
boolean