public/javascripts/vendor/javascripts/geolib.js
function(latlng, coords) {

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

			for(var c = false, i = -1, l = coords.length, j = l - 1; ++i < l; j = i) {

				(
					(coords[i][longitude] <= latlng[longitude] && latlng[longitude] < coords[j][longitude]) ||
					(coords[j][longitude] <= latlng[longitude] && latlng[longitude] < coords[i][longitude])
				)
			   && (latlng[latitude] < (coords[j][latitude] - coords[i][latitude]) 
					* (latlng[longitude] - coords[i][longitude])
					/ (coords[j][longitude] - coords[i][longitude]) + coords[i][latitude])
			   && (c = !c);

			}

			return c;

		}
function(latlng, coords) {

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

			for(var c = false, i = -1, l = coords.length, j = l - 1; ++i < l; j = i) {

				(
					(coords[i][longitude] <= latlng[longitude] && latlng[longitude] < coords[j][longitude]) ||
					(coords[j][longitude] <= latlng[longitude] && latlng[longitude] < coords[i][longitude])
				)
			   && (latlng[latitude] < (coords[j][latitude] - coords[i][latitude]) 
					* (latlng[longitude] - coords[i][longitude])
					/ (coords[j][longitude] - coords[i][longitude]) + coords[i][latitude])
			   && (c = !c);

			}

			return c;

		}
function ( latlng , coords ) { var keys = geolib . getKeys ( latlng ) ; var latitude = keys . latitude ; var longitude = keys . longitude ; for ( var c = false , i = - 1 , l = coords . length , j = l - 1 ; ++ i < l ; j = i ) { ( ( coords [ i ] [ longitude ] <= latlng [ longitude ] && latlng [ longitude ] < coords [ j ] [ longitude ] ) || ( coords [ j ] [ longitude ] <= latlng [ longitude ] && latlng [ longitude ] < coords [ i ] [ longitude ] ) ) && ( latlng [ latitude ] < ( coords [ j ] [ latitude ] - coords [ i ] [ latitude ] ) * ( latlng [ longitude ] - coords [ i ] [ longitude ] ) / ( coords [ j ] [ longitude ] - coords [ i ] [ longitude ] ) + coords [ i ] [ latitude ] ) && ( c = ! c ) ; } return c ; }
Checks whether a point is inside of a polygon or not.
Note that the polygon coords must be in correct order!

@param		object		coordinate to check e.g. {latitude: 51.5023, longitude: 7.3815}
@param		array		array with coords e.g. [{latitude: 51.5143, longitude: 7.4138}, {latitude: 123, longitude: 123}, ...]
@return		bool		true if the coordinate is inside the given polygon
Checks whether a point is inside of a polygon or not . Note that the polygon coords must be in correct order!