Security News
Research
Data Theft Repackaged: A Case Study in Malicious Wrapper Packages on npm
The Socket Research Team breaks down a malicious wrapper package that uses obfuscation to harvest credentials and exfiltrate sensitive data.
s2-geometry
Advanced tools
A pure JavaScript/ES5.1 port of Google/Niantic's S2 Geometry library (used by Ingress, Pokemon GO)
| Sponsored by ppl
A pure JavaScript/ES5.1 port of Google/Niantic's S2 Geometry library (as used by Ingress, Pokemon GO)
Currently contains basic support for S2Cell
Face 2
Orientation A The North Pole (and Canada / Europe) | |||
Face 0
Orientation A Africa |
Face 1
Orientation D Asia |
Face 3
Orientation D Nothing (and Australia) |
Face 4
Orientation A The Americas (and Provo, UT) |
Face 5
Orientation D Antarctica |
'use strict';
var S2 = require('s2-geometry').S2;
var lat = 40.2574448;
var lng = -111.7089464;
var level = 15;
//
// Convert from Lat / Lng
//
var key = S2.latLngToKey(lat, lng, level);
// '4/032212303102210'
//
// Convert between Hilbert Curve Quadtree Key and S2 Cell Id
//
var id = S2.keyToId(key);
// '9749618446378729472'
var key = S2.idToKey(id);
// '9749618446378729472'
//
// Convert between Quadkey and Id
//
var latlng = S2.keyToLatLng(key);
var latlng = S2.idToLatLng(id);
//
// Neighbors
//
var neighbors = S2.latLngToNeighborKeys(lat, lng, level);
// [ keyLeft, keyDown, keyRight, keyUp ]
//
// Previous, Next, and Step
//
var nextKey = S2.nextKey(key);
var prevKey = S2.prevKey(key);
var backTenKeys = S2.stepKey(key, -10);
You can get the previous and next S2CellId from any given Key:
var key = S2.latLngToKey(40.2574448, -111.7089464, 15); // '4/032212303102210'
var id = S2.keyToId(key); // '9749618446378729472'
var nextKey = S2.nextKey(key);
var nextId = S2.keyToId(nextKey);
var prevKey = S2.prevKey(key);
var prevId = S2.keyToId(prevKey);
var backTenKeys = S2.stepKey(key, -10);
// See it
console.log(prevKey); // '4/032212303102203'
console.log(key); // '4/032212303102210'
console.log(nextKey); // '4/032212303102211'
console.log(nextId);
Convert from base 10 (decimal) S2 Cell Id
to base 4 quadkey
(aka hilbert curve quadtree id)
Example '4/032212303102210' becomes '9749618446378729472'
'use strict';
var quadkey = '4/032212303102210'
var parts = quadkey.split('/');
var face = parts[0]; // 4
var position = parts[1]; // '032212303102210';
var level = '032212303102210'.length; // 15
var cellId = S2.facePosLevelToId(face, position, level);
console.log(cellId);
Convert from hilbert quadtree id to s2 cell id:
Example '9749618446378729472' becomes '4/032212303102210'
'use strict';
var cellId = '9749618446378729472';
var hilbertQuadkey = S2.idToKey(cellId);
console.log(hilbertQuadkey);
var latlng = S2.keyToLatLng('4/032212303102210');
var latlng = S2.idToLatLng('9749618446378729472');
FAQs
A pure JavaScript/ES5.1 port of Google/Niantic's S2 Geometry library (used by Ingress, Pokemon GO)
The npm package s2-geometry receives a total of 15,555 weekly downloads. As such, s2-geometry popularity was classified as popular.
We found that s2-geometry demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer 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.
Security News
Research
The Socket Research Team breaks down a malicious wrapper package that uses obfuscation to harvest credentials and exfiltrate sensitive data.
Research
Security News
Attackers used a malicious npm package typosquatting a popular ESLint plugin to steal sensitive data, execute commands, and exploit developer systems.
Security News
The Ultralytics' PyPI Package was compromised four times in one weekend through GitHub Actions cache poisoning and failure to rotate previously compromised API tokens.