public/javascripts/vendor/javascripts/geolib.js
function(start, end, accuracy) {

			var keys = geolib.getKeys(start);
			var latitude = keys.latitude;
			var longitude = keys.longitude;

			accuracy = Math.floor(accuracy) || 1;

			var coord1 = {}, coord2 = {};
			coord1[latitude] = parseFloat(geolib.useDecimal(start[latitude])).toRad();
			coord1[longitude] = parseFloat(geolib.useDecimal(start[longitude])).toRad();

			coord2[latitude] = parseFloat(geolib.useDecimal(end[latitude])).toRad();
			coord2[longitude] = parseFloat(geolib.useDecimal(end[longitude])).toRad();

			var distance = 
				Math.round(
					Math.acos(
						Math.sin(
							coord2[latitude]
						) * 
						Math.sin(
							coord1[latitude]
						) + 
						Math.cos(
							coord2[latitude]
						) * 
						Math.cos(
							coord1[latitude]
						) * 
						Math.cos(
							coord1[longitude] - coord2[longitude]
						) 
					) * radius
				);

			return geolib.distance = Math.floor(Math.round(distance/accuracy)*accuracy);

		}
function(start, end, accuracy) {

			var keys = geolib.getKeys(start);
			var latitude = keys.latitude;
			var longitude = keys.longitude;

			accuracy = Math.floor(accuracy) || 1;

			var coord1 = {}, coord2 = {};
			coord1[latitude] = parseFloat(geolib.useDecimal(start[latitude])).toRad();
			coord1[longitude] = parseFloat(geolib.useDecimal(start[longitude])).toRad();

			coord2[latitude] = parseFloat(geolib.useDecimal(end[latitude])).toRad();
			coord2[longitude] = parseFloat(geolib.useDecimal(end[longitude])).toRad();

			var distance = 
				Math.round(
					Math.acos(
						Math.sin(
							coord2[latitude]
						) * 
						Math.sin(
							coord1[latitude]
						) + 
						Math.cos(
							coord2[latitude]
						) * 
						Math.cos(
							coord1[latitude]
						) * 
						Math.cos(
							coord1[longitude] - coord2[longitude]
						) 
					) * radius
				);

			return geolib.distance = Math.floor(Math.round(distance/accuracy)*accuracy);

		}
function ( start , end , accuracy ) { var keys = geolib . getKeys ( start ) ; var latitude = keys . latitude ; var longitude = keys . longitude ; accuracy = Math . floor ( accuracy ) || 1 ; var coord1 = { } , coord2 = { } ; coord1 [ latitude ] = parseFloat ( geolib . useDecimal ( start [ latitude ] ) ) . toRad ( ) ; coord1 [ longitude ] = parseFloat ( geolib . useDecimal ( start [ longitude ] ) ) . toRad ( ) ; coord2 [ latitude ] = parseFloat ( geolib . useDecimal ( end [ latitude ] ) ) . toRad ( ) ; coord2 [ longitude ] = parseFloat ( geolib . useDecimal ( end [ longitude ] ) ) . toRad ( ) ; var distance = Math . round ( Math . acos ( Math . sin ( coord2 [ latitude ] ) * Math . sin ( coord1 [ latitude ] ) + Math . cos ( coord2 [ latitude ] ) * Math . cos ( coord1 [ latitude ] ) * Math . cos ( coord1 [ longitude ] - coord2 [ longitude ] ) ) * radius ) ; return geolib . distance = Math . floor ( Math . round ( distance / accuracy ) * accuracy ) ; }
Calculates the distance between two spots.
This method is more simple but also more inaccurate

@param    object    Start position {latitude: 123, longitude: 123}
@param    object    End position {latitude: 123, longitude: 123}
@param    integer   Accuracy (in meters)
@return   integer   Distance (in meters)
Calculates the distance between two spots . This method is more simple but also more inaccurate