Skip to content

A package to have maps utils to calculate distance and angle between coordinates, or time for traveling (on distance as the crow flies for now)

License

Notifications You must be signed in to change notification settings

MaxDesplanches/maps-utils

Repository files navigation


Logo

Maps Utils

A package to have maps utils to calculate distance and angle between coordinates, or time for traveling (on distance as the crow flies for now)

Report Bug · Request Feature

About The Project

The goal of this project is to provide utils for your maps calculation as distance, angle, time.

Getting Started

Installation

Install NPM packages:

npm install @maxdesplanches/maps-utils

(back to top)

Usage (NodeJS, TypeScript below)

const mapsUtils = require("@maxdesplanches/maps-utils");

const location1 = {
  latitude1: 43.6206597,
  longitude1: 3.8553517,
};

const location2 = {
  latitude2: 43.6211969,
  longitude2: 3.8519288,
};

const coordinates = {
  ...location1,
  ...location2,
};

const distanceInKm = mapsUtils.getDistanceFromCoordinates(coordinates);

const angleInDegree = mapsUtils.getDegreeAngleFromCoordinates(coordinates);

const transportation = mapsUtils.Transportation.BUS;

const timeInMn1 = mapsUtils.getTimeInMnFromKm(distance, transportation);

const timeInMn2 = mapsUtils.getTimeInMnFromCoordinates(
  coordinates,
  transportation
);

(back to top)

Usage (Typescript)

import {
  getTimeInMnFromKm,
  getDegreeAngleFromCoordinates,
  getDistanceFromCoordinates,
  getTimeInMnFromCoordinates,
  Transportation,
} from "@maxdesplanches/maps-utils";

const location1 = {
  latitude1: 43.6206597,
  longitude1: 3.8553517,
};

const location2 = {
  latitude2: 43.6211969,
  longitude2: 3.8519288,
};

const coordinates = {
  ...location1,
  ...location2,
};

const distanceInKm = getDistanceFromCoordinates(coordinates);

const angleInDegree = getDegreeAngleFromCoordinates(coordinates);

const transportation = Transportation.BUS;

const timeInMn1 = getTimeInMnFromKm(distance, transportation);

const timeInMn2 = getTimeInMnFromCoordinates(coordinates, transportation);

(back to top)

Ressources

http://www.movable-type.co.uk/scripts/latlong.html https://www.calculatorsoup.com/calculators/math/speed-distance-time-calculator.php

(back to top)

License

Distributed under the MIT License. See LICENSE.txt for more information.

(back to top)

Contact

Max Desplanches - @Max_Desplanches - [email protected]

Project Link: https://github.com/MaxDesplanches/maps-utils

(back to top)

About

A package to have maps utils to calculate distance and angle between coordinates, or time for traveling (on distance as the crow flies for now)

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published