GithubHelp home page GithubHelp logo

l4u / cjahaversine Goto Github PK

View Code? Open in Web Editor NEW

This project forked from carlj/cjahaversine

0.0 1.0 0.0 256 KB

Calculate the distance betweens two GPS coordinates with the Haversine Formular.

License: MIT License

cjahaversine's Introduction

#CJAHaversine Calculate the distance betweens two GPS coordinates with the Haversine Formular.

As of iOS 7 release, you can use the MKDistanceFormatter Class to calculate the distance between two locations.

Build Status Coverage Status

##Installation

  • Drag & Drop CJAHaversine.h and CJAHaversine.m to your project

If you want to use the CLLocationCoordinate2D functions:

  • Add the CoreLocation framework to your target
  • Import <CoreLocation/CoreLocation.h> to your targets ...-Prefix.pch file

##Usage calculate the distance in the imperial system:

//Calculate the distance between two location in kilometers
distance = CJAHaversineMilesBetweenLocations(lat1, lon1, lat2, lon2);

//Calculate the distance between two location in meters
distance = CJAHaversineFeetsBetweenLocations(lat1, lon1, lat2, lon2);

calculate the distance in the metric system:

//Calculate the distance between two location in kilometers
distance = CJAHaversineKilometersBetweenLocations(lat1, lon1, lat2, lon2);

//Calculate the distance between two location in meters
distance = CJAHaversineMetersBetweenLocations(lat1, lon1, lat2, lon2);

You can also use the CLLocationCoordinate2D struct from the CoreLocation framework:

//Calculate the distance between two `CLLocationCoordinate2D` in miles
distance = CJAHaversineMilesBetweenCLLocations(first, second);

//Calculate the distance between two `CLLocationCoordinate2D` in feets
distance = CJAHaversineFeetsBetweenCLLocations(first, second);

//Calculate the distance between two `CLLocationCoordinate2D` in kilometers
distance = CJAHaversineKilometersBetweenCLLocations(first, second);

//Calculate the distance between two `CLLocationCoordinate2D` in meters
distance = CJAHaversineMetersBetweenCLLocations(first, second);

##License Released under the MIT license.

cjahaversine's People

Contributors

carlj avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.