Giter Site home page Giter Site logo

geo-position.ts's Introduction

geo-position.ts ๐ŸŒŽ

Library for working with GeoPosition fot TypeScript

Build Status CodeCov npm

Install

yarn add geo-position.ts

Run test

yarn test or yarn test-nya and for reports yarn report-test

image

Usage

Create GeoPosition from coordinates

import { GeoPosition } from 'geo-position.ts';

/* ... */

new GeoPosition(71.317941, 55.691416);

71.317941 //-  Latitude  (ฮป)
55.691416 //-  Longitude (ฯ†)

Distance:

let xPoint = new GeoPosition(71.317941, 55.691416);
let yPoint = new GeoPosition(71.500873, 55.807184);

+xPoint.Distance(yPoint).toFixed(0) // -> 20844 meters

Zero check

new GeoPosition(0, 0).IsZero()         // -> true
new GeoPosition(71.317941, 55.691416)  // -> false
GeoPosition.Zero.IsZero()              // -> true

Validate Coordinates

GeoPosition.IsValidGpsCoordinate(71.317941, 55.691416) // true
GeoPosition.IsValidGpsCoordinate(271.317941, 255.691416) // false

Parse Coordinates

GeoPosition.GetGpsPosition("N71.317941", "E55.691416"); // -> [71.317941, 55.691416]
GeoPosition.GetGpsPosition("S71,317941", "W55,691416"); // -> [-71.317941, -55.691416]

Is Inside Area

(this area array coordinates)
image

let area = [
        new GeoPosition(71.51834193441157, 55.116358997070286),
        new GeoPosition(71.44676509856431, 54.92684483691404),
        new GeoPosition(71.33845776024275, 55.123225452148404),
        new GeoPosition(71.36701875276431, 55.43084263964841),
        new GeoPosition(71.45113719694054, 55.575038196289),
        new GeoPosition(71.5065763194486, 55.40749669238277),
        new GeoPosition(71.51834193441157, 55.116358997070286)
    ]

new GeoPosition(71.436275, 55.220661).IsInsideArea(area) // true
new GeoPosition(0, 0).IsInsideArea(area)                 // false

SectionCenterPosition

let pos = new GeoPosition(71.436706, 55.268108);
let pos2 = new GeoPosition(71.473202, 55.857764);

GeoPosition.SectionCenterPosition(pos, pos2) // GeoPosition(71.454954, 55.562936)

image

DistanceToSection

let start = new GeoPosition(71.436706, 55.268108);
let end = new GeoPosition(71.473202, 55.857764);
let point = new GeoPosition(71.504361, 55.511926);
GeoPosition.SectionCenterPosition(point, start, end) // 5807 meters

geo-position.ts's People

Contributors

0xf6 avatar dependabot[bot] avatar good-idea avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Forkers

arteha iqex

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.