bugfix #3 pad face binary string
This commit is contained in:
parent
e3619d963a
commit
54bd875e3e
|
@ -333,6 +333,9 @@ S2.fromFacePosLevel = function (faceN, posS, levelN) {
|
||||||
posB = '0' + posB;
|
posB = '0' + posB;
|
||||||
}
|
}
|
||||||
var bin = Long.fromString(faceN.toString(10), true, 10).toString(2);
|
var bin = Long.fromString(faceN.toString(10), true, 10).toString(2);
|
||||||
|
while (bin.length < 3) {
|
||||||
|
bin = '0' + bin;
|
||||||
|
}
|
||||||
bin += posB;
|
bin += posB;
|
||||||
bin += '1';
|
bin += '1';
|
||||||
while (bin.length < (S2.FACE_BITS + S2.POS_BITS)) {
|
while (bin.length < (S2.FACE_BITS + S2.POS_BITS)) {
|
||||||
|
|
|
@ -29,6 +29,7 @@ function getNeighbors(lat, lng, step) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
// Startup Building in Provo
|
// Startup Building in Provo
|
||||||
var lat = 40.2262363;
|
var lat = 40.2262363;
|
||||||
var lng = -111.6630927;
|
var lng = -111.6630927;
|
||||||
|
@ -48,3 +49,24 @@ walk.forEach(function (cellId, i) {
|
||||||
// ! because converting CellId / HilbertQuadkey to LatLng is not implemented... yet
|
// ! because converting CellId / HilbertQuadkey to LatLng is not implemented... yet
|
||||||
console.log(-((walk.length - 1) / 2) + i, face, cellId, S2.fromId(cellId), '!', level);
|
console.log(-((walk.length - 1) / 2) + i, face, cellId, S2.fromId(cellId), '!', level);
|
||||||
});
|
});
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
// Kyderman's test location
|
||||||
|
var lat = 51.352085106718384;
|
||||||
|
var lng = -2.9877930879592896;
|
||||||
|
var walk = getNeighbors(lat, lng, 5);
|
||||||
|
|
||||||
|
walk.forEach(function (cellId, i) {
|
||||||
|
var key = S2.fromId(cellId);
|
||||||
|
var face = parseInt(key.substr(0, 1), 10);
|
||||||
|
var pos = key.substr(2);
|
||||||
|
var level = pos.length;
|
||||||
|
|
||||||
|
// TODO
|
||||||
|
// S2.keyToLatLng(key);
|
||||||
|
// S2.idToLatLng(id);
|
||||||
|
|
||||||
|
// ! because converting CellId / HilbertQuadkey to LatLng is not implemented... yet
|
||||||
|
console.log(-((walk.length - 1) / 2) + i, face, cellId, S2.fromId(cellId), '!', level);
|
||||||
|
});
|
||||||
|
|
|
@ -5,8 +5,12 @@ var S2 = require('s2geometry-node');
|
||||||
//var lng = -111.7089464;
|
//var lng = -111.7089464;
|
||||||
|
|
||||||
// Startup Building in Provo
|
// Startup Building in Provo
|
||||||
var lat = 40.2262363;
|
//var lat = 40.2262363;
|
||||||
var lng = -111.6630927;
|
//var lng = -111.6630927;
|
||||||
|
|
||||||
|
// Kyderman's test location
|
||||||
|
var lat = 51.352085106718384;
|
||||||
|
var lng = -2.9877930879592896;
|
||||||
|
|
||||||
var s2latlng = new S2.S2LatLng(lat, lng);
|
var s2latlng = new S2.S2LatLng(lat, lng);
|
||||||
var cellId = new S2.S2CellId(s2latlng).parent(15);
|
var cellId = new S2.S2CellId(s2latlng).parent(15);
|
||||||
|
|
Loading…
Reference in New Issue