This file contains 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
* ASM-ONE FORMAT | |
section aaa,code_c | |
AbsExecBase: equ $4 | |
_LVOLoadView: equ -$DE | |
_LVOCloseLibrary: equ -$19E | |
_LVOOpenLibrary: equ -$228 | |
_LVOWaitTOF: equ -$10E |
This file contains 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 math import radians, cos, sin, asin, sqrt | |
def haversine(lon1, lat1, lon2, lat2): | |
""" | |
Calculate the great circle distance between two points | |
on the earth (specified in decimal degrees) | |
""" | |
# convert decimal degrees to radians | |
lon1, lat1, lon2, lat2 = map(radians, [lon1, lat1, lon2, lat2]) |
This file contains 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
CREATE FUNCTION [dbo].[GetDistance] | |
( | |
@lat1 Float(8), | |
@long1 Float(8), | |
@lat2 Float(8), | |
@long2 Float(8) | |
) | |
RETURNS Float(8) | |
AS |
This file contains 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
Position pos1 = new Position(); | |
pos1.Latitude = 40.7486; | |
pos1.Longitude = -73.9864; | |
Position pos2 = new Position(); | |
pos2.Latitude = 24.7486; | |
pos2.Longitude = -72.9864; | |
Haversine hv = new Haversine(); | |
double result = hv.Distance(pos1, pos2, DistanceType.Kilometers); |
This file contains 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
def haversine(lat1, long1, lat2, long2) | |
dtor = Math::PI/180 | |
r = 6378.14*1000 | |
rlat1 = lat1 * dtor | |
rlong1 = long1 * dtor | |
rlat2 = lat2 * dtor | |
rlong2 = long2 * dtor | |
dlon = rlong1 - rlong2 |
This file contains 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
function getDistance($latitude1, $longitude1, $latitude2, $longitude2) { | |
$earth_radius = 6371; | |
$dLat = deg2rad($latitude2 - $latitude1); | |
$dLon = deg2rad($longitude2 - $longitude1); | |
$a = sin($dLat/2) * sin($dLat/2) + cos(deg2rad($latitude1)) * cos(deg2rad($latitude2)) * sin($dLon/2) * sin($dLon/2); | |
$c = 2 * asin(sqrt($a)); | |
$d = $earth_radius * $c; |