@maplibre/mlt 1.1.10 → 1.1.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -5,6 +5,48 @@ import { PhysicalStreamType } from "./physicalStreamType";
|
|
|
5
5
|
import { DictionaryType } from "./dictionaryType";
|
|
6
6
|
import { OffsetType } from "./offsetType";
|
|
7
7
|
import { LengthType } from "./lengthType";
|
|
8
|
+
const PHYSICAL_STREAM_TYPE_BY_ID = [
|
|
9
|
+
PhysicalStreamType.PRESENT,
|
|
10
|
+
PhysicalStreamType.DATA,
|
|
11
|
+
PhysicalStreamType.OFFSET,
|
|
12
|
+
PhysicalStreamType.LENGTH,
|
|
13
|
+
];
|
|
14
|
+
const LOGICAL_LEVEL_TECHNIQUE_BY_ID = [
|
|
15
|
+
LogicalLevelTechnique.NONE,
|
|
16
|
+
LogicalLevelTechnique.DELTA,
|
|
17
|
+
LogicalLevelTechnique.COMPONENTWISE_DELTA,
|
|
18
|
+
LogicalLevelTechnique.RLE,
|
|
19
|
+
LogicalLevelTechnique.MORTON,
|
|
20
|
+
LogicalLevelTechnique.PDE,
|
|
21
|
+
];
|
|
22
|
+
const PHYSICAL_LEVEL_TECHNIQUE_BY_ID = [
|
|
23
|
+
PhysicalLevelTechnique.NONE,
|
|
24
|
+
PhysicalLevelTechnique.FAST_PFOR,
|
|
25
|
+
PhysicalLevelTechnique.VARINT,
|
|
26
|
+
];
|
|
27
|
+
const DICTIONARY_TYPE_BY_ID = [
|
|
28
|
+
DictionaryType.NONE,
|
|
29
|
+
DictionaryType.SINGLE,
|
|
30
|
+
DictionaryType.SHARED,
|
|
31
|
+
DictionaryType.VERTEX,
|
|
32
|
+
DictionaryType.MORTON,
|
|
33
|
+
DictionaryType.FSST,
|
|
34
|
+
];
|
|
35
|
+
const OFFSET_TYPE_BY_ID = [
|
|
36
|
+
OffsetType.VERTEX,
|
|
37
|
+
OffsetType.INDEX,
|
|
38
|
+
OffsetType.STRING,
|
|
39
|
+
OffsetType.KEY,
|
|
40
|
+
];
|
|
41
|
+
const LENGTH_TYPE_BY_ID = [
|
|
42
|
+
LengthType.VAR_BINARY,
|
|
43
|
+
LengthType.GEOMETRIES,
|
|
44
|
+
LengthType.PARTS,
|
|
45
|
+
LengthType.RINGS,
|
|
46
|
+
LengthType.TRIANGLES,
|
|
47
|
+
LengthType.SYMBOL,
|
|
48
|
+
LengthType.DICTIONARY,
|
|
49
|
+
];
|
|
8
50
|
export function decodeStreamMetadata(tile, offset) {
|
|
9
51
|
const streamMetadata = decodeStreamMetadataInternal(tile, offset);
|
|
10
52
|
if (streamMetadata.logicalLevelTechnique1 === LogicalLevelTechnique.MORTON) {
|
|
@@ -49,30 +91,30 @@ function decodePartialRleEncodedStreamMetadata(streamMetadata, tile, offset) {
|
|
|
49
91
|
}
|
|
50
92
|
function decodeStreamMetadataInternal(tile, offset) {
|
|
51
93
|
const stream_type = tile[offset.get()];
|
|
52
|
-
const physicalStreamType =
|
|
53
|
-
let logicalStreamType =
|
|
94
|
+
const physicalStreamType = PHYSICAL_STREAM_TYPE_BY_ID[stream_type >> 4];
|
|
95
|
+
let logicalStreamType = {};
|
|
54
96
|
switch (physicalStreamType) {
|
|
55
97
|
case PhysicalStreamType.DATA:
|
|
56
98
|
logicalStreamType = {
|
|
57
|
-
dictionaryType:
|
|
99
|
+
dictionaryType: DICTIONARY_TYPE_BY_ID[stream_type & 0xf],
|
|
58
100
|
};
|
|
59
101
|
break;
|
|
60
102
|
case PhysicalStreamType.OFFSET:
|
|
61
103
|
logicalStreamType = {
|
|
62
|
-
offsetType:
|
|
104
|
+
offsetType: OFFSET_TYPE_BY_ID[stream_type & 0xf],
|
|
63
105
|
};
|
|
64
106
|
break;
|
|
65
107
|
case PhysicalStreamType.LENGTH:
|
|
66
108
|
logicalStreamType = {
|
|
67
|
-
lengthType:
|
|
109
|
+
lengthType: LENGTH_TYPE_BY_ID[stream_type & 0xf],
|
|
68
110
|
};
|
|
69
111
|
break;
|
|
70
112
|
}
|
|
71
113
|
offset.increment();
|
|
72
114
|
const encodings_header = tile[offset.get()];
|
|
73
|
-
const llt1 =
|
|
74
|
-
const llt2 =
|
|
75
|
-
const plt =
|
|
115
|
+
const llt1 = LOGICAL_LEVEL_TECHNIQUE_BY_ID[encodings_header >> 5];
|
|
116
|
+
const llt2 = LOGICAL_LEVEL_TECHNIQUE_BY_ID[(encodings_header >> 2) & 0x7];
|
|
117
|
+
const plt = PHYSICAL_LEVEL_TECHNIQUE_BY_ID[encodings_header & 0x3];
|
|
76
118
|
offset.increment();
|
|
77
119
|
const sizeInfo = decodeVarintInt32(tile, offset, 2);
|
|
78
120
|
const numValues = sizeInfo[0];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"streamMetadataDecoder.js","sourceRoot":"","sources":["../../../src/metadata/tile/streamMetadataDecoder.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAAqB,EAAE,MAAM,yBAAyB,CAAC;AAChE,OAAO,EAAE,sBAAsB,EAAE,MAAM,0BAA0B,CAAC;AAClE,OAAO,EAAE,iBAAiB,EAAE,MAAM,qCAAqC,CAAC;AACxE,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAC1D,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AA8B1C,MAAM,UAAU,oBAAoB,CAAC,IAAgB,EAAE,MAAkB;IACrE,MAAM,cAAc,GAAG,4BAA4B,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;IAClE,IAAI,cAAc,CAAC,sBAAsB,KAAK,qBAAqB,CAAC,MAAM,EAAE,CAAC;QACzE,OAAO,wCAAwC,CAAC,cAAc,EAAE,IAAI,EAAE,MAAM,CAAC,CAAC;IAClF,CAAC;IAED,IACI,CAAC,qBAAqB,CAAC,GAAG,KAAK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M,CAAC,MAAM,CAAC,qBAAqB,CAAC,CAAC,CAAC,gBAAgB,IAAI,CAAC,CAAC,GAAG,GAAG,CAA0B,CAAC;IAC1G,MAAM,GAAG,GAAG,MAAM,CAAC,MAAM,CAAC,sBAAsB,CAAC,CAAC,gBAAgB,GAAG,GAAG,CAA2B,CAAC;IACpG,MAAM,CAAC,SAAS,EAAE,CAAC;IAEnB,MAAM,QAAQ,GAAG,iBAAiB,CAAC,IAAI,EAAE,MAAM,EAAE,CAAC,CAAC,CAAC;IACpD,MAAM,SAAS,GAAG,QAAQ,CAAC,CAAC,CAAC,CAAC;IAC9B,MAAM,UAAU,GAAG,QAAQ,CAAC,CAAC,CAAC,CAAC;IAE/B,OAAO;QACH,kBAAkB;QAClB,iBAAiB;QACjB,sBAAsB,EAAE,IAAI;QAC5B,sBAAsB,EAAE,IAAI;QAC5B,sBAAsB,EAAE,GAAG;QAC3B,SAAS;QACT,UAAU;QACV,iBAAiB,EAAE,SAAS;KAC/B,CAAC;AACN,CAAC","sourcesContent":["import { LogicalLevelTechnique } from \"./logicalLevelTechnique\";\nimport { PhysicalLevelTechnique } from \"./physicalLevelTechnique\";\nimport { decodeVarintInt32 } from \"../../decoding/integerDecodingUtils\";\nimport { PhysicalStreamType } from \"./physicalStreamType\";\nimport { DictionaryType } from \"./dictionaryType\";\nimport { OffsetType } from \"./offsetType\";\nimport { LengthType } from \"./lengthType\";\nimport type { LogicalStreamType } from \"./logicalStreamType\";\nimport type IntWrapper from \"../../decoding/intWrapper\";\n\nexport type StreamMetadata = {\n readonly physicalStreamType: PhysicalStreamType;\n readonly logicalStreamType: LogicalStreamType;\n readonly logicalLevelTechnique1: LogicalLevelTechnique;\n readonly logicalLevelTechnique2: LogicalLevelTechnique;\n readonly physicalLevelTechnique: PhysicalLevelTechnique;\n readonly numValues: number;\n readonly byteLength: number;\n /**\n * Returns the number of decompressed values.\n * For non-RLE streams, this is the same as numValues.\n * For RLE streams, this is overridden to return numRleValues.\n */\n readonly decompressedCount: number;\n};\n\nexport type MortonEncodedStreamMetadata = StreamMetadata & {\n readonly numBits: number;\n readonly coordinateShift: number;\n};\n\nexport type RleEncodedStreamMetadata = StreamMetadata & {\n readonly runs: number;\n readonly numRleValues: number;\n};\n\nexport function decodeStreamMetadata(tile: Uint8Array, offset: IntWrapper): StreamMetadata {\n const streamMetadata = decodeStreamMetadataInternal(tile, offset);\n if (streamMetadata.logicalLevelTechnique1 === LogicalLevelTechnique.MORTON) {\n return decodePartialMortonEncodedStreamMetadata(streamMetadata, tile, offset);\n }\n\n if (\n (LogicalLevelTechnique.RLE === streamMetadata.logicalLevelTechnique1 ||\n LogicalLevelTechnique.RLE === streamMetadata.logicalLevelTechnique2) &&\n PhysicalLevelTechnique.NONE !== streamMetadata.physicalLevelTechnique\n ) {\n return decodePartialRleEncodedStreamMetadata(streamMetadata, tile, offset);\n }\n\n return streamMetadata;\n}\n\nfunction decodePartialMortonEncodedStreamMetadata(\n streamMetadata: StreamMetadata,\n tile: Uint8Array,\n offset: IntWrapper,\n): MortonEncodedStreamMetadata {\n const mortonInfo = decodeVarintInt32(tile, offset, 2);\n return {\n physicalStreamType: streamMetadata.physicalStreamType,\n logicalStreamType: streamMetadata.logicalStreamType,\n logicalLevelTechnique1: streamMetadata.logicalLevelTechnique1,\n logicalLevelTechnique2: streamMetadata.logicalLevelTechnique2,\n physicalLevelTechnique: streamMetadata.physicalLevelTechnique,\n numValues: streamMetadata.numValues,\n byteLength: streamMetadata.byteLength,\n decompressedCount: streamMetadata.decompressedCount,\n numBits: mortonInfo[0],\n coordinateShift: mortonInfo[1],\n };\n}\n\nfunction decodePartialRleEncodedStreamMetadata(\n streamMetadata: StreamMetadata,\n tile: Uint8Array,\n offset: IntWrapper,\n): RleEncodedStreamMetadata {\n const rleInfo = decodeVarintInt32(tile, offset, 2);\n return {\n physicalStreamType: streamMetadata.physicalStreamType,\n logicalStreamType: streamMetadata.logicalStreamType,\n logicalLevelTechnique1: streamMetadata.logicalLevelTechnique1,\n logicalLevelTechnique2: streamMetadata.logicalLevelTechnique2,\n physicalLevelTechnique: streamMetadata.physicalLevelTechnique,\n numValues: streamMetadata.numValues,\n byteLength: streamMetadata.byteLength,\n decompressedCount: rleInfo[1],\n runs: rleInfo[0],\n numRleValues: rleInfo[1],\n };\n}\n\nfunction decodeStreamMetadataInternal(tile: Uint8Array, offset: IntWrapper): StreamMetadata {\n const stream_type = tile[offset.get()];\n const physicalStreamType = Object.values(PhysicalStreamType)[stream_type >> 4] as PhysicalStreamType;\n let logicalStreamType: LogicalStreamType | null = null;\n\n switch (physicalStreamType) {\n case PhysicalStreamType.DATA:\n logicalStreamType = {\n dictionaryType: Object.values(DictionaryType)[stream_type & 0xf],\n };\n break;\n case PhysicalStreamType.OFFSET:\n logicalStreamType = {\n offsetType: Object.values(OffsetType)[stream_type & 0xf],\n };\n break;\n case PhysicalStreamType.LENGTH:\n logicalStreamType = {\n lengthType: Object.values(LengthType)[stream_type & 0xf],\n };\n break;\n }\n offset.increment();\n\n const encodings_header = tile[offset.get()];\n const llt1 = Object.values(LogicalLevelTechnique)[encodings_header >> 5] as LogicalLevelTechnique;\n const llt2 = Object.values(LogicalLevelTechnique)[(encodings_header >> 2) & 0x7] as LogicalLevelTechnique;\n const plt = Object.values(PhysicalLevelTechnique)[encodings_header & 0x3] as PhysicalLevelTechnique;\n offset.increment();\n\n const sizeInfo = decodeVarintInt32(tile, offset, 2);\n const numValues = sizeInfo[0];\n const byteLength = sizeInfo[1];\n\n return {\n physicalStreamType,\n logicalStreamType,\n logicalLevelTechnique1: llt1,\n logicalLevelTechnique2: llt2,\n physicalLevelTechnique: plt,\n numValues,\n byteLength,\n decompressedCount: numValues,\n };\n}\n"]}
|
|
1
|
+
{"version":3,"file":"streamMetadataDecoder.js","sourceRoot":"","sources":["../../../src/metadata/tile/streamMetadataDecoder.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAAqB,EAAE,MAAM,yBAAyB,CAAC;AAChE,OAAO,EAAE,sBAA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,MAAM;IACd,CAAC;IACD,MAAM,CAAC,SAAS,EAAE,CAAC;IAEnB,MAAM,gBAAgB,GAAG,IAAI,CAAC,MAAM,CAAC,GAAG,EAAE,CAAC,CAAC;IAC5C,MAAM,IAAI,GAAG,6BAA6B,CAAC,gBAAgB,IAAI,CAAC,CAAC,CAAC;IAClE,MAAM,IAAI,GAAG,6BAA6B,CAAC,CAAC,gBAAgB,IAAI,CAAC,CAAC,GAAG,GAAG,CAAC,CAAC;IAC1E,MAAM,GAAG,GAAG,8BAA8B,CAAC,gBAAgB,GAAG,GAAG,CAAC,CAAC;IACnE,MAAM,CAAC,SAAS,EAAE,CAAC;IAEnB,MAAM,QAAQ,GAAG,iBAAiB,CAAC,IAAI,EAAE,MAAM,EAAE,CAAC,CAAC,CAAC;IACpD,MAAM,SAAS,GAAG,QAAQ,CAAC,CAAC,CAAC,CAAC;IAC9B,MAAM,UAAU,GAAG,QAAQ,CAAC,CAAC,CAAC,CAAC;IAE/B,OAAO;QACH,kBAAkB;QAClB,iBAAiB;QACjB,sBAAsB,EAAE,IAAI;QAC5B,sBAAsB,EAAE,IAAI;QAC5B,sBAAsB,EAAE,GAAG;QAC3B,SAAS;QACT,UAAU;QACV,iBAAiB,EAAE,SAAS;KAC/B,CAAC;AACN,CAAC","sourcesContent":["import { LogicalLevelTechnique } from \"./logicalLevelTechnique\";\nimport { PhysicalLevelTechnique } from \"./physicalLevelTechnique\";\nimport { decodeVarintInt32 } from \"../../decoding/integerDecodingUtils\";\nimport { PhysicalStreamType } from \"./physicalStreamType\";\nimport { DictionaryType } from \"./dictionaryType\";\nimport { OffsetType } from \"./offsetType\";\nimport { LengthType } from \"./lengthType\";\nimport type { LogicalStreamType } from \"./logicalStreamType\";\nimport type IntWrapper from \"../../decoding/intWrapper\";\n\nexport type StreamMetadata = {\n readonly physicalStreamType: PhysicalStreamType;\n readonly logicalStreamType: LogicalStreamType;\n readonly logicalLevelTechnique1: LogicalLevelTechnique;\n readonly logicalLevelTechnique2: LogicalLevelTechnique;\n readonly physicalLevelTechnique: PhysicalLevelTechnique;\n readonly numValues: number;\n readonly byteLength: number;\n /**\n * Returns the number of decompressed values.\n * For non-RLE streams, this is the same as numValues.\n * For RLE streams, this is overridden to return numRleValues.\n */\n readonly decompressedCount: number;\n};\n\nexport type MortonEncodedStreamMetadata = StreamMetadata & {\n readonly numBits: number;\n readonly coordinateShift: number;\n};\n\nexport type RleEncodedStreamMetadata = StreamMetadata & {\n readonly runs: number;\n readonly numRleValues: number;\n};\n\nconst PHYSICAL_STREAM_TYPE_BY_ID: readonly PhysicalStreamType[] = [\n PhysicalStreamType.PRESENT,\n PhysicalStreamType.DATA,\n PhysicalStreamType.OFFSET,\n PhysicalStreamType.LENGTH,\n];\n\nconst LOGICAL_LEVEL_TECHNIQUE_BY_ID: readonly LogicalLevelTechnique[] = [\n LogicalLevelTechnique.NONE,\n LogicalLevelTechnique.DELTA,\n LogicalLevelTechnique.COMPONENTWISE_DELTA,\n LogicalLevelTechnique.RLE,\n LogicalLevelTechnique.MORTON,\n LogicalLevelTechnique.PDE,\n];\n\nconst PHYSICAL_LEVEL_TECHNIQUE_BY_ID: readonly PhysicalLevelTechnique[] = [\n PhysicalLevelTechnique.NONE,\n PhysicalLevelTechnique.FAST_PFOR,\n PhysicalLevelTechnique.VARINT,\n];\n\nconst DICTIONARY_TYPE_BY_ID: readonly DictionaryType[] = [\n DictionaryType.NONE,\n DictionaryType.SINGLE,\n DictionaryType.SHARED,\n DictionaryType.VERTEX,\n DictionaryType.MORTON,\n DictionaryType.FSST,\n];\n\nconst OFFSET_TYPE_BY_ID: readonly OffsetType[] = [\n OffsetType.VERTEX,\n OffsetType.INDEX,\n OffsetType.STRING,\n OffsetType.KEY,\n];\n\nconst LENGTH_TYPE_BY_ID: readonly LengthType[] = [\n LengthType.VAR_BINARY,\n LengthType.GEOMETRIES,\n LengthType.PARTS,\n LengthType.RINGS,\n LengthType.TRIANGLES,\n LengthType.SYMBOL,\n LengthType.DICTIONARY,\n];\n\nexport function decodeStreamMetadata(tile: Uint8Array, offset: IntWrapper): StreamMetadata {\n const streamMetadata = decodeStreamMetadataInternal(tile, offset);\n if (streamMetadata.logicalLevelTechnique1 === LogicalLevelTechnique.MORTON) {\n return decodePartialMortonEncodedStreamMetadata(streamMetadata, tile, offset);\n }\n\n if (\n (LogicalLevelTechnique.RLE === streamMetadata.logicalLevelTechnique1 ||\n LogicalLevelTechnique.RLE === streamMetadata.logicalLevelTechnique2) &&\n PhysicalLevelTechnique.NONE !== streamMetadata.physicalLevelTechnique\n ) {\n return decodePartialRleEncodedStreamMetadata(streamMetadata, tile, offset);\n }\n\n return streamMetadata;\n}\n\nfunction decodePartialMortonEncodedStreamMetadata(\n streamMetadata: StreamMetadata,\n tile: Uint8Array,\n offset: IntWrapper,\n): MortonEncodedStreamMetadata {\n const mortonInfo = decodeVarintInt32(tile, offset, 2);\n return {\n physicalStreamType: streamMetadata.physicalStreamType,\n logicalStreamType: streamMetadata.logicalStreamType,\n logicalLevelTechnique1: streamMetadata.logicalLevelTechnique1,\n logicalLevelTechnique2: streamMetadata.logicalLevelTechnique2,\n physicalLevelTechnique: streamMetadata.physicalLevelTechnique,\n numValues: streamMetadata.numValues,\n byteLength: streamMetadata.byteLength,\n decompressedCount: streamMetadata.decompressedCount,\n numBits: mortonInfo[0],\n coordinateShift: mortonInfo[1],\n };\n}\n\nfunction decodePartialRleEncodedStreamMetadata(\n streamMetadata: StreamMetadata,\n tile: Uint8Array,\n offset: IntWrapper,\n): RleEncodedStreamMetadata {\n const rleInfo = decodeVarintInt32(tile, offset, 2);\n return {\n physicalStreamType: streamMetadata.physicalStreamType,\n logicalStreamType: streamMetadata.logicalStreamType,\n logicalLevelTechnique1: streamMetadata.logicalLevelTechnique1,\n logicalLevelTechnique2: streamMetadata.logicalLevelTechnique2,\n physicalLevelTechnique: streamMetadata.physicalLevelTechnique,\n numValues: streamMetadata.numValues,\n byteLength: streamMetadata.byteLength,\n decompressedCount: rleInfo[1],\n runs: rleInfo[0],\n numRleValues: rleInfo[1],\n };\n}\n\nfunction decodeStreamMetadataInternal(tile: Uint8Array, offset: IntWrapper): StreamMetadata {\n const stream_type = tile[offset.get()];\n const physicalStreamType = PHYSICAL_STREAM_TYPE_BY_ID[stream_type >> 4];\n let logicalStreamType: LogicalStreamType = {};\n\n switch (physicalStreamType) {\n case PhysicalStreamType.DATA:\n logicalStreamType = {\n dictionaryType: DICTIONARY_TYPE_BY_ID[stream_type & 0xf],\n };\n break;\n case PhysicalStreamType.OFFSET:\n logicalStreamType = {\n offsetType: OFFSET_TYPE_BY_ID[stream_type & 0xf],\n };\n break;\n case PhysicalStreamType.LENGTH:\n logicalStreamType = {\n lengthType: LENGTH_TYPE_BY_ID[stream_type & 0xf],\n };\n break;\n }\n offset.increment();\n\n const encodings_header = tile[offset.get()];\n const llt1 = LOGICAL_LEVEL_TECHNIQUE_BY_ID[encodings_header >> 5];\n const llt2 = LOGICAL_LEVEL_TECHNIQUE_BY_ID[(encodings_header >> 2) & 0x7];\n const plt = PHYSICAL_LEVEL_TECHNIQUE_BY_ID[encodings_header & 0x3];\n offset.increment();\n\n const sizeInfo = decodeVarintInt32(tile, offset, 2);\n const numValues = sizeInfo[0];\n const byteLength = sizeInfo[1];\n\n return {\n physicalStreamType,\n logicalStreamType,\n logicalLevelTechnique1: llt1,\n logicalLevelTechnique2: llt2,\n physicalLevelTechnique: plt,\n numValues,\n byteLength,\n decompressedCount: numValues,\n };\n}\n"]}
|