Class Mapx

This class is actually an "abstract"-type superclass that cannot be instantiated manually. Rather, each projection supported are inherited from this class, and thus provide uniform interfaces to methods that require a Mapx method. See the mapx_projections.txt file for a list of the exact classes inherited from Mapx. These classes will not be be listed here because they all have the same functionality and methods.
Typically, you won't instantiate the subclasses yourself, either, as the MapMaker MapMaker class was written to abstract some of the details.
If you are creating your own custom projection subclass, the methods marked (!!) above MUST be overwritten. The other methods should NOT be overwritten.


Constructor Summary

Mapx ( )
Create an empty Mapx object.

Method Summary

setupvars ( projection_name , lat0 , lon0 , lat1 , lon1 , rotation , scale , center_lat , center_lon , south , north , west , east , lat_interval , lon_interval , label_lat , label_lon , cil_detail , bdy_detail , riv_detail , equatorial_radius , eccentricity )
Sets up the Mapx object parameters
reinit_mapx ( )
Reinitializes internal variables based on the parameters.
within_mapx ( lat , lon )
Determines if a lat/lon coordinate is within the set Mapx bounds.
forward_mapx ( lat , lon , u , v )
Converts a lat/lon coordinate to an x/y map coordinate.
inverse_mapx ( u , v , lat , lon )
Converts an x/y map coordiate to a lat/lon coordinate
initialize ( )
Sets up projection-specific initialization
geo_to_map ( lat , lon , u , v )
Converts from lat/lon to x/y
inverse_mapx ( u , v , lat , lon )
Converts an x/y map coordiate to a lat/lon coordinate

Constructor Detail

Mapx

Create an empty Mapx object.


Parameters
None.

Returns
An empty, uninitialized Mapx object.

Examples
var mx = new Mapx;

Notes
After creating the object, you must initialize it by calling the setupvars method below.

Method Detail

setupvars

Sets up the Mapx object parameters


Parameters
projection_name - A string of the projection name
lat0 - lat0 value used by the projection (*)
lon0 - lon0 value used by the projection (*)
lat1 - lat1 value used by the projection (*)
lon1 - lon1 value used by the projection (*)
rotation - The rotation angle to use
scale - The scale factor to use
center_lat - The latitude of the projection center (*)
center_lon - The longitude of the projection center (*)
south - The southernmost limit of the projection
north - The northernmost limit of the projection
west - The westernmost limit of the projection
east - The easternmost limit of the projection
lat_interval - The latitude interval (**)
lon_interval - The longitude interval (**)
label_lat - The label for latitude (**)
label_lon - The label for longitude (**)
cil_detail - 1 or 0, represents Coastline/Island/Lake (**)
bdy_detail - 1 or 0, represents political boundaries (**)
riv_detail - 1 or 0, represents rivers (**)
equatorial_radius - Optional radius of the equator
eccentricity - Optional eccentricity for ellipse projections

Returns
None.

Examples
mx.setupvars('Azimuthal Equal-Area', 90, 0, 0, 0,
0, 1, 90, 0, 0, 90, -180, 180, 15, 30, 0, 0,
0, 0, 1, 6371228.0, 0);
// Creates a Mapx object using the Azimuthal Equal-Area projection
// and the parameters given above.

Notes
The values marked with (**) are not currently utilized by this version of Mapx, but represent values that may be useful in future applications. They are used for display purposes, not calculation purposes. It is possible in future versions that these values may be removed, though if this happens tis version will still be available for backwards compatibility. equatorial_radius is optional. If it is not provided, a default value of 6371.228 is used. eccentricity is optional, and only used for projections that use an elliptical earth. If so, and the value is not provided, a default value of 0.082271673 is used. The projection name is not used except for display purposes, though it is advised that it represent the name of the proejction object being used for the class. The parameters marked as (*) above are specific to the projections. Some projections may not use certain values, in which case any value can be used as a place- holder for those values. The south boundary cannot be greater than the north boundary. However, the west boundary may be greater than the east boundary. If so, this will mean the map boundaries straddle the dateline.


reinit_mapx

Reinitializes internal variables based on the parameters.


Parameters
None.

Returns
False if there was a problem with the initialization, true otherwise

Examples
var status = mx.reinit_mapx();
// Reinitializes internal Mapx variables and returns the status
// of whether it was successful

Notes
This should always be called after using the setupvars method, to ensure that other internal variables are set correctly.


within_mapx

Determines if a lat/lon coordinate is within the set Mapx bounds.


Parameters
lat - The latitude value of the coordinate
lon - The longitude value of the coordinate

Returns
True if the coordinate is within the bounds, false otherwise.

Examples
var inbounds = mx.within_mapx(30.3, -30.2);
// Returns true if the coordinate 30.3N, -30.2S is within the
// boundaries set for the projection

Notes
Latitude values can be any numeric value. This value will be normalized into a -180 to 180 range before checking validity. Negative lat/lon values represent South/West, positive represent North/East.


forward_mapx

Converts a lat/lon coordinate to an x/y map coordinate.


Parameters
lat - The latitude value to convert
lon - The longitude value to convert
u - An array to hold the "x" result
v - An array to hold the "y" result

Returns
False if there is an error converting, true otherwise.

Examples
var status = mx.forward_mapx(30.3, -40.2, x, y);
// Converts the coordinate 30.3N, 40.2W to the x/y values
// that coordinate represents on the projected map.

Notes
u and v are used for parameters to account for potential rotation of the projection. This method really wraps the projection- specific geo_to_map method. The u and v arrays must be pre- allocated. The results will be stored in u[0] and v[0].


inverse_mapx

Converts an x/y map coordiate to a lat/lon coordinate


Parameters
u - The "x" value to convert
v - The "y" value to convert
lat - An array to hold the latitude value
lon - An array to hold the longitude value

Returns
False if there is an error converting, true otherwise.

Examples
var status = mx.inverse_mapx(300, 400, lat, lon);
// Converts the coordinate 300,400 into the respective
// latitude/longitude value.

Notes
u and v are used for parameters to account for potential rotation of the projection. This method really wraps the projection- specific map_to_geo method. The lat and lon arrays must be pre- allocated. The results will be stored in u[0] and v[0]


initialize

Sets up projection-specific initialization


Parameters
None.

Returns
False if there is an error initializing, true otherwise.

Examples
var status = mx.initialize();
// Initializes projection variables

Notes
THIS METHOD MUST BE OVERWRITTEN IN ALL INHERITED CLASSES. This method should be called after setupvars to initialize any projection-specific information, such as defining constants used or making complex calculations based on the preset parameters. If you call reinit_mapx, this will be called for you. The overwritten method must return a boolean value, true to represent success, false to represent failure.


geo_to_map

Converts from lat/lon to x/y


Parameters
lat - The latitude value to convert
lon - The longitude value to convert
u - An array to hold the "x" result
v - An array to hold the "y" result

Returns
False if there is an error converting, true otherwise.

Examples
var status = mx.forward_mapx(30.3, -40.2, x, y);
// Converts the coordinate 30.3N, 40.2W to the x/y values
// that coordinate represents on the projected map.

Notes
THIS METHOD MUST BE OVERWRITTEN IN ALL INHERITED CLASSES. This method is where the actual work of converting from a lat/lon value to an x/y value should go. The following should be done for the implementation of this method: - Results should be stored in u[0] and v[0]. These results should account for rotation, if applicable. - The method should return true if the conversion is successful, false if not.


inverse_mapx

Converts an x/y map coordiate to a lat/lon coordinate


Parameters
u - The "x" value to convert
v - The "y" value to convert
lat - An array to hold the latitude value
lon - An array to hold the longitude value

Returns
False if there is an error converting, true otherwise.

Examples
var status = mx.inverse_mapx(300, 400, lat, lon);
// Converts the coordinate 300,400 into the respective
// latitude/longitude value.

Notes
THIS METHOD MUST BE OVERWRITTEN IN ALL INHERITED CLASSES. This method is where the actual work of converting from an x/y value to a lat/lon value should go. The following should be done for the implementation of this method: - Results should be stored in lat[0] and lon[0]. These results should account for rotation, if applicable. - The method should return true if the conversion is successful, false if not.