Class WMSAspect

This class is used by the WMSMapCanvas child class to store information for different image aspects/projections. This way, a different projection and map server information can be attached to each view, allowing you to use the same WMSMapCanvas object for a number of different map views. You must attach at least one WMSAspect object to WMSMapCanvas for it to work properly. Note that the Aspect, once created, is never altered, though the WMSMapCanvas can use the information the aspect contains to retrieve zooms of the view.


Constructor Summary

WMSAspect ( newName , newURL , newSRS , newBounds , newLayers , newRows , newCols , newProjection )
Create a WMSAspect object and initialize the grids and other information it contains.

Method Summary

regrid ( bnds , rows , cols )
Return a regridded version of the aspect info.
getBounds ( )
Return the bounds for the aspect
rowColToRS ( row , col , r , s )
Converts a row/col grid coordinate to R/S MapServer coordinates.
rsToRowCol ( r , s , row , col )
Converts R/S MapServer coordinates to a row/col in the grid
keepInBounds ( newBnds )
Ensures that the bounds object passed in remains within the Aspect's bounds

Constructor Detail

WMSAspect

Create a WMSAspect object and initialize the grids and other information it contains.


Parameters
newName - The name of the aspect, used for switching between the various aspects.
newURL - The base URL of the WMS Map Server that will provide images.
newSRS - The Spatial Reference System that the WMS Map Server will use with the images;
newBounds - An object containing the bounds information for the aspect
newLayers - A string containing the layers to be used for the WMS Map Server
newRows - The number of rows the map's grid contains
newCols - The number of columns the map's grid contains
newProjection - The Mapx projection to use with this Aspect


Returns
A new WMSAspect object, initialized.

Examples
var asp = new WMSAspect('north', 'http://someURL', 'EPSG:3409',
{minx:-9036842.762,miny:-9036842.762,
maxx: 9036842.762,maxy: 9036842.762},
'blue_marble_01_circle,north_pole_geographic',
19, 19, projinfo);
// Creates a new aspect for the Northern Hemisphere, and
// using a 19x19 "grid" for potential underlying tiles.

Notes
All the inputs are required. newName can be any string, but make sure it is stored somewhere as to change to an aspect you must do so by name. The URL should be the full path to the target WMS scripts or executables; the URL should return an image bytestream. The SRS values available depend on the WMS being used. newBounds is an object with minx, miny, maxx, and maxy properties. The newLayers depends on the WMS being used. newRows and newCols are mostly used with the Row/Col information; if you don't want it tiled, you can just pass in the number of pixels for each. Finally, the newProjection must already be defined and initialized before being passed in.

Method Detail

regrid

Return a regridded version of the aspect info.


Parameters
bnds - An object containing the new bounds parameters
rows - The number of rows in the new grid
cols - The number of columns in the new grid

Returns
A Grids object conforming to the information passed in.

Examples
var newGrid = asp.regrid({minx:-903684.2762,miny:-903684.2762,
maxx: 903684.2762,maxy: 903684.2762},
1.9,1.9);
// A rough example, would create a grid reprenting a zoom of
// the center of the original bounds.

Notes
You will usually not have to call this yourself, as the WMSMapCanvas object will handle it. The bnds object will have four fields: minx, miny, maxx, and maxy; These are in the same "scale" as the bounds passed into the constructor.


getBounds

Return the bounds for the aspect


Parameters
None.

Returns
An object containing the bounds information.

Examples
var bnds = asp.getBounds();
// Returns the bounds object for the aspect

Notes
The bounds returned are the bounds set by the constructor. The object will have 4 fields: minx, miny, maxx, maxy. You should rarely need to call this manually, but it is used by the WMSMapCanvas object as the bounds information is not stored there.


rowColToRS

Converts a row/col grid coordinate to R/S MapServer coordinates.


Parameters
row - The row coordinate value
col - The column coordinate value
r - An array to store the resulting r value in [0]
s - An array to store the resulting s value in [0]

Returns
A boolean, which is true if the conversion is successful

Examples
var status = asp.rowColToRS(9.5, 9.5, r, s);
// Converts the row/col values given. If using the example
// from the constructor, r[0] and s[0] should both be 0, as
// this is the center of the grid.

Notes
r and s must be defined before calling the function. The [0] element of each will store the returned values. These values correspond with the relative Aspect coordinates set in the bounds given, with r being similar to x, s being similar to y.


rsToRowCol

Converts R/S MapServer coordinates to a row/col in the grid


Parameters
r - The r coordinate value
s - The s coordinate value
row - An array to store the resulting row in [0]
col - An array to store the resulting column in [0]

Returns
A boolean, which will be true if the conversion is successful

Examples
var status = asp.rowColToRS(0, 0, row, col);
// Converts the r/s values given. If using the example from
// the constructor, row[0] and col[0] should both be 9.5, as
// this is the center of the grid.

Notes
row and col must be defined before calling the function. The [0] element of each will store the returned values. These values will be relative to the Grids object for the aspect.


keepInBounds

Ensures that the bounds object passed in remains within the Aspect's bounds


Parameters
newBnds - The bounds object to check

Returns
None.

Examples
var bnds = {minx:-10000000,miny:-10000000,maxx: 0,maxy: 0});
asp.keepInBounds(bnds);
// Adjusts bnds so that the bounds values given are within the
// bounds set in the constructor.

Notes
Calling this method on a bounds object will cause the bounds information to be shifted if they are not in bounds. It does this by shifting the bounds so that the "edge" rests on the edge of the bounds if they are going out. If the newBnds object dimensions are "bigger" than the set bounds, the bounds object will be shrunk so that it fits completely within the bounds before shifting. The bounds object should have 4 fields: minx, miny, maxx, and maxy.