earth-coordinate-distance

1.0.6 • Public • Published

Earth Coordinate Distance

This is light weight javascript package for calculating distance between two coordinates.

Installation

Use the package manager npm or yarn to install "earth-coordinate-distance".

npm install earth-coordinate-distance
yarn add earth-coordinate-distance

Usage

Use single or multiple import based on your use case.

import { coordinateDistance, checkInsideRadius, checkMultiInsideRadius, checkSingleRadiusWithMulti } from 'earth-coordinate-distance';

There are three types of options in this module.

const option_one = {
    unit: 'meter',
    overrideEarthRadius: null
}

const option_two = {
    ...option_one,
    radius: 1500
}

const option_three = {
    ...option_two,
    full: false,
    inside: true,
}

Data formats in this module.

const format_one = {
    lat1: 30.71179282255132,
    lat2: 30.71520428155315,
    lon1: 76.69702583818913,
    lon2: 76.70953675185454,
    // <Any Data>
}
const format_two = [
    {
        lat1: 30.71179282255132,
        lat2: 30.71520428155315,
        lon1: 76.69702583818913,
        lon2: 76.70953675185454,
        // <Any Data>
    },
    {
        lat1: 30.71179282255132,
        lat2: 30.712875802368803,
        lon1: 76.69702583818913,
        lon2: 76.72515449908545,
        // <Any Data>
    },
]
const format_three = [
    {
        lat: 30.71520428155315,
        lon: 76.70953675185454,
        // <Any Data>
        
    },
    {
        lat: 30.712875802368803,
        lon: 76.72515449908545,
        // <Any Data>
    },
]
const format_four = {
    lat: 30.71179282255132,
    lon: 76.69702583818913
}

There are four types of functions in this module.

coordinateDistance(format_one, option_one) // return distance object

checkInsideRadius(format_one, option_two) // return boolean

checkMultiInsideRadius(format_two, option_three) // return array of distance objects

checkSingleRadiusWithMulti(format_four, format_three, option_three) // return array of distance objects

License

ISC

Package Sidebar

Install

npm i earth-coordinate-distance

Weekly Downloads

2

Version

1.0.6

License

ISC

Unpacked Size

6.3 kB

Total Files

3

Last publish

Collaborators

  • skm112