Skip to content

Instantly share code, notes, and snippets.

View mhasko's full-sized avatar

Michael Hasko mhasko

View GitHub Profile
@stephenfeather
stephenfeather / LatLon.js
Last active November 14, 2018 18:00
GeoTools we use in Appcelerator Titanium (sourced from Chris Veness) http://www.movable-type.co.uk/scripts/latlong.html
/*jslint vars: true, sloppy: true, nomen: true, maxerr: 1000 */
function LatLon(lat, lon, rad) {
if (typeof(rad) == 'undefined') rad = 6371; // earth's mean radius in km
// only accept numbers or valid numeric strings
this._lat = typeof(lat)=='number' ? lat : typeof(lat)=='string' && lat.trim()!='' ? +lat : NaN;
this._lon = typeof(lon)=='number' ? lon : typeof(lon)=='string' && lon.trim()!='' ? +lon : NaN;
this._radius = typeof(rad)=='number' ? rad : typeof(rad)=='string' && trim(lon)!='' ? +rad : NaN;
}