@maxdesplanches/maps-utils

1.1.6 • Public • Published


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 - max.desplanches@gmail.com

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

(back to top)

Readme

Keywords

Package Sidebar

Install

npm i @maxdesplanches/maps-utils

Weekly Downloads

0

Version

1.1.6

License

ISC

Unpacked Size

312 kB

Total Files

40

Last publish

Collaborators

  • maxdesplanches