public/javascripts/vendor/javascripts/geolib.js
function(originLL, destLL, bearingMode) {

			var direction;
			if(bearingMode == 'circle') { // use great circle bearing
				var bearing = geolib.getBearing(originLL, destLL);
			} else { // default is rhumb line bearing
				var bearing = geolib.getRhumbLineBearing(originLL, destLL);
			}

			switch(Math.round(bearing/22.5)) {
				case 1:
					direction = {exact: "NNE", rough: "N"};
					break;
				case 2:
					direction = {exact: "NE", rough: "N"}
					break;
				case 3:
					direction = {exact: "ENE", rough: "E"}
					break;
				case 4:
					direction = {exact: "E", rough: "E"}
					break;
				case 5:
					direction = {exact: "ESE", rough: "E"}
					break;
				case 6:
					direction = {exact: "SE", rough: "E"}
					break;
				case 7:
					direction = {exact: "SSE", rough: "S"}
					break;
				case 8:
					direction = {exact: "S", rough: "S"}
					break;
				case 9:
					direction = {exact: "SSW", rough: "S"}
					break;
				case 10:
					direction = {exact: "SW", rough: "S"}
					break;
				case 11:
					direction = {exact: "WSW", rough: "W"}
					break;
				case 12:
					direction = {exact: "W", rough: "W"}
					break;
				case 13:
					direction = {exact: "WNW", rough: "W"}
					break;
				case 14:
					direction = {exact: "NW", rough: "W"}
					break;
				case 15:
					direction = {exact: "NNW", rough: "N"}
					break;
				default:
					direction = {exact: "N", rough: "N"}
			}

			return direction;

		}
function(originLL, destLL, bearingMode) {

			var direction;
			if(bearingMode == 'circle') { // use great circle bearing
				var bearing = geolib.getBearing(originLL, destLL);
			} else { // default is rhumb line bearing
				var bearing = geolib.getRhumbLineBearing(originLL, destLL);
			}

			switch(Math.round(bearing/22.5)) {
				case 1:
					direction = {exact: "NNE", rough: "N"};
					break;
				case 2:
					direction = {exact: "NE", rough: "N"}
					break;
				case 3:
					direction = {exact: "ENE", rough: "E"}
					break;
				case 4:
					direction = {exact: "E", rough: "E"}
					break;
				case 5:
					direction = {exact: "ESE", rough: "E"}
					break;
				case 6:
					direction = {exact: "SE", rough: "E"}
					break;
				case 7:
					direction = {exact: "SSE", rough: "S"}
					break;
				case 8:
					direction = {exact: "S", rough: "S"}
					break;
				case 9:
					direction = {exact: "SSW", rough: "S"}
					break;
				case 10:
					direction = {exact: "SW", rough: "S"}
					break;
				case 11:
					direction = {exact: "WSW", rough: "W"}
					break;
				case 12:
					direction = {exact: "W", rough: "W"}
					break;
				case 13:
					direction = {exact: "WNW", rough: "W"}
					break;
				case 14:
					direction = {exact: "NW", rough: "W"}
					break;
				case 15:
					direction = {exact: "NNW", rough: "N"}
					break;
				default:
					direction = {exact: "N", rough: "N"}
			}

			return direction;

		}
function ( originLL , destLL , bearingMode ) { var direction ; if ( bearingMode == 'circle' ) { // use great circle bearing var bearing = geolib . getBearing ( originLL , destLL ) ; } else { // default is rhumb line bearing var bearing = geolib . getRhumbLineBearing ( originLL , destLL ) ; } switch ( Math . round ( bearing / 22.5 ) ) { case 1 : direction = { exact : "NNE" , rough : "N" } ; break ; case 2 : direction = { exact : "NE" , rough : "N" } break ; case 3 : direction = { exact : "ENE" , rough : "E" } break ; case 4 : direction = { exact : "E" , rough : "E" } break ; case 5 : direction = { exact : "ESE" , rough : "E" } break ; case 6 : direction = { exact : "SE" , rough : "E" } break ; case 7 : direction = { exact : "SSE" , rough : "S" } break ; case 8 : direction = { exact : "S" , rough : "S" } break ; case 9 : direction = { exact : "SSW" , rough : "S" } break ; case 10 : direction = { exact : "SW" , rough : "S" } break ; case 11 : direction = { exact : "WSW" , rough : "W" } break ; case 12 : direction = { exact : "W" , rough : "W" } break ; case 13 : direction = { exact : "WNW" , rough : "W" } break ; case 14 : direction = { exact : "NW" , rough : "W" } break ; case 15 : direction = { exact : "NNW" , rough : "N" } break ; default : direction = { exact : "N" , rough : "N" } } return direction ; }
Gets the compass direction from an origin coordinate to a destination coordinate.

@param		object		origin coordinate (e.g. {latitude: 51.5023, longitude: 7.3815})
@param		object		destination coordinate
@param		string		Bearing mode. Can be either circle or rhumbline
@return		object		Returns an object with a rough (NESW) and an exact direction (NNE, NE, ENE, E, ESE, etc).
Gets the compass direction from an origin coordinate to a destination coordinate .