CFLib.org – Common Function Library Project

calculateUTMZone(lat, lon)

Last updated February 3, 2006

author

Wayne Graham

Version: 1 | Requires: CF5 | Library: UtilityLib

Description:
Calculates correct UTM zone for a given latitude/longitude point. Longitude and latitude points are given in degree format.

Return Values:
Returns a number.

Example:

<cfset lat = 90>
<cfset lon = 33>
<cfoutput>
	#calculateUTMZone(lat,lon)#
</cfoutput>

Parameters:

Name Description Required
lat Latitude value. Yes
lon Longitude value. Yes

Full UDF Source:

/**
 * Calculates correct UTM zone for a given latitude/longitude point.
 * 
 * @param lat 	 Latitude value. (Required)
 * @param lon 	 Longitude value. (Required)
 * @return Returns a number. 
 * @author Wayne Graham (wsgrah@wm.edu) 
 * @version 1, February 3, 2006 
 */
function calculateUTMZone(lat,lon){
	// make sure the longitude is between -180 and 179.9
	var lonTemp = (arguments.lon + 180) - int((arguments.lon + 180) / 360) * 360 - 180;
	var zoneNumber = int((lonTemp + 180)/6) + 1;
			
	// Special zones for Svalbard
	if(arguments.lat GTE 72 and arguments.lat GT 84) {
		if(lonTemp GTE 0 AND lonTemp LT 9) zoneNumber = 31;
		else if(lonTemp GTE 9 AND lonTemp LT 21) zoneNumber = 33;
		else if(lonTemp GTE 21 AND lonTemp LT 33) zoneNumber = 35;
		else if(lonTemp GTE 33 AND lonTemp LT 42) zoneNumber = 37;
	}			
	return zoneNumber;
}
blog comments powered by Disqus

Search CFLib.org


Latest Additions

Kevin Cotton added
date2ExcelDate
May 5, 2016

Raymond Camden added
CapFirst
April 25, 2016

Chris Wigginton added
loremIpsum
January 18, 2016

Gary Stanton added
calculateArrival...
November 19, 2015

Sebastiaan Naafs - van Dijk added
getDaysInQuarter
November 13, 2015

Created by Raymond Camden / Design by Justin Johnson