Using plainnumbers instead of BigInts for GPXids.
This commit is contained in:
parent
00ad6285d0
commit
68ebdbdbf6
|
@ -20,8 +20,8 @@ describe('The LayerStack component', () => {
|
|||
expect(svg).toMatchInlineSnapshot(`
|
||||
<svg
|
||||
data-testid="layer-stack"
|
||||
height="768"
|
||||
width="1024"
|
||||
height="100%"
|
||||
width="100%"
|
||||
>
|
||||
<g
|
||||
transform="translate(0, 0) scale(1)"
|
||||
|
@ -40,116 +40,7 @@ describe('The LayerStack component', () => {
|
|||
/>
|
||||
<g
|
||||
transform="scale(256) translate(-777, -333)"
|
||||
>
|
||||
<g
|
||||
transform="translate(777, 333)"
|
||||
>
|
||||
<image
|
||||
height="1"
|
||||
href="https://fakeurl/9/265/333.png"
|
||||
width="1"
|
||||
/>
|
||||
</g>
|
||||
<g
|
||||
transform="translate(778, 333)"
|
||||
>
|
||||
<image
|
||||
height="1"
|
||||
href="https://fakeurl/9/266/333.png"
|
||||
width="1"
|
||||
/>
|
||||
</g>
|
||||
<g
|
||||
transform="translate(779, 333)"
|
||||
>
|
||||
<image
|
||||
height="1"
|
||||
href="https://fakeurl/9/267/333.png"
|
||||
width="1"
|
||||
/>
|
||||
</g>
|
||||
<g
|
||||
transform="translate(780, 333)"
|
||||
>
|
||||
<image
|
||||
height="1"
|
||||
href="https://fakeurl/9/268/333.png"
|
||||
width="1"
|
||||
/>
|
||||
</g>
|
||||
<g
|
||||
transform="translate(777, 334)"
|
||||
>
|
||||
<image
|
||||
height="1"
|
||||
href="https://fakeurl/9/265/334.png"
|
||||
width="1"
|
||||
/>
|
||||
</g>
|
||||
<g
|
||||
transform="translate(778, 334)"
|
||||
>
|
||||
<image
|
||||
height="1"
|
||||
href="https://fakeurl/9/266/334.png"
|
||||
width="1"
|
||||
/>
|
||||
</g>
|
||||
<g
|
||||
transform="translate(779, 334)"
|
||||
>
|
||||
<image
|
||||
height="1"
|
||||
href="https://fakeurl/9/267/334.png"
|
||||
width="1"
|
||||
/>
|
||||
</g>
|
||||
<g
|
||||
transform="translate(780, 334)"
|
||||
>
|
||||
<image
|
||||
height="1"
|
||||
href="https://fakeurl/9/268/334.png"
|
||||
width="1"
|
||||
/>
|
||||
</g>
|
||||
<g
|
||||
transform="translate(777, 335)"
|
||||
>
|
||||
<image
|
||||
height="1"
|
||||
href="https://fakeurl/9/265/335.png"
|
||||
width="1"
|
||||
/>
|
||||
</g>
|
||||
<g
|
||||
transform="translate(778, 335)"
|
||||
>
|
||||
<image
|
||||
height="1"
|
||||
href="https://fakeurl/9/266/335.png"
|
||||
width="1"
|
||||
/>
|
||||
</g>
|
||||
<g
|
||||
transform="translate(779, 335)"
|
||||
>
|
||||
<image
|
||||
height="1"
|
||||
href="https://fakeurl/9/267/335.png"
|
||||
width="1"
|
||||
/>
|
||||
</g>
|
||||
<g
|
||||
transform="translate(780, 335)"
|
||||
>
|
||||
<image
|
||||
height="1"
|
||||
href="https://fakeurl/9/268/335.png"
|
||||
width="1"
|
||||
/>
|
||||
</g>
|
||||
</g>
|
||||
/>
|
||||
</g>
|
||||
</svg>
|
||||
`);
|
||||
|
@ -168,8 +59,8 @@ describe('The LayerStack component', () => {
|
|||
expect(svg).toMatchInlineSnapshot(`
|
||||
<svg
|
||||
data-testid="layer-stack"
|
||||
height="768"
|
||||
width="1024"
|
||||
height="100%"
|
||||
width="100%"
|
||||
>
|
||||
<g
|
||||
transform="translate(0, 0) scale(1)"
|
||||
|
@ -182,116 +73,7 @@ describe('The LayerStack component', () => {
|
|||
/>
|
||||
<g
|
||||
transform="scale(256) translate(-777, -333)"
|
||||
>
|
||||
<g
|
||||
transform="translate(777, 333)"
|
||||
>
|
||||
<image
|
||||
height="1"
|
||||
href="https://fakeurl/9/265/333.png"
|
||||
width="1"
|
||||
/>
|
||||
</g>
|
||||
<g
|
||||
transform="translate(778, 333)"
|
||||
>
|
||||
<image
|
||||
height="1"
|
||||
href="https://fakeurl/9/266/333.png"
|
||||
width="1"
|
||||
/>
|
||||
</g>
|
||||
<g
|
||||
transform="translate(779, 333)"
|
||||
>
|
||||
<image
|
||||
height="1"
|
||||
href="https://fakeurl/9/267/333.png"
|
||||
width="1"
|
||||
/>
|
||||
</g>
|
||||
<g
|
||||
transform="translate(780, 333)"
|
||||
>
|
||||
<image
|
||||
height="1"
|
||||
href="https://fakeurl/9/268/333.png"
|
||||
width="1"
|
||||
/>
|
||||
</g>
|
||||
<g
|
||||
transform="translate(777, 334)"
|
||||
>
|
||||
<image
|
||||
height="1"
|
||||
href="https://fakeurl/9/265/334.png"
|
||||
width="1"
|
||||
/>
|
||||
</g>
|
||||
<g
|
||||
transform="translate(778, 334)"
|
||||
>
|
||||
<image
|
||||
height="1"
|
||||
href="https://fakeurl/9/266/334.png"
|
||||
width="1"
|
||||
/>
|
||||
</g>
|
||||
<g
|
||||
transform="translate(779, 334)"
|
||||
>
|
||||
<image
|
||||
height="1"
|
||||
href="https://fakeurl/9/267/334.png"
|
||||
width="1"
|
||||
/>
|
||||
</g>
|
||||
<g
|
||||
transform="translate(780, 334)"
|
||||
>
|
||||
<image
|
||||
height="1"
|
||||
href="https://fakeurl/9/268/334.png"
|
||||
width="1"
|
||||
/>
|
||||
</g>
|
||||
<g
|
||||
transform="translate(777, 335)"
|
||||
>
|
||||
<image
|
||||
height="1"
|
||||
href="https://fakeurl/9/265/335.png"
|
||||
width="1"
|
||||
/>
|
||||
</g>
|
||||
<g
|
||||
transform="translate(778, 335)"
|
||||
>
|
||||
<image
|
||||
height="1"
|
||||
href="https://fakeurl/9/266/335.png"
|
||||
width="1"
|
||||
/>
|
||||
</g>
|
||||
<g
|
||||
transform="translate(779, 335)"
|
||||
>
|
||||
<image
|
||||
height="1"
|
||||
href="https://fakeurl/9/267/335.png"
|
||||
width="1"
|
||||
/>
|
||||
</g>
|
||||
<g
|
||||
transform="translate(780, 335)"
|
||||
>
|
||||
<image
|
||||
height="1"
|
||||
href="https://fakeurl/9/268/335.png"
|
||||
width="1"
|
||||
/>
|
||||
</g>
|
||||
</g>
|
||||
/>
|
||||
</g>
|
||||
</svg>
|
||||
`);
|
||||
|
|
|
@ -17,9 +17,9 @@ describe('The gpx module', () => {
|
|||
globalThis.Date.now = originalDateNow;
|
||||
});
|
||||
test('db.put() a new Gpx when required', async () => {
|
||||
await putNewGpx({ gpx: 0n });
|
||||
await putNewGpx({ gpx: 0 });
|
||||
expect(globalThis.db.put).toBeCalledWith({
|
||||
_id: 'gpx/00000000000000000',
|
||||
_id: 'gpx/0000000000000000',
|
||||
_rev: undefined,
|
||||
doc: {
|
||||
$: {
|
||||
|
@ -57,6 +57,6 @@ describe('The gpx module', () => {
|
|||
});
|
||||
test('db.put() generates an id if needed', async () => {
|
||||
const id = await putNewGpx();
|
||||
expect(id).toEqual({ gpx: 8640000000000000n });
|
||||
expect(id).toEqual({ gpx: 4320000000000000 });
|
||||
});
|
||||
});
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import getUri from '../lib/ids';
|
||||
import getUri, { intToGpxId } from '../lib/ids';
|
||||
import { put } from './lib';
|
||||
|
||||
const emptyGpx: Gpx = {
|
||||
|
@ -32,7 +32,7 @@ const emptyGpx: Gpx = {
|
|||
};
|
||||
|
||||
export const putNewGpx = async (
|
||||
id: IdGpx = { gpx: BigInt(Date.now()) + 8640000000000000n }
|
||||
id: IdGpx = { gpx: intToGpxId(Date.now()) }
|
||||
) => {
|
||||
const uri = getUri('gpx', id);
|
||||
await put(
|
||||
|
|
|
@ -32,17 +32,17 @@ Object {
|
|||
"offset": 0,
|
||||
"rows": Array [
|
||||
Object {
|
||||
"id": "gpx/08640000000000000",
|
||||
"key": "gpx/08640000000000000",
|
||||
"id": "gpx/4320000000000000",
|
||||
"key": "gpx/4320000000000000",
|
||||
"value": Object {
|
||||
"rev": "1-e8125b3d924c831968288bf8786e8651",
|
||||
"rev": "1-49baa096ec0c89962f2cafd3ff50b80b",
|
||||
},
|
||||
},
|
||||
Object {
|
||||
"id": "gpx/08640000000000000/2trk/000000",
|
||||
"key": "gpx/08640000000000000/2trk/000000",
|
||||
"id": "gpx/4320000000000000/2trk/000000",
|
||||
"key": "gpx/4320000000000000/2trk/000000",
|
||||
"value": Object {
|
||||
"rev": "1-a4d5a6dfa66766fd3e42c6ee328436f7",
|
||||
"rev": "1-46d2f0dcad2299e6ba2830cb1e10b234",
|
||||
},
|
||||
},
|
||||
],
|
||||
|
@ -61,8 +61,8 @@ Object {
|
|||
"rows": Array [
|
||||
Object {
|
||||
"doc": Object {
|
||||
"_id": "gpx/08640000000000000",
|
||||
"_rev": "1-e8125b3d924c831968288bf8786e8651",
|
||||
"_id": "gpx/4320000000000000",
|
||||
"_rev": "1-49baa096ec0c89962f2cafd3ff50b80b",
|
||||
"doc": Object {
|
||||
"$": Object {
|
||||
"creator": "dyomedea version 0.000002",
|
||||
|
@ -81,25 +81,25 @@ Object {
|
|||
},
|
||||
"type": "gpx",
|
||||
},
|
||||
"id": "gpx/08640000000000000",
|
||||
"key": "gpx/08640000000000000",
|
||||
"id": "gpx/4320000000000000",
|
||||
"key": "gpx/4320000000000000",
|
||||
"value": Object {
|
||||
"rev": "1-e8125b3d924c831968288bf8786e8651",
|
||||
"rev": "1-49baa096ec0c89962f2cafd3ff50b80b",
|
||||
},
|
||||
},
|
||||
Object {
|
||||
"doc": Object {
|
||||
"_id": "gpx/08640000000000000/2trk/000000",
|
||||
"_rev": "1-a4d5a6dfa66766fd3e42c6ee328436f7",
|
||||
"_id": "gpx/4320000000000000/2trk/000000",
|
||||
"_rev": "1-46d2f0dcad2299e6ba2830cb1e10b234",
|
||||
"doc": Object {
|
||||
"number": 0,
|
||||
},
|
||||
"type": "trk",
|
||||
},
|
||||
"id": "gpx/08640000000000000/2trk/000000",
|
||||
"key": "gpx/08640000000000000/2trk/000000",
|
||||
"id": "gpx/4320000000000000/2trk/000000",
|
||||
"key": "gpx/4320000000000000/2trk/000000",
|
||||
"value": Object {
|
||||
"rev": "1-a4d5a6dfa66766fd3e42c6ee328436f7",
|
||||
"rev": "1-46d2f0dcad2299e6ba2830cb1e10b234",
|
||||
},
|
||||
},
|
||||
],
|
||||
|
@ -115,24 +115,24 @@ Object {
|
|||
"offset": 0,
|
||||
"rows": Array [
|
||||
Object {
|
||||
"id": "gpx/08640000000000000",
|
||||
"key": "gpx/08640000000000000",
|
||||
"id": "gpx/4320000000000000",
|
||||
"key": "gpx/4320000000000000",
|
||||
"value": Object {
|
||||
"rev": "1-e8125b3d924c831968288bf8786e8651",
|
||||
"rev": "1-49baa096ec0c89962f2cafd3ff50b80b",
|
||||
},
|
||||
},
|
||||
Object {
|
||||
"id": "gpx/08640000000000000/2trk/000000",
|
||||
"key": "gpx/08640000000000000/2trk/000000",
|
||||
"id": "gpx/4320000000000000/2trk/000000",
|
||||
"key": "gpx/4320000000000000/2trk/000000",
|
||||
"value": Object {
|
||||
"rev": "1-a4d5a6dfa66766fd3e42c6ee328436f7",
|
||||
"rev": "1-46d2f0dcad2299e6ba2830cb1e10b234",
|
||||
},
|
||||
},
|
||||
Object {
|
||||
"id": "gpx/08640000000000000/2trk/000000/000000",
|
||||
"key": "gpx/08640000000000000/2trk/000000/000000",
|
||||
"id": "gpx/4320000000000000/2trk/000000/000000",
|
||||
"key": "gpx/4320000000000000/2trk/000000/000000",
|
||||
"value": Object {
|
||||
"rev": "1-9d45ff67006abf9bd493c0e38e3b9d2d",
|
||||
"rev": "1-9ecf6e716dbbb26576a0b13a062b8f5f",
|
||||
},
|
||||
},
|
||||
],
|
||||
|
@ -148,31 +148,31 @@ Object {
|
|||
"offset": 0,
|
||||
"rows": Array [
|
||||
Object {
|
||||
"id": "gpx/08640000000000000",
|
||||
"key": "gpx/08640000000000000",
|
||||
"id": "gpx/4320000000000000",
|
||||
"key": "gpx/4320000000000000",
|
||||
"value": Object {
|
||||
"rev": "1-e8125b3d924c831968288bf8786e8651",
|
||||
"rev": "1-49baa096ec0c89962f2cafd3ff50b80b",
|
||||
},
|
||||
},
|
||||
Object {
|
||||
"id": "gpx/08640000000000000/2trk/000000",
|
||||
"key": "gpx/08640000000000000/2trk/000000",
|
||||
"id": "gpx/4320000000000000/2trk/000000",
|
||||
"key": "gpx/4320000000000000/2trk/000000",
|
||||
"value": Object {
|
||||
"rev": "1-a4d5a6dfa66766fd3e42c6ee328436f7",
|
||||
"rev": "1-46d2f0dcad2299e6ba2830cb1e10b234",
|
||||
},
|
||||
},
|
||||
Object {
|
||||
"id": "gpx/08640000000000000/2trk/000000/000000",
|
||||
"key": "gpx/08640000000000000/2trk/000000/000000",
|
||||
"id": "gpx/4320000000000000/2trk/000000/000000",
|
||||
"key": "gpx/4320000000000000/2trk/000000/000000",
|
||||
"value": Object {
|
||||
"rev": "1-9d45ff67006abf9bd493c0e38e3b9d2d",
|
||||
"rev": "1-9ecf6e716dbbb26576a0b13a062b8f5f",
|
||||
},
|
||||
},
|
||||
Object {
|
||||
"id": "gpx/08640000000000000/2trk/000000/000000/000000",
|
||||
"key": "gpx/08640000000000000/2trk/000000/000000/000000",
|
||||
"id": "gpx/4320000000000000/2trk/000000/000000/000000",
|
||||
"key": "gpx/4320000000000000/2trk/000000/000000/000000",
|
||||
"value": Object {
|
||||
"rev": "1-8ed7435552a904ab50c836156fdde2b4",
|
||||
"rev": "1-99c4c054903f577d66ddac0384e04d06",
|
||||
},
|
||||
},
|
||||
],
|
||||
|
@ -189,17 +189,17 @@ Object {
|
|||
"offset": 0,
|
||||
"rows": Array [
|
||||
Object {
|
||||
"id": "gpx/08640000000000000",
|
||||
"key": "gpx/08640000000000000",
|
||||
"id": "gpx/4320000000000000",
|
||||
"key": "gpx/4320000000000000",
|
||||
"value": Object {
|
||||
"rev": "1-e8125b3d924c831968288bf8786e8651",
|
||||
"rev": "1-49baa096ec0c89962f2cafd3ff50b80b",
|
||||
},
|
||||
},
|
||||
Object {
|
||||
"id": "gpx/08640000000000000/0wpt/000000",
|
||||
"key": "gpx/08640000000000000/0wpt/000000",
|
||||
"id": "gpx/4320000000000000/0wpt/000000",
|
||||
"key": "gpx/4320000000000000/0wpt/000000",
|
||||
"value": Object {
|
||||
"rev": "1-5641f46ee0e0bb75493540be43e6d3b6",
|
||||
"rev": "1-a3213e8257fb142c09f8b7d7c9482dac",
|
||||
},
|
||||
},
|
||||
],
|
||||
|
@ -216,17 +216,17 @@ Object {
|
|||
"offset": 0,
|
||||
"rows": Array [
|
||||
Object {
|
||||
"id": "gpx/08640000000000000",
|
||||
"key": "gpx/08640000000000000",
|
||||
"id": "gpx/4320000000000000",
|
||||
"key": "gpx/4320000000000000",
|
||||
"value": Object {
|
||||
"rev": "1-e8125b3d924c831968288bf8786e8651",
|
||||
"rev": "1-49baa096ec0c89962f2cafd3ff50b80b",
|
||||
},
|
||||
},
|
||||
Object {
|
||||
"id": "gpx/08640000000000000/1rte/000000",
|
||||
"key": "gpx/08640000000000000/1rte/000000",
|
||||
"id": "gpx/4320000000000000/1rte/000000",
|
||||
"key": "gpx/4320000000000000/1rte/000000",
|
||||
"value": Object {
|
||||
"rev": "1-1ce2ce3ed4fdc8cd652625325fa4249e",
|
||||
"rev": "1-a683896687f08ed73ceede02dc0c210e",
|
||||
},
|
||||
},
|
||||
],
|
||||
|
@ -243,24 +243,24 @@ Object {
|
|||
"offset": 0,
|
||||
"rows": Array [
|
||||
Object {
|
||||
"id": "gpx/08640000000000000",
|
||||
"key": "gpx/08640000000000000",
|
||||
"id": "gpx/4320000000000000",
|
||||
"key": "gpx/4320000000000000",
|
||||
"value": Object {
|
||||
"rev": "1-e8125b3d924c831968288bf8786e8651",
|
||||
"rev": "1-49baa096ec0c89962f2cafd3ff50b80b",
|
||||
},
|
||||
},
|
||||
Object {
|
||||
"id": "gpx/08640000000000000/1rte/000000",
|
||||
"key": "gpx/08640000000000000/1rte/000000",
|
||||
"id": "gpx/4320000000000000/1rte/000000",
|
||||
"key": "gpx/4320000000000000/1rte/000000",
|
||||
"value": Object {
|
||||
"rev": "1-1ce2ce3ed4fdc8cd652625325fa4249e",
|
||||
"rev": "1-a683896687f08ed73ceede02dc0c210e",
|
||||
},
|
||||
},
|
||||
Object {
|
||||
"id": "gpx/08640000000000000/1rte/000000/000000",
|
||||
"key": "gpx/08640000000000000/1rte/000000/000000",
|
||||
"id": "gpx/4320000000000000/1rte/000000/000000",
|
||||
"key": "gpx/4320000000000000/1rte/000000/000000",
|
||||
"value": Object {
|
||||
"rev": "1-89cbde37e6c4a85f43e2b68c881183c0",
|
||||
"rev": "1-e2eff2ff270417d00f681fcc3f7ceafe",
|
||||
},
|
||||
},
|
||||
],
|
||||
|
|
|
@ -18,9 +18,9 @@ describe('The rte module', () => {
|
|||
globalThis.Date.now = originalDateNow;
|
||||
});
|
||||
test('db.put() a new rte when required', async () => {
|
||||
putNewRte({ gpx: 8640000000000000n, rte: 25 });
|
||||
putNewRte({ gpx: 4320000000000000, rte: 25 });
|
||||
await expect(globalThis.db.put).toBeCalledWith({
|
||||
_id: 'gpx/08640000000000000/1rte/000025',
|
||||
_id: 'gpx/4320000000000000/1rte/000025',
|
||||
_rev: undefined,
|
||||
doc: {
|
||||
cmt: undefined,
|
||||
|
@ -37,11 +37,11 @@ describe('The rte module', () => {
|
|||
});
|
||||
});
|
||||
test('db.put() generates an id for the trk if needed', async () => {
|
||||
const id = await putNewRte({ gpx: 0n });
|
||||
expect(id).toEqual({ gpx: 0n, rte: 0 });
|
||||
const id = await putNewRte({ gpx: 0 });
|
||||
expect(id).toEqual({ gpx: 0, rte: 0 });
|
||||
});
|
||||
test('db.put() generates ids for both gpx and trk if needed', async () => {
|
||||
const id = await putNewRte();
|
||||
expect(id).toEqual({ gpx: 8640000000000000n, rte: 0 });
|
||||
expect(id).toEqual({ gpx: 4320000000000000, rte: 0 });
|
||||
});
|
||||
});
|
||||
|
|
|
@ -18,9 +18,9 @@ describe('The rtept module', () => {
|
|||
globalThis.Date.now = originalDateNow;
|
||||
});
|
||||
test('db.put() a new rtept when required', async () => {
|
||||
putNewRtept({ gpx: 0n, rte: 0, rtept: 0 });
|
||||
putNewRtept({ gpx: 0, rte: 0, rtept: 0 });
|
||||
await expect(globalThis.db.put).toBeCalledWith({
|
||||
_id: 'gpx/00000000000000000/1rte/000000/000000',
|
||||
_id: 'gpx/0000000000000000/1rte/000000/000000',
|
||||
_rev: undefined,
|
||||
doc: {
|
||||
$: { lat: 0, lon: 0 },
|
||||
|
@ -48,11 +48,11 @@ describe('The rtept module', () => {
|
|||
});
|
||||
});
|
||||
test('db.put() generates an id for the rtept if needed', async () => {
|
||||
const id = await putNewRtept({ gpx: 0n });
|
||||
expect(id).toEqual({ gpx: 0n, rte: 0, rtept: 0 });
|
||||
const id = await putNewRtept({ gpx: 0 });
|
||||
expect(id).toEqual({ gpx: 0, rte: 0, rtept: 0 });
|
||||
});
|
||||
test('db.put() generates ids for both gpx and rte if needed', async () => {
|
||||
const id = await putNewRtept();
|
||||
expect(id).toEqual({ gpx: 8640000000000000n, rte: 0, rtept: 0 });
|
||||
expect(id).toEqual({ gpx: 4320000000000000, rte: 0, rtept: 0 });
|
||||
});
|
||||
});
|
||||
|
|
|
@ -18,9 +18,9 @@ describe('The trk module', () => {
|
|||
globalThis.Date.now = originalDateNow;
|
||||
});
|
||||
test('db.put() a new trk when required', async () => {
|
||||
putNewTrk({ gpx: 1n, trk: 2 });
|
||||
putNewTrk({ gpx: 1, trk: 2 });
|
||||
await expect(globalThis.db.put).toBeCalledWith({
|
||||
_id: 'gpx/00000000000000001/2trk/000002',
|
||||
_id: 'gpx/0000000000000001/2trk/000002',
|
||||
_rev: undefined,
|
||||
doc: {
|
||||
cmt: undefined,
|
||||
|
@ -37,11 +37,11 @@ describe('The trk module', () => {
|
|||
});
|
||||
});
|
||||
test('db.put() generates an id for the trk if needed', async () => {
|
||||
const id = await putNewTrk({ gpx: 2n });
|
||||
expect(id).toEqual({ gpx: 2n, trk: 0});
|
||||
const id = await putNewTrk({ gpx: 2 });
|
||||
expect(id).toEqual({ gpx: 2, trk: 0});
|
||||
});
|
||||
test('db.put() generates ids for both gpx and trk if needed', async () => {
|
||||
const id = await putNewTrk();
|
||||
expect(id).toEqual({ gpx: 8640000000000000n, trk: 0});
|
||||
expect(id).toEqual({ gpx: 4320000000000000, trk: 0});
|
||||
});
|
||||
});
|
||||
|
|
|
@ -19,13 +19,13 @@ describe('The trkpt module', () => {
|
|||
});
|
||||
test('db.put() a new trkpt when required', async () => {
|
||||
putNewTrkpt({
|
||||
gpx: 1n,
|
||||
gpx: 1,
|
||||
trk: 2,
|
||||
trkseg: 3,
|
||||
trkpt: 4,
|
||||
});
|
||||
await expect(globalThis.db.put).toBeCalledWith({
|
||||
_id: 'gpx/00000000000000001/2trk/000002/000003/000004',
|
||||
_id: 'gpx/0000000000000001/2trk/000002/000003/000004',
|
||||
_rev: undefined,
|
||||
doc: {
|
||||
$: { lat: 0, lon: 0 },
|
||||
|
@ -59,9 +59,9 @@ describe('The trkpt module', () => {
|
|||
});
|
||||
});
|
||||
test('db.put() generates an id for the trk if needed', async () => {
|
||||
const id = await putNewTrkpt({ gpx: 5n });
|
||||
const id = await putNewTrkpt({ gpx: 5 });
|
||||
expect(id).toEqual({
|
||||
gpx: 5n,
|
||||
gpx: 5,
|
||||
trk: 0,
|
||||
trkseg: 0,
|
||||
trkpt: 0,
|
||||
|
@ -70,7 +70,7 @@ describe('The trkpt module', () => {
|
|||
test('db.put() generates ids for both gpx and trk if needed', async () => {
|
||||
const id = await putNewTrkpt();
|
||||
expect(id).toEqual({
|
||||
gpx: 8640000000000000n,
|
||||
gpx: 4320000000000000,
|
||||
trk: 0,
|
||||
trkseg: 0,
|
||||
trkpt: 0,
|
||||
|
|
|
@ -18,9 +18,9 @@ describe('The trkseg module', () => {
|
|||
globalThis.Date.now = originalDateNow;
|
||||
});
|
||||
test('db.put() a new trk when required', async () => {
|
||||
putNewTrkseg({ gpx: 12345678901234567n, trk: 123456, trkseg: 5 });
|
||||
putNewTrkseg({ gpx: 1234567890123456, trk: 123456, trkseg: 5 });
|
||||
await expect(globalThis.db.put).toBeCalledWith({
|
||||
_id: 'gpx/12345678901234567/2trk/123456/000005',
|
||||
_id: 'gpx/1234567890123456/2trk/123456/000005',
|
||||
_rev: undefined,
|
||||
doc: {
|
||||
trkpt: undefined,
|
||||
|
@ -30,11 +30,11 @@ describe('The trkseg module', () => {
|
|||
});
|
||||
});
|
||||
test('db.put() generates an id for the trk if needed', async () => {
|
||||
const id = await putNewTrkseg({ gpx: 1n });
|
||||
expect(id).toEqual({ gpx: 1n, trk: 0, trkseg: 0 });
|
||||
const id = await putNewTrkseg({ gpx: 1 });
|
||||
expect(id).toEqual({ gpx: 1, trk: 0, trkseg: 0 });
|
||||
});
|
||||
test('db.put() generates ids for both gpx and trk if needed', async () => {
|
||||
const id = await putNewTrkseg();
|
||||
expect(id).toEqual({ gpx: 8640000000000000n, trk: 0, trkseg: 0 });
|
||||
expect(id).toEqual({ gpx: 4320000000000000, trk: 0, trkseg: 0 });
|
||||
});
|
||||
});
|
||||
|
|
|
@ -18,9 +18,9 @@ describe('The wpt module', () => {
|
|||
globalThis.Date.now = originalDateNow;
|
||||
});
|
||||
test('db.put() a new wpt when required', async () => {
|
||||
putNewWpt({ gpx: 1n, wpt: 2 });
|
||||
putNewWpt({ gpx: 1, wpt: 2 });
|
||||
await expect(globalThis.db.put).toBeCalledWith({
|
||||
_id: 'gpx/00000000000000001/0wpt/000002',
|
||||
_id: 'gpx/0000000000000001/0wpt/000002',
|
||||
_rev: undefined,
|
||||
doc: {
|
||||
$: { lat: 0, lon: 0 },
|
||||
|
@ -48,11 +48,11 @@ describe('The wpt module', () => {
|
|||
});
|
||||
});
|
||||
test('db.put() generates an id for the wpt if needed', async () => {
|
||||
const id = await putNewWpt({ gpx: 1n });
|
||||
expect(id).toEqual({ gpx: 1n, wpt: 0 });
|
||||
const id = await putNewWpt({ gpx: 1 });
|
||||
expect(id).toEqual({ gpx: 1, wpt: 0 });
|
||||
});
|
||||
test('db.put() generates ids for both gpx and trk if needed', async () => {
|
||||
const id = await putNewWpt();
|
||||
expect(id).toEqual({ gpx: 8640000000000000n, wpt: 0 });
|
||||
expect(id).toEqual({ gpx: 4320000000000000, wpt: 0 });
|
||||
});
|
||||
});
|
||||
|
|
|
@ -44,9 +44,9 @@ describe('Checking a multilevel route with optional part', () => {
|
|||
|
||||
describe('Checking gpx ids', () => {
|
||||
const id = {
|
||||
gpx: 12345678901234567n,
|
||||
gpx: 1234567890123456,
|
||||
};
|
||||
const key = 'gpx/12345678901234567';
|
||||
const key = 'gpx/1234567890123456';
|
||||
test(', vice', () => {
|
||||
const gpx = uri('gpx', id);
|
||||
expect(gpx).toBe(key);
|
||||
|
@ -59,10 +59,10 @@ describe('Checking gpx ids', () => {
|
|||
|
||||
describe('Checking trk ids', () => {
|
||||
const id = {
|
||||
gpx: 12345678901234567n,
|
||||
gpx: 1234567890123456,
|
||||
trk: 123456,
|
||||
};
|
||||
const key = 'gpx/12345678901234567/2trk/123456';
|
||||
const key = 'gpx/1234567890123456/2trk/123456';
|
||||
test(', vice', () => {
|
||||
const rte = uri('trk', id);
|
||||
expect(rte).toBe(key);
|
||||
|
@ -75,11 +75,11 @@ describe('Checking trk ids', () => {
|
|||
|
||||
describe('Checking trkseg ids', () => {
|
||||
const id = {
|
||||
gpx: 111n,
|
||||
gpx: 111,
|
||||
trk: 0,
|
||||
trkseg: 3,
|
||||
};
|
||||
const key = 'gpx/00000000000000111/2trk/000000/000003';
|
||||
const key = 'gpx/0000000000000111/2trk/000000/000003';
|
||||
test(', vice', () => {
|
||||
const rte = uri('trkseg', id);
|
||||
expect(rte).toBe(key);
|
||||
|
@ -92,12 +92,12 @@ describe('Checking trkseg ids', () => {
|
|||
|
||||
describe('Checking trkpt ids', () => {
|
||||
const id = {
|
||||
gpx: 25n,
|
||||
gpx: 25,
|
||||
trk: 8,
|
||||
trkseg: 0,
|
||||
trkpt: 155,
|
||||
};
|
||||
const key = 'gpx/00000000000000025/2trk/000008/000000/000155';
|
||||
const key = 'gpx/0000000000000025/2trk/000008/000000/000155';
|
||||
test(', vice', () => {
|
||||
const rte = uri('trkpt', id);
|
||||
expect(rte).toBe(key);
|
||||
|
|
|
@ -15,7 +15,7 @@ const bigIntType = (n: number) => {
|
|||
};
|
||||
|
||||
const coding = {
|
||||
gpx: bigIntType(17),
|
||||
gpx: integerType(16),
|
||||
wpt: integerType(6),
|
||||
rte: integerType(6),
|
||||
rtept: integerType(6),
|
||||
|
@ -43,3 +43,8 @@ const uri = (type: RouteKey, param: any) => {
|
|||
};
|
||||
|
||||
export default uri;
|
||||
|
||||
const minDate = -8640000000000000;
|
||||
const halfMinDate = minDate / 2;
|
||||
|
||||
export const intToGpxId = (i: number) => Math.round(i / 2) - halfMinDate;
|
||||
|
|
|
@ -1,34 +1,34 @@
|
|||
interface IdGpx {
|
||||
gpx: BigInt;
|
||||
gpx: number;
|
||||
}
|
||||
|
||||
interface IdTrk {
|
||||
gpx: BigInt;
|
||||
gpx: number;
|
||||
trk: number;
|
||||
}
|
||||
interface IdTrkseg {
|
||||
gpx: BigInt;
|
||||
gpx: number;
|
||||
trk: number;
|
||||
trkseg: number;
|
||||
}
|
||||
interface IdTrkpt {
|
||||
gpx: BigInt;
|
||||
gpx: number;
|
||||
trk: number;
|
||||
trkseg: number;
|
||||
trkpt: number;
|
||||
}
|
||||
interface IdWpt {
|
||||
gpx: BigInt;
|
||||
gpx: number;
|
||||
wpt: number;
|
||||
}
|
||||
|
||||
interface IdRte {
|
||||
gpx: BigInt;
|
||||
gpx: number;
|
||||
rte: number;
|
||||
}
|
||||
|
||||
interface IdRtept {
|
||||
gpx: BigInt;
|
||||
gpx: number;
|
||||
rte: number;
|
||||
rtept: number;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue