CoordinateCalculator

Use

``````/// pubspec.yaml
coordinate_calculator:
git:
url: https://github.com/DeliriousLee/CoordinateCalculator.git
/// main.dart
import 'package:coordinate_calculator/coordinate_calculator.dart';
/// calculate result: km
/// 计算结果：km
var result = DLCoordinateManager.kilometersDistanceFrom(
lat1: double.parse(_originLatitude.text),
long1: double.parse(_originLong.text),
lat2: double.parse(_destLatitude.text),
long2: double.parse(_destLong.text));
``````

Python

locationCalculator.py 附带了python版本的计算公式

``````#
#    @desc : python 版本的公式计算
#    @file : locationCalculator.py
#    @date : 23/02/07 11:47
#

import math
def sin_square(a):
result=math.sin(a)
return result*result
return math.pi*ang/180.0
#a,b参数是数组
def distance_calculate(a,b):
lata,lnga=a[0],a[1]
latb,lngb=b[0],b[1]

#纬度差
#经度差

``````

大圆公式

the great circle fromula reference from http://edwilliams.org/avform147.htm#Intro Distance between points The great circle distance d between two points with coordinates {lat1,lon1} and {lat2,lon2} is given by:

``````d=acos(sin(lat1)*sin(lat2)+cos(lat1)*cos(lat2)*cos(lon1-lon2))
``````

A mathematically equivalent formula, which is less subject to rounding error for short distances is:

``````d=2*asin(sqrt((sin((lat1-lat2)/2))^2 +
cos(lat1)*cos(lat2)*(sin((lon1-lon2)/2))^2))
``````