public/javascripts/vendor/javascripts/geolib.js
function(unit, distance, round) {

			if(distance == 0 || typeof distance == 'undefined') {

				if(geolib.distance == 0) {
					// throw 'No distance given.';
					return 0;
				} else {
					distance = geolib.distance;
				}

			}

			unit = unit || 'm';
			round = (null == round ? 4 : round);

			switch(unit) {

				case 'm':    // Meter
					return geolib.round(distance, round);
					break;
				case 'km':    // Kilometer
					return geolib.round(distance / 1000, round);
					break;
				case 'cm':    // Centimeter
					return geolib.round(distance * 100, round);
					break;
				case 'mm':    // Millimeter
					return geolib.round(distance * 1000, round);
					break;
				case 'mi':    // Miles
					return geolib.round(distance * (1 / 1609.344), round);
					break;
				case 'sm':    // Seamiles
					return geolib.round(distance * (1 / 1852.216), round);
					break;
				case 'ft':    // Feet
					return geolib.round(distance * (100 / 30.48), round);
					break;
				case 'in':    // Inch
					return geolib.round(distance * 100 / 2.54, round);
					break;
				case 'yd':    // Yards
					return geolib.round(distance * (1 / 0.9144), round);
					break;
			}

			return distance;

		}
function(unit, distance, round) {

			if(distance == 0 || typeof distance == 'undefined') {

				if(geolib.distance == 0) {
					// throw 'No distance given.';
					return 0;
				} else {
					distance = geolib.distance;
				}

			}

			unit = unit || 'm';
			round = (null == round ? 4 : round);

			switch(unit) {

				case 'm':    // Meter
					return geolib.round(distance, round);
					break;
				case 'km':    // Kilometer
					return geolib.round(distance / 1000, round);
					break;
				case 'cm':    // Centimeter
					return geolib.round(distance * 100, round);
					break;
				case 'mm':    // Millimeter
					return geolib.round(distance * 1000, round);
					break;
				case 'mi':    // Miles
					return geolib.round(distance * (1 / 1609.344), round);
					break;
				case 'sm':    // Seamiles
					return geolib.round(distance * (1 / 1852.216), round);
					break;
				case 'ft':    // Feet
					return geolib.round(distance * (100 / 30.48), round);
					break;
				case 'in':    // Inch
					return geolib.round(distance * 100 / 2.54, round);
					break;
				case 'yd':    // Yards
					return geolib.round(distance * (1 / 0.9144), round);
					break;
			}

			return distance;

		}
function ( unit , distance , round ) { if ( distance == 0 || typeof distance == 'undefined' ) { if ( geolib . distance == 0 ) { // throw 'No distance given.'; return 0 ; } else { distance = geolib . distance ; } } unit = unit || 'm' ; round = ( null == round ? 4 : round ) ; switch ( unit ) { case 'm' : // Meter return geolib . round ( distance , round ) ; break ; case 'km' : // Kilometer return geolib . round ( distance / 1000 , round ) ; break ; case 'cm' : // Centimeter return geolib . round ( distance * 100 , round ) ; break ; case 'mm' : // Millimeter return geolib . round ( distance * 1000 , round ) ; break ; case 'mi' : // Miles return geolib . round ( distance * ( 1 / 1609.344 ) , round ) ; break ; case 'sm' : // Seamiles return geolib . round ( distance * ( 1 / 1852.216 ) , round ) ; break ; case 'ft' : // Feet return geolib . round ( distance * ( 100 / 30.48 ) , round ) ; break ; case 'in' : // Inch return geolib . round ( distance * 100 / 2.54 , round ) ; break ; case 'yd' : // Yards return geolib . round ( distance * ( 1 / 0.9144 ) , round ) ; break ; } return distance ; }
Converts a distance from meters to km, mm, cm, mi, ft, in or yd

@param		string		Format to be converted in
@param		float		Distance in meters
@param               float           Decimal places for rounding (default: 4)
@return		float		Converted distance
Converts a distance from meters to km mm cm mi ft in or yd