Using plainnumbers instead of BigInts for GPXids.

This commit is contained in:
vdv committed 2022-11-14 11:39:37 +01:00
1 parent 00ad6285d0
commit 68ebdbdbf6
13 files changed
+120 -333

No files matched your search

+8 -8
View File
@@ -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);
+6 -1
View File
@@ -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;
+7 -7
View File
@@ -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;
}