Socket
Socket
Sign inDemoInstall

spherical-geometry-js

Package Overview
Dependencies
0
Maintainers
2
Versions
9
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    spherical-geometry-js

This library provides classes and functions for the computation of geometric data on the surface of the Earth. Code ported from the Google Maps Javascript API v3 and tubalmartin/spherical-geometry-php


Version published
Maintainers
2
Install size
48.6 kB
Created

Readme

Source

Spherical Geometry Library · Build Status npm PRs Welcome

This library provides classes and functions for the computation of geometric data on the surface of the Earth.

This library ports a small but useful subset of classes from the Google Maps Javascript API version 3, to use as a separate module or in node.

How to use

import * as geometry from 'spherical-geometry-js';

Or import individual modules

import { computeArea } from 'spherical-geometry-js';
import computeArea from 'spherical-geometry-js/compute-area';

Notes:

  • The API is nearly identical to the Google Maps Javascript API.
  • computeOffsetOrigin has not yet been implemented
  • All computed lengths are returned in meters.

API

The full API of the library is described in the typings file.

Classes and libraries ported from the Google Maps Javascript API:

For convenience, LatLng includes some extra methods.

const latlng = new LatLng(123, 56);
// Alias getters for longitude and latitude

latlng.x === latlng.lng();
latlng.y === latlng.lat();

latlng[0] === latlng.lng();
latlng[1] === latlng.lat();
import { equalLatLngs } from 'spherical-geometry-js';

equalLatLngs(latlng1, latlng2) === latlng1.equals(latlng2);

A function called convertLatLng can be used. It tries to convert an object into a LatLng.

convertLatLng(like) ⇒ LatLng

Converts an object into a LatLng. Tries a few different methods:

  1. If instanceof LatLng, clone and return the object

  2. If it has 'lat' and 'lng' properties...

    2a. if the properties are functions (like Google LatLngs), use the lat() and lng() values as lat and lng

    2b. otherwise get lat and lng, parse them as floats and try them

  3. If it has 'lat' and 'long' properties, parse them as floats and return a LatLng

  4. If it has number values for 0 and 1, use 1 as latitude and 0 as longitude.

  5. If it has x and y properties, try using y as latitude and x and longitude.

Keywords

FAQs

Last updated on 14 Dec 2018

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc