
Research
/Security News
Toptal’s GitHub Organization Hijacked: 10 Malicious Packages Published
Threat actors hijacked Toptal’s GitHub org, publishing npm packages with malicious payloads that steal tokens and attempt to wipe victim systems.
spherical-geometry-js
Advanced tools
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
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. I also try to have readable code, so that you can understand what calculations are being made.
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:
LatLng
s. See
convertLatLng
for more details.The full API of the library is described in the typings file.
Classes and libraries ported from the Google Maps Javascript API:
This module tries to maintain full API compatibility with Google Maps so it can be used as a drop-in replacement.
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);
LatLng
import { LatLng, convertLatLng } from 'spherical-geometry-js';
convertLatLng({ lat: 123, lng: 56 }).equals(new LatLng(123, 56));
convertLatLng([56, 123]).equals(new LatLng(123, 56));
convertLatLng({ x: 56, y: 123 }).equals(new LatLng(123, 56));
Helper function that tries to convert and object into a LatLng
. Tries a few
different methods:
If instanceof LatLng
, clone the object and return it.
If it has lat
and lng
properties...
2a. if the properties are functions (like Google LatLng
s), use the lat()
and lng()
values as latitude and longitude.
2b. otherwise get lat
and lng
, parse them as floats and use them.
If it has lat
and long
properties, parse them as floats use them.
If it has lat
and lon
properties, parse them as floats use them.
If it has latitude
and longitude
properties, parse them as floats use
them.
If it has number values for 0
and 1
(aka an array of two numbers), use
1
as latitude and 0
as longitude.
If it has x
and y
properties, try using y
as latitude and x
and
longitude.
FAQs
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
The npm package spherical-geometry-js receives a total of 9,734 weekly downloads. As such, spherical-geometry-js popularity was classified as popular.
We found that spherical-geometry-js demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 2 open source maintainers collaborating on the project.
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.
Research
/Security News
Threat actors hijacked Toptal’s GitHub org, publishing npm packages with malicious payloads that steal tokens and attempt to wipe victim systems.
Research
/Security News
Socket researchers investigate 4 malicious npm and PyPI packages with 56,000+ downloads that install surveillance malware.
Security News
The ongoing npm phishing campaign escalates as attackers hijack the popular 'is' package, embedding malware in multiple versions.