New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@id-sdk/geo

Package Overview
Dependencies
Maintainers
2
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@id-sdk/geo

Geographic (spherical) math functions

  • 3.0.0-pre.10
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
2
Created
Source

npm version

@id-sdk/geo

🌐 Geographic (spherical) math functions

Installing

npm install @id-sdk/geo

This library is distributed in ESM format only. It cannot be require()'d from CommonJS. For more, please read Sindre Sorhus’s FAQ.

import * as geo from '@id-sdk/geo';
import { geoLatToMeters } from '@id-sdk/geo';

Contributing

This project is just getting started! 🌱

We're not able to support external contributors at this time, but check back in a bit when things have matured.

API Reference

Functions
Types
  • Vec2: [number, number]
  • Closest: { index: number, distance: number, point: Vec2 }

Functions

# geoLatToMeters(dLat: number): number <>

Convert degrees latitude to meters.

geoLatToMeters(1);  // returns ≈111319

# geoLonToMeters(dLon: number, atLat: number): number <>

Convert degrees longitude to meters at a given latitude.

geoLonToMeters(1, 0);  // returns ≈110946 at equator

# geoMetersToLat(m: number): number <>

Convert meters to degrees latitude.

geoMetersToLat(111319);  // returns ≈1°

# geoMetersToLon(m: number, atLat: number): number <>

Convert meters to degrees longitude at a given latitude.

geoMetersToLon(110946, 0);  // returns ≈1° at equator

# geoMetersToOffset(m: Vec2, tileSize?: number): Vec2 <>

Convert offset in meters (for example, imagery offset) to offset in tile pixels. tileSize defaults to 256px.

geoMetersToOffset([100, 100]);  // returns ≈[0.00064, -0.00064] pixels

# geoOffsetToMeters(offset: Vec2, tileSize?: number): Vec2 <>

Convert imagery offset in tile pixels to offset in meters. tileSize defaults to 256px.

geoOffsetToMeters([0.00064, -0.00064]);  // returns ≈[100, 100] meters

# geoSphericalDistance(a: Vec2, b: Vec2): number <>

Equirectangular approximation of spherical distances on Earth.

geoSphericalDistance([0, 0], [1, 0]);  // returns ≈110946 meters

# geoScaleToZoom(k: number, tileSize?: number): number <>

Projection scale factor to tile zoom level. tileSize defaults to 256px.

geoScaleToZoom(5340353.7154);  // returns ≈17

# geoZoomToScale(z: number, tileSize?: number): number <>

Tile zoom to projection scale factor. tileSize defaults to 256px.

geoZoomToScale(17);  // returns ≈5340353.7154

# geoSphericalClosestPoint(points: Vec2[], a: Vec2): Closest | null <>

Returns info about the point from points closest to the given test point a.

Types

# Vec2

An array of two numbers.

[number, number]

# Closest

An Object containing index, distance, and point properties. Used as the return value for geoSphericalClosestPoint().

{ index: number, distance: number, point: Vec2 }

FAQs

Package last updated on 10 Sep 2021

Did you know?

Socket

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
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc