mirror of
https://github.com/protomaps/PMTiles.git
synced 2026-02-04 10:51:07 +00:00
* make use of ===, if branches, let/const, string templates, var names consistent style.
This commit is contained in:
@@ -14,22 +14,22 @@ import {
|
||||
test("stub data", () => {
|
||||
const dataview = new DataView(
|
||||
createDirectory([
|
||||
{ z: 5, x: 1000, y: 2000, offset: 1000, length: 2000, is_dir: false },
|
||||
{ z: 5, x: 1000, y: 2000, offset: 1000, length: 2000, isDir: false },
|
||||
{
|
||||
z: 14,
|
||||
x: 16383,
|
||||
y: 16383,
|
||||
offset: 999999,
|
||||
length: 999,
|
||||
is_dir: false,
|
||||
isDir: false,
|
||||
},
|
||||
])
|
||||
);
|
||||
var zRaw = dataview.getUint8(17 + 0);
|
||||
var x = getUint24(dataview, 17 + 1);
|
||||
var y = getUint24(dataview, 17 + 4);
|
||||
var offset = getUint48(dataview, 17 + 7);
|
||||
var length = dataview.getUint32(17 + 13, true);
|
||||
const zRaw = dataview.getUint8(17 + 0);
|
||||
const x = getUint24(dataview, 17 + 1);
|
||||
const y = getUint24(dataview, 17 + 4);
|
||||
const offset = getUint48(dataview, 17 + 7);
|
||||
const length = dataview.getUint32(17 + 13, true);
|
||||
assert.strictEqual(zRaw, 14);
|
||||
assert.strictEqual(x, 16383);
|
||||
assert.strictEqual(y, 16383);
|
||||
@@ -38,24 +38,24 @@ test("stub data", () => {
|
||||
test("get entry", () => {
|
||||
const view = new DataView(
|
||||
createDirectory([
|
||||
{ z: 5, x: 1000, y: 2000, offset: 1000, length: 2000, is_dir: false },
|
||||
{ z: 5, x: 1000, y: 2000, offset: 1000, length: 2000, isDir: false },
|
||||
{
|
||||
z: 14,
|
||||
x: 16383,
|
||||
y: 16383,
|
||||
offset: 999999,
|
||||
length: 999,
|
||||
is_dir: false,
|
||||
isDir: false,
|
||||
},
|
||||
])
|
||||
);
|
||||
const entry = queryTile(view, 14, 16383, 16383);
|
||||
assert.strictEqual(entry!.z, 14);
|
||||
assert.strictEqual(entry!.x, 16383);
|
||||
assert.strictEqual(entry!.y, 16383);
|
||||
assert.strictEqual(entry!.offset, 999999);
|
||||
assert.strictEqual(entry!.length, 999);
|
||||
assert.strictEqual(entry!.is_dir, false);
|
||||
assert.strictEqual(entry?.z, 14);
|
||||
assert.strictEqual(entry?.x, 16383);
|
||||
assert.strictEqual(entry?.y, 16383);
|
||||
assert.strictEqual(entry?.offset, 999999);
|
||||
assert.strictEqual(entry?.length, 999);
|
||||
assert.strictEqual(entry?.isDir, false);
|
||||
assert.strictEqual(queryLeafdir(view, 14, 16383, 16383), null);
|
||||
});
|
||||
|
||||
@@ -68,17 +68,17 @@ test("get leafdir", () => {
|
||||
y: 16383,
|
||||
offset: 999999,
|
||||
length: 999,
|
||||
is_dir: true,
|
||||
isDir: true,
|
||||
},
|
||||
])
|
||||
);
|
||||
const entry = queryLeafdir(view, 14, 16383, 16383);
|
||||
assert.strictEqual(entry!.z, 14);
|
||||
assert.strictEqual(entry!.x, 16383);
|
||||
assert.strictEqual(entry!.y, 16383);
|
||||
assert.strictEqual(entry!.offset, 999999);
|
||||
assert.strictEqual(entry!.length, 999);
|
||||
assert.strictEqual(entry!.is_dir, true);
|
||||
assert.strictEqual(entry?.z, 14);
|
||||
assert.strictEqual(entry?.x, 16383);
|
||||
assert.strictEqual(entry?.y, 16383);
|
||||
assert.strictEqual(entry?.offset, 999999);
|
||||
assert.strictEqual(entry?.length, 999);
|
||||
assert.strictEqual(entry?.isDir, true);
|
||||
assert.strictEqual(queryTile(view, 14, 16383, 16383), null);
|
||||
});
|
||||
|
||||
@@ -91,14 +91,14 @@ test("derive the leaf level", () => {
|
||||
y: 3,
|
||||
offset: 0,
|
||||
length: 0,
|
||||
is_dir: true,
|
||||
isDir: true,
|
||||
},
|
||||
])
|
||||
);
|
||||
let leaf = deriveLeaf(view, { z: 7, x: 6, y: 6 });
|
||||
assert.strictEqual(leaf!.z, 6);
|
||||
assert.strictEqual(leaf!.x, 3);
|
||||
assert.strictEqual(leaf!.y, 3);
|
||||
assert.strictEqual(leaf?.z, 6);
|
||||
assert.strictEqual(leaf?.x, 3);
|
||||
assert.strictEqual(leaf?.y, 3);
|
||||
view = new DataView(
|
||||
createDirectory([
|
||||
{
|
||||
@@ -107,7 +107,7 @@ test("derive the leaf level", () => {
|
||||
y: 3,
|
||||
offset: 0,
|
||||
length: 0,
|
||||
is_dir: false,
|
||||
isDir: false,
|
||||
},
|
||||
])
|
||||
);
|
||||
@@ -124,7 +124,7 @@ test("convert spec v1 directory to spec v2 directory", () => {
|
||||
y: 3,
|
||||
offset: 3,
|
||||
length: 3,
|
||||
is_dir: true,
|
||||
isDir: true,
|
||||
},
|
||||
{
|
||||
z: 6,
|
||||
@@ -132,7 +132,7 @@ test("convert spec v1 directory to spec v2 directory", () => {
|
||||
y: 2,
|
||||
offset: 2,
|
||||
length: 2,
|
||||
is_dir: false,
|
||||
isDir: false,
|
||||
},
|
||||
{
|
||||
z: 6,
|
||||
@@ -140,21 +140,21 @@ test("convert spec v1 directory to spec v2 directory", () => {
|
||||
y: 1,
|
||||
offset: 1,
|
||||
length: 1,
|
||||
is_dir: false,
|
||||
isDir: false,
|
||||
},
|
||||
])
|
||||
);
|
||||
let entry = queryLeafdir(view, 7, 3, 3);
|
||||
assert.strictEqual(entry!.offset, 3);
|
||||
assert.strictEqual(entry?.offset, 3);
|
||||
entry = queryTile(view, 6, 2, 2);
|
||||
assert.strictEqual(entry!.offset, 2);
|
||||
assert.strictEqual(entry?.offset, 2);
|
||||
entry = queryTile(view, 6, 2, 1);
|
||||
assert.strictEqual(entry!.offset, 1);
|
||||
assert.strictEqual(entry?.offset, 1);
|
||||
|
||||
entry = parseEntry(view, 0);
|
||||
assert.strictEqual(entry!.offset, 1);
|
||||
assert.strictEqual(entry?.offset, 1);
|
||||
entry = parseEntry(view, 1);
|
||||
assert.strictEqual(entry!.offset, 2);
|
||||
assert.strictEqual(entry?.offset, 2);
|
||||
entry = parseEntry(view, 2);
|
||||
assert.strictEqual(entry!.offset, 3);
|
||||
assert.strictEqual(entry?.offset, 3);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user