haversine 1.0.2

  • README.md
  • CHANGELOG.md
  • Example
  • Installing
  • Versions
  • 84

haversine.dart Pub Travis status Coverage Status

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.

see Decimal degrees

1.0.1

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

Add this to your package's pubspec.yaml file:


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';
  
Version Uploaded Documentation Archive
1.0.2 Feb 10, 2018 Go to the documentation of haversine 1.0.2 Download haversine 1.0.2 archive
1.0.1 Oct 12, 2017 Go to the documentation of haversine 1.0.1 Download haversine 1.0.1 archive
1.0.0 Oct 12, 2017 Go to the documentation of haversine 1.0.0 Download haversine 1.0.0 archive
0.0.2 Oct 1, 2017 Go to the documentation of haversine 0.0.2 Download haversine 0.0.2 archive
0.0.1 Sep 30, 2017 Go to the documentation of haversine 0.0.1 Download haversine 0.0.1 archive

Analysis

We analyzed this package on Jun 19, 2018, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.0.0-dev.63.0
  • pana: 0.11.3

Scores

Popularity:
Describes how popular the package is relative to other packages. [more]
70 / 100
Health:
Code health derived from static analysis. [more]
95 / 100
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
100 / 100
Overall score:
Weighted score of the above. [more]
84
Learn more about scoring.

Platforms

Detected platforms: Flutter, web, other

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

Suggestions

  • Fix analysis and formatting issues.

    Analysis or formatting checks reported 3 hints.

    Run dartfmt to format lib/haversine.dart.

    Run dartfmt to format lib/src/haversine_base.dart.

Dependencies

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