jonatkins / s2-geometry-javascript Goto Github PK
View Code? Open in Web Editor NEWPorting Google's S2 Geometry Library to Javascript
Porting Google's S2 Geometry Library to Javascript
We can now finally convert between S2CellId (uint64) and Hilbert Quadkey (``).
See
However, we lack the support to go from from a key to lat / lng. It seems that once this.ij
and this.st
are calculated, we already know this.face
(from either the key or id), so we can call the lat / lng method. However, we need to get those from the key/id somehow...
Once this is tested and has relevant documentation, it'll need a v1.0.0 tag for semver for use with npm, bower, or whatever else.
Where does one find 'L'?
Everyone is trying to implement their Pokemon GO clients in the browser, but if I could figure out what the 'L' is wrong with this library, I could take it to the browser, where it belongs. :D
In the meantime, I'm doing this: https://github.com/Daplie/node-pokemap/issues/1
Following Latitude and Longitute
lat = -6.120097
lng = 106.846511
return a Cell ID of '4197156086991552512'
Code:
var s2 = require('s2-geometry').S2;
var origin = s2.S2Cell.FromLatLng({lat: -6.120097, lng: 106.846511}, 15);
var cell = origin.toHilbertQuadkey();
console.log(s2.toId(origin));
Regards Skeec
Which license do you prefer? I'll add it and PR.
I like to dual-license Apache-2.0 and MIT because then it can be GPL-compatible via MIT and also grant relevant rights in perpetuity all IP via Apache-2.0.
Do you know if it's possible to apply a hilbert curve without converting the cell to a 64-bit ID and back?
I'm able to return neighbors and I have some code for the hilbert curve and I'm trying to figure out how to adapt it so that I can add next()
and prev()
functions to a cell, but it appears to need and integer as initial
.
I see you mention combine face,position to get the cell id
L16, but I'm not sure which function that refers to and there's no variable called position
, except in pointToHilbertQuadList
L161 & L256, but I'm not clear on how to use that to get next
and prev
.
Can you help me with this at all? I'd be willing to pay for consulting.
Is it possible to directly derive a CellId, such as 9749618446378729472 from the face,quadtree pair, such as 4/032212303102210?
face encoding
position encoding
level encoding
id encoding
Note that +
means concat
and NOT add
// id 9749618446378729472
// quadkey 4/032212303102210
// base 4 10 032212303102210 1000000000000000
// base 10 100 001110100110110011010010100100 1000000000000000000000000000000
Note that +
means concat
and NOT add
// psuedo-code
// This WON'T work because JavaScript uses 31-bit integers (53-bit floats)
var faceBits = 3;
var maxLevel = 30;
var maxBits = (maxLevel * 2) + 1; // one bit is lost to the marker
var str = face.toString(2) + position.toString(2) + '1';
str = padRight(str, maxBits, '0');
// 4/032212303102210
// 4 032212303102210 1000000000000000
// 100 0001110100110110011010010100100 1000000000000000000000000000000
Long.fromString('9749618446378729472', true, 10).toString('4');
'20131031212211021000000000000000'
Long.fromString('9749618446378729472', true, 10).toString('2');
'1000011101001101100110100101001001000000000000000000000000000000'
Expected:
9749618446378729472
20131031212211021000000000000000
1000011101001101100110100101001001000000000000000000000000000000
I'm currently hosting the updates at https://github.com/coolaj86/s2-geometry-javascript
Would you like to transfer ownership?
You can go to the transfer ownership section at the bottom of the settings page, click 'transfer' and choose to transfer s2-geometry-javascript
to Daplie
.
I've already created AUTHORS and LICENSE files in my fork to give you proper attribution.
Once we have a license I'll create the package.json
and publish (and add you as owner if you have an npm username)
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.