This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"vessel_info": { | |
"id": "8d435f12-8373-47c8-968d-a4881e9cd76c", | |
"name": "GOGOGOGOG1", | |
"hin": "", | |
"make_and_model": null, | |
"number_of_hulls": "1", | |
"created_at": "2018-09-10T13:14:03+01:00", | |
"updated_at": "2018-10-17T10:42:03+01:00", | |
"mmsi_number": "", |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// from https://rosettacode.org/wiki/Haversine_formula#Elixir | |
defmodule Haversine do | |
@v :math.pi / 180 | |
@r 6372.8 # km for the earth radius | |
def distance({lat1, long1}, {lat2, long2}) do | |
dlat = :math.sin((lat2 - lat1) * @v / 2) | |
dlong = :math.sin((long2 - long1) * @v / 2) | |
a = dlat * dlat + dlong * dlong * :math.cos(lat1 * @v) * :math.cos(lat2 * @v) | |
@r * 2 * :math.asin(:math.sqrt(a)) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// php implementation from http://stackoverflow.com/questions/14750275/haversine-formula-with-php | |
I calculate distances straight inside queries, using the following stored procedure: | |
CREATE FUNCTION GEODIST (lat1 DOUBLE, lon1 DOUBLE, lat2 DOUBLE, lon2 DOUBLE) | |
RETURNS DOUBLE | |
DETERMINISTIC | |
BEGIN | |
DECLARE dist DOUBLE; | |
SET dist = round(acos(cos(radians(lat1))*cos(radians(lon1))*cos(radians(lat2))*cos(radians(lon2)) + cos(radians(lat1))*sin(radians(lon1))*cos(radians(lat2))*sin(radians(lon2)) + sin(radians(lat1))*sin(radians(lat2))) * 6378.8, 1); | |
RETURN dist; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// php implementation from http://stackoverflow.com/questions/14750275/haversine-formula-with-php | |
I calculate distances straight inside queries, using the following stored procedure: | |
CREATE FUNCTION GEODIST (lat1 DOUBLE, lon1 DOUBLE, lat2 DOUBLE, lon2 DOUBLE) | |
RETURNS DOUBLE | |
DETERMINISTIC | |
BEGIN | |
DECLARE dist DOUBLE; | |
SET dist = round(acos(cos(radians(lat1))*cos(radians(lon1))*cos(radians(lat2))*cos(radians(lon2)) + cos(radians(lat1))*sin(radians(lon1))*cos(radians(lat2))*sin(radians(lon2)) + sin(radians(lat1))*sin(radians(lat2))) * 6378.8, 1); | |
RETURN dist; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//https://developers.google.com/maps/documentation/javascript/reference#spherical | |
computeOffset(from:LatLng, distance:number, heading:number, radius?:number) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// from: http://www.movable-type.co.uk/scripts/latlong-vincenty.html | |
var sinα1 = Math.sin(α1); | |
var cosα1 = Math.cos(α1); | |
var tanU1 = (1-f) * Math.tan(φ1), cosU1 = 1 / Math.sqrt((1 + tanU1*tanU1)), sinU1 = tanU1 * cosU1; | |
var σ1 = Math.atan2(tanU1, cosα1); | |
var sinα = cosU1 * sinα1; | |
var cosSqα = 1 - sinα*sinα; | |
var uSq = cosSqα * (a*a - b*b) / (b*b); | |
var A = 1 + uSq/16384*(4096+uSq*(-768+uSq*(320-175*uSq))); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/ruby | |
# | |
# This script installs to /usr/local only. To install elsewhere you can just | |
# untar https://github.com/mxcl/homebrew/tarball/master anywhere you like. | |
# | |
# | |
# 30th March 2010: | |
# Added a check to make sure user is in the staff group. This was a problem | |
# for me, and I think it was due to me migrating my account over several | |
# versions of OS X. I cannot verify that for sure, and it was tested on |