Closed patrickkuhlmann closed 8 years ago
This has already been fixed. It actually returns 1/130311003301320
now.
You're using an older version. Please update to v1.2.6
(at https://github.com/coolaj86/s2-geometry-javascript)
@Skeec I tested your values and get the same result with v1.2.6
as s2-geometry-node
Lat/Lng = -6.120097,106.846511
Quadkey
= 1/130311003301320
j 1/130311003301320 (3344518917396627456)
Which also matches up with the results of golang/geo/s2
:
{ "f": 1
, "u": 0.3028037841764609
, "v": -0.11203184522499791
, "i": 741661730
, "j": 453174890
, "lat": -6.120097
, "lng": 106.846511
, "cellid": 3344518917396627456
, "quadkey": "1/130311003301320"
, "token": "2e6a1e3c4"
}
Updated a minute ago and still getting 4197156086991552512
with v1.2.6
I'm using pogobuf which has dependency to this project (v1.2.6, according to it's package.json) and the result is what Skeec posted (it's my issue actually). I'll test it again later.
EDIT: Ok. I've test it with these lines of codes:
var s2 = require('s2geometry-node');
var ss2 = require('s2-geometry').S2;
var origin = ss2.S2Cell.FromLatLng({lat: -6.120097, lng: 106.846511}, 15);
var cell = origin.toHilbertQuadkey();
console.log('s2-geometry: ' + ss2.toId(cell));
origin = new s2.S2CellId(new s2.S2LatLng(-6.120097, 106.846511)).parent(15);
console.log('s2geometry-node: ' + origin.id());
And here's the result:
s2-geometry: 4197156086991552512
s2geometry-node: 3344518917396627456
It's definitely different value. s2-geometry's result cell is at an open ocean near India, while s2geometry-node's result cell is right at Jakarta, Indonesia, where the input coordinate pointing at. Looking at their final result, s2geometry-node's cell is the correct one.
Ah!!!!! Yes, I need to update the docs and a few of the helper functions.
I was using the functional-style to do my tests.
brb
Fixed in v1.2.7
See the new README.md
I'm trying to get away from the class
-oriented style and more towards the functional style.
It's always super easy to forEach over methods of a functional library to create a classy library, but it's not easy to turn a classy library into a functional library.
Nice. Good to hear that. Updating right away... :3
Allright thank you :)
Following Latitude and Longitute lat = -6.120097 lng = 106.846511 return a Cell ID of '4197156086991552512'
Code:
Regards Skeec