• CHANGELOG.md
• Example
• Installing
• Versions
• 77

# haversine.dart

Simple Haversine formula implementation to calculate geographic distance on earth having a pair of Latitude/Longitude points.

The haversine formula determines the great-circle distance between two points on a sphere given their longitudes and latitudes.

The formula in this library works on the basis of a spherical earth, which is accurate enough for most purposes.

`Disclaimer`: The earth is not quite a sphere. This means that errors from assuming spherical geometry might be considerable depending on the points, so: `don't trust your life on this value`.

Check this detailed information.

# Changelog #

## 0.0.1 #

• Initial version for calculating geographic distance using the Haversine formula

## 0.0.2 #

• Minor update, now using the WGS84 major axis for the Earth radius

## 1.0.0 #

Added coordinates validation. A coordinate is considered invalid if it meets at least one of the following criteria:

• Its latitude is greater than 90 degrees or less than -90 degrees.
• Its longitude is greater than 180 degrees or less than -180 degrees.

Update tests

## 1.0.2 #

Minor update to removee the upper bound sdk limit

example/haversine_example.dart

``````// Copyright (c) 2017, yeradis. All rights reserved. Use of this source code
// is governed by a BSD-style license that can be found in the LICENSE file.

import 'package:haversine/haversine.dart';

main() {
final lat1 = 41.139129;
final lon1 = 1.402244;

final lat2 = 41.139074;
final lon2 = 1.402315;

final harvesine = new Haversine.fromDegrees(latitude1: lat1,
longitude1: lon1,
latitude2: lat2,
longitude2: lon2);

print('Distance from location 1 to 2 is : \${harvesine.distance()}');
}
``````

## Use this package as a library

### 1. Depend on it

``````
dependencies:
haversine: ^1.0.2

``````

### 2. Install it

You can install packages from the command line:

with pub:

``````
\$ pub get

``````

with Flutter:

``````
\$ flutter packages get

``````

Alternatively, your editor might support `pub get` or `flutter packages get`. Check the docs for your editor to learn more.

### 3. Import it

Now in your Dart code, you can use:

``````
import 'package:haversine/haversine.dart';
``````
1.0.2 Feb 10, 2018
1.0.1 Oct 12, 2017
1.0.0 Oct 12, 2017
0.0.2 Oct 1, 2017
0.0.1 Sep 30, 2017
 Popularity: Describes how popular the package is relative to other packages. [more] 76 Health: Code health derived from static analysis. [more] 75 Maintenance: Reflects how tidy and up-to-date the package is. [more] 80 Overall: Weighted score of the above. [more] 77

We analyzed this package on Apr 24, 2019, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

• Dart: 2.2.0
• pana: 0.12.14

#### Platforms

Detected platforms: Flutter, web, other

No platform restriction found in primary library `package:haversine/haversine.dart`.

#### Health issues and suggestions

Fix `lib/src/haversine_base.dart`. (-25 points)

Analysis of `lib/src/haversine_base.dart` failed with 1 error:

line 72 col 68: Undefined name 'PI'.

Format `lib/haversine.dart`.

Run `dartfmt` to format `lib/haversine.dart`.

#### Maintenance suggestions

Package is getting outdated. (-20 points)

The package was last published 62 weeks ago.

#### Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=1.20.1 <3.0.0
Dev dependencies
test ^0.12.0