@maplibre/mlt 1.1.6 → 1.1.8
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.
- package/dist/decoding/bigEndianDecode.d.ts +13 -0
- package/dist/decoding/bigEndianDecode.js +50 -0
- package/dist/decoding/bigEndianDecode.js.map +1 -0
- package/dist/decoding/decodingTestUtils.d.ts +2 -2
- package/dist/decoding/decodingTestUtils.js +20 -21
- package/dist/decoding/decodingTestUtils.js.map +1 -1
- package/dist/decoding/decodingUtils.js +4 -2
- package/dist/decoding/decodingUtils.js.map +1 -1
- package/dist/decoding/fastPforDecoder.d.ts +47 -0
- package/dist/decoding/fastPforDecoder.js +482 -0
- package/dist/decoding/fastPforDecoder.js.map +1 -0
- package/dist/decoding/fastPforShared.d.ts +7 -0
- package/dist/decoding/fastPforShared.js +29 -0
- package/dist/decoding/fastPforShared.js.map +1 -0
- package/dist/decoding/fastPforUnpack.d.ts +23 -0
- package/dist/decoding/fastPforUnpack.js +910 -0
- package/dist/decoding/fastPforUnpack.js.map +1 -0
- package/dist/decoding/geometryDecoder.d.ts +2 -2
- package/dist/decoding/geometryDecoder.js +52 -49
- package/dist/decoding/geometryDecoder.js.map +1 -1
- package/dist/decoding/intWrapper.js +0 -1
- package/dist/decoding/intWrapper.js.map +1 -1
- package/dist/decoding/integerDecodingUtils.d.ts +33 -25
- package/dist/decoding/integerDecodingUtils.js +115 -52
- package/dist/decoding/integerDecodingUtils.js.map +1 -1
- package/dist/decoding/integerStreamDecoder.d.ts +15 -11
- package/dist/decoding/integerStreamDecoder.js +159 -65
- package/dist/decoding/integerStreamDecoder.js.map +1 -1
- package/dist/decoding/propertyDecoder.js +38 -36
- package/dist/decoding/propertyDecoder.js.map +1 -1
- package/dist/decoding/stringDecoder.js +19 -23
- package/dist/decoding/stringDecoder.js.map +1 -1
- package/dist/decoding/unpackNullableUtils.d.ts +2 -2
- package/dist/decoding/unpackNullableUtils.js.map +1 -1
- package/dist/encoding/bigEndianEncode.d.ts +7 -0
- package/dist/encoding/bigEndianEncode.js +16 -0
- package/dist/encoding/bigEndianEncode.js.map +1 -0
- package/dist/encoding/constGeometryVectorEncoder.d.ts +19 -0
- package/dist/encoding/constGeometryVectorEncoder.js +248 -0
- package/dist/encoding/constGeometryVectorEncoder.js.map +1 -0
- package/dist/encoding/encodingUtils.d.ts +2 -2
- package/dist/encoding/encodingUtils.js +3 -3
- package/dist/encoding/encodingUtils.js.map +1 -1
- package/dist/encoding/fastPforEncoder.d.ts +18 -0
- package/dist/encoding/fastPforEncoder.js +310 -0
- package/dist/encoding/fastPforEncoder.js.map +1 -0
- package/dist/encoding/integerEncodingUtils.d.ts +20 -20
- package/dist/encoding/integerEncodingUtils.js +64 -48
- package/dist/encoding/integerEncodingUtils.js.map +1 -1
- package/dist/encoding/integerStreamEncoder.d.ts +3 -2
- package/dist/encoding/integerStreamEncoder.js +57 -23
- package/dist/encoding/integerStreamEncoder.js.map +1 -1
- package/dist/encoding/packNullableUtils.d.ts +1 -1
- package/dist/encoding/packNullableUtils.js.map +1 -1
- package/dist/encoding/propertyEncoder.d.ts +1 -1
- package/dist/encoding/propertyEncoder.js +17 -24
- package/dist/encoding/propertyEncoder.js.map +1 -1
- package/dist/encoding/stringEncoder.js +9 -42
- package/dist/encoding/stringEncoder.js.map +1 -1
- package/dist/encoding/zOrderCurveEncoder.js +1 -1
- package/dist/encoding/zOrderCurveEncoder.js.map +1 -1
- package/dist/metadata/tile/logicalStreamType.d.ts +8 -12
- package/dist/metadata/tile/logicalStreamType.js +1 -19
- package/dist/metadata/tile/logicalStreamType.js.map +1 -1
- package/dist/metadata/tile/streamMetadataDecoder.d.ts +1 -1
- package/dist/metadata/tile/streamMetadataDecoder.js +9 -4
- package/dist/metadata/tile/streamMetadataDecoder.js.map +1 -1
- package/dist/metadata/tileset/embeddedTilesetMetadataDecoder.d.ts +1 -1
- package/dist/metadata/tileset/embeddedTilesetMetadataDecoder.js.map +1 -1
- package/dist/metadata/tileset/typeMap.d.ts +10 -2
- package/dist/metadata/tileset/typeMap.js +25 -15
- package/dist/metadata/tileset/typeMap.js.map +1 -1
- package/dist/mltDecoder.js +46 -47
- package/dist/mltDecoder.js.map +1 -1
- package/dist/mltMetadata.js.map +1 -1
- package/dist/vector/constant/int32ConstVector.d.ts +6 -0
- package/dist/vector/constant/int32ConstVector.js +10 -0
- package/dist/vector/constant/int32ConstVector.js.map +1 -0
- package/dist/vector/constant/int64ConstVector.d.ts +6 -0
- package/dist/vector/constant/int64ConstVector.js +10 -0
- package/dist/vector/constant/int64ConstVector.js.map +1 -0
- package/dist/vector/dictionary/stringDictionaryVector.d.ts +1 -2
- package/dist/vector/dictionary/stringDictionaryVector.js +0 -3
- package/dist/vector/dictionary/stringDictionaryVector.js.map +1 -1
- package/dist/vector/featureTable.d.ts +7 -8
- package/dist/vector/featureTable.js +10 -42
- package/dist/vector/featureTable.js.map +1 -1
- package/dist/vector/filter/flatSelectionVector.d.ts +1 -1
- package/dist/vector/filter/flatSelectionVector.js +0 -2
- package/dist/vector/filter/flatSelectionVector.js.map +1 -1
- package/dist/vector/filter/selectionVectorUtils.d.ts +1 -1
- package/dist/vector/filter/selectionVectorUtils.js.map +1 -1
- package/dist/vector/filter/sequenceSelectionVector.d.ts +1 -1
- package/dist/vector/filter/sequenceSelectionVector.js +1 -5
- package/dist/vector/filter/sequenceSelectionVector.js.map +1 -1
- package/dist/vector/flat/bitVector.js +0 -2
- package/dist/vector/flat/bitVector.js.map +1 -1
- package/dist/vector/flat/booleanFlatVector.js +0 -1
- package/dist/vector/flat/booleanFlatVector.js.map +1 -1
- package/dist/vector/flat/{intFlatVector.d.ts → int32FlatVector.d.ts} +1 -1
- package/dist/vector/flat/{intFlatVector.js → int32FlatVector.js} +2 -2
- package/dist/vector/flat/int32FlatVector.js.map +1 -0
- package/dist/vector/flat/{longFlatVector.d.ts → int64FlatVector.d.ts} +1 -1
- package/dist/vector/flat/{longFlatVector.js → int64FlatVector.js} +2 -2
- package/dist/vector/flat/int64FlatVector.js.map +1 -0
- package/dist/vector/flat/stringFlatVector.d.ts +0 -1
- package/dist/vector/flat/stringFlatVector.js +0 -2
- package/dist/vector/flat/stringFlatVector.js.map +1 -1
- package/dist/vector/fsst-dictionary/stringFsstDictionaryVector.d.ts +1 -3
- package/dist/vector/fsst-dictionary/stringFsstDictionaryVector.js +0 -42
- package/dist/vector/fsst-dictionary/stringFsstDictionaryVector.js.map +1 -1
- package/dist/vector/geometry/constGeometryVector.d.ts +5 -5
- package/dist/vector/geometry/constGeometryVector.js +1 -3
- package/dist/vector/geometry/constGeometryVector.js.map +1 -1
- package/dist/vector/geometry/constGpuVector.d.ts +4 -4
- package/dist/vector/geometry/constGpuVector.js +1 -3
- package/dist/vector/geometry/constGpuVector.js.map +1 -1
- package/dist/vector/geometry/flatGeometryVector.d.ts +4 -4
- package/dist/vector/geometry/flatGeometryVector.js +1 -5
- package/dist/vector/geometry/flatGeometryVector.js.map +1 -1
- package/dist/vector/geometry/flatGpuVector.d.ts +3 -3
- package/dist/vector/geometry/flatGpuVector.js +0 -1
- package/dist/vector/geometry/flatGpuVector.js.map +1 -1
- package/dist/vector/geometry/geometryType.js.map +1 -1
- package/dist/vector/geometry/geometryVector.d.ts +7 -8
- package/dist/vector/geometry/geometryVector.js +0 -13
- package/dist/vector/geometry/geometryVector.js.map +1 -1
- package/dist/vector/geometry/geometryVectorConverter.d.ts +1 -1
- package/dist/vector/geometry/geometryVectorConverter.js +167 -211
- package/dist/vector/geometry/geometryVectorConverter.js.map +1 -1
- package/dist/vector/geometry/gpuVector.d.ts +6 -6
- package/dist/vector/geometry/gpuVector.js +0 -4
- package/dist/vector/geometry/gpuVector.js.map +1 -1
- package/dist/vector/geometry/topologyVector.d.ts +5 -9
- package/dist/vector/geometry/topologyVector.js +1 -19
- package/dist/vector/geometry/topologyVector.js.map +1 -1
- package/dist/vector/geometry/vertexBufferType.js.map +1 -1
- package/dist/vector/idVector.d.ts +8 -0
- package/dist/vector/idVector.js +2 -0
- package/dist/vector/idVector.js.map +1 -0
- package/dist/vector/sequence/{intSequenceVector.d.ts → int32SequenceVector.d.ts} +1 -1
- package/dist/vector/sequence/{intSequenceVector.js → int32SequenceVector.js} +2 -2
- package/dist/vector/sequence/int32SequenceVector.js.map +1 -0
- package/dist/vector/sequence/{longSequenceVector.d.ts → int64SequenceVector.d.ts} +1 -1
- package/dist/vector/sequence/{longSequenceVector.js → int64SequenceVector.js} +2 -2
- package/dist/vector/sequence/int64SequenceVector.js.map +1 -0
- package/dist/vector/sequence/sequenceVector.js +0 -1
- package/dist/vector/sequence/sequenceVector.js.map +1 -1
- package/dist/vector/variableSizeVector.js +0 -1
- package/dist/vector/variableSizeVector.js.map +1 -1
- package/dist/vector/vector.js +1 -5
- package/dist/vector/vector.js.map +1 -1
- package/dist/vector/vectorType.js.map +1 -1
- package/package.json +9 -10
- package/dist/decoding/decodingUtils.spec.d.ts +0 -1
- package/dist/decoding/decodingUtils.spec.js +0 -141
- package/dist/decoding/decodingUtils.spec.js.map +0 -1
- package/dist/decoding/fsstDecoder.spec.d.ts +0 -1
- package/dist/decoding/fsstDecoder.spec.js +0 -57
- package/dist/decoding/fsstDecoder.spec.js.map +0 -1
- package/dist/decoding/integerDecodingUtils.spec.d.ts +0 -1
- package/dist/decoding/integerDecodingUtils.spec.js +0 -300
- package/dist/decoding/integerDecodingUtils.spec.js.map +0 -1
- package/dist/decoding/integerStreamDecoder.spec.d.ts +0 -1
- package/dist/decoding/integerStreamDecoder.spec.js +0 -402
- package/dist/decoding/integerStreamDecoder.spec.js.map +0 -1
- package/dist/decoding/propertyDecoder.spec.d.ts +0 -1
- package/dist/decoding/propertyDecoder.spec.js +0 -448
- package/dist/decoding/propertyDecoder.spec.js.map +0 -1
- package/dist/decoding/stringDecoder.spec.d.ts +0 -1
- package/dist/decoding/stringDecoder.spec.js +0 -387
- package/dist/decoding/stringDecoder.spec.js.map +0 -1
- package/dist/decoding/unpackNullableUtils.spec.d.ts +0 -1
- package/dist/decoding/unpackNullableUtils.spec.js +0 -71
- package/dist/decoding/unpackNullableUtils.spec.js.map +0 -1
- package/dist/metadata/tileset/embeddedTilesetMetadataDecoder.spec.d.ts +0 -1
- package/dist/metadata/tileset/embeddedTilesetMetadataDecoder.spec.js +0 -142
- package/dist/metadata/tileset/embeddedTilesetMetadataDecoder.spec.js.map +0 -1
- package/dist/mltDecoder.spec.d.ts +0 -1
- package/dist/mltDecoder.spec.js +0 -152
- package/dist/mltDecoder.spec.js.map +0 -1
- package/dist/vector/constant/intConstVector.d.ts +0 -6
- package/dist/vector/constant/intConstVector.js +0 -10
- package/dist/vector/constant/intConstVector.js.map +0 -1
- package/dist/vector/constant/longConstVector.d.ts +0 -6
- package/dist/vector/constant/longConstVector.js +0 -10
- package/dist/vector/constant/longConstVector.js.map +0 -1
- package/dist/vector/filter/flatSelectionVector.spec.d.ts +0 -1
- package/dist/vector/filter/flatSelectionVector.spec.js +0 -51
- package/dist/vector/filter/flatSelectionVector.spec.js.map +0 -1
- package/dist/vector/filter/selectionVectorUtil.spec.d.ts +0 -1
- package/dist/vector/filter/selectionVectorUtil.spec.js +0 -154
- package/dist/vector/filter/selectionVectorUtil.spec.js.map +0 -1
- package/dist/vector/filter/sequenceSelectionVector.spec.d.ts +0 -1
- package/dist/vector/filter/sequenceSelectionVector.spec.js +0 -115
- package/dist/vector/filter/sequenceSelectionVector.spec.js.map +0 -1
- package/dist/vector/flat/floatFlatVector.spec.d.ts +0 -1
- package/dist/vector/flat/floatFlatVector.spec.js +0 -14
- package/dist/vector/flat/floatFlatVector.spec.js.map +0 -1
- package/dist/vector/flat/intFlatVector.js.map +0 -1
- package/dist/vector/flat/intFlatVector.spec.d.ts +0 -1
- package/dist/vector/flat/intFlatVector.spec.js +0 -15
- package/dist/vector/flat/intFlatVector.spec.js.map +0 -1
- package/dist/vector/flat/longFlatVector.js.map +0 -1
- package/dist/vector/flat/longFlatVector.spec.d.ts +0 -1
- package/dist/vector/flat/longFlatVector.spec.js +0 -14
- package/dist/vector/flat/longFlatVector.spec.js.map +0 -1
- package/dist/vector/fsst-dictionary/stringFsstDictionaryVector.spec.d.ts +0 -1
- package/dist/vector/fsst-dictionary/stringFsstDictionaryVector.spec.js +0 -28
- package/dist/vector/fsst-dictionary/stringFsstDictionaryVector.spec.js.map +0 -1
- package/dist/vector/geometry/zOrderCurve.spec.d.ts +0 -1
- package/dist/vector/geometry/zOrderCurve.spec.js +0 -25
- package/dist/vector/geometry/zOrderCurve.spec.js.map +0 -1
- package/dist/vector/intVector.d.ts +0 -8
- package/dist/vector/intVector.js +0 -2
- package/dist/vector/intVector.js.map +0 -1
- package/dist/vector/sequence/intSequenceVector.js.map +0 -1
- package/dist/vector/sequence/longSequenceVector.js.map +0 -1
- package/dist/vector/sequence/longSequenceVektor.spec.d.ts +0 -1
- package/dist/vector/sequence/longSequenceVektor.spec.js +0 -11
- package/dist/vector/sequence/longSequenceVektor.spec.js.map +0 -1
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { PhysicalStreamType } from "../metadata/tile/physicalStreamType";
|
|
2
|
-
import { LogicalStreamType } from "../metadata/tile/logicalStreamType";
|
|
3
2
|
import { DictionaryType } from "../metadata/tile/dictionaryType";
|
|
4
3
|
import { LengthType } from "../metadata/tile/lengthType";
|
|
5
4
|
import { OffsetType } from "../metadata/tile/offsetType";
|
|
@@ -28,14 +27,14 @@ export function encodePlainStrings(strings) {
|
|
|
28
27
|
}
|
|
29
28
|
// Add LENGTH stream
|
|
30
29
|
const lengths = createStringLengths(nonNullStrings);
|
|
31
|
-
streams.push(createStream(PhysicalStreamType.LENGTH, encodeVarintInt32(
|
|
32
|
-
logical:
|
|
30
|
+
streams.push(createStream(PhysicalStreamType.LENGTH, encodeVarintInt32(lengths), {
|
|
31
|
+
logical: { lengthType: LengthType.VAR_BINARY },
|
|
33
32
|
technique: PhysicalLevelTechnique.VARINT,
|
|
34
33
|
count: lengths.length,
|
|
35
34
|
}));
|
|
36
35
|
// Add DATA stream
|
|
37
36
|
streams.push(createStream(PhysicalStreamType.DATA, stringBytes, {
|
|
38
|
-
logical:
|
|
37
|
+
logical: { dictionaryType: DictionaryType.NONE },
|
|
39
38
|
}));
|
|
40
39
|
return concatenateBuffers(...streams);
|
|
41
40
|
}
|
|
@@ -69,20 +68,20 @@ export function encodeDictionaryStrings(strings) {
|
|
|
69
68
|
}));
|
|
70
69
|
}
|
|
71
70
|
// Add OFFSET stream
|
|
72
|
-
streams.push(createStream(PhysicalStreamType.OFFSET, encodeVarintInt32(new
|
|
73
|
-
logical:
|
|
71
|
+
streams.push(createStream(PhysicalStreamType.OFFSET, encodeVarintInt32(new Uint32Array(offsets)), {
|
|
72
|
+
logical: { offsetType: OffsetType.STRING },
|
|
74
73
|
technique: PhysicalLevelTechnique.VARINT,
|
|
75
74
|
count: offsets.length,
|
|
76
75
|
}));
|
|
77
76
|
// Add LENGTH stream (for dictionary)
|
|
78
|
-
streams.push(createStream(PhysicalStreamType.LENGTH, encodeVarintInt32(
|
|
79
|
-
logical:
|
|
77
|
+
streams.push(createStream(PhysicalStreamType.LENGTH, encodeVarintInt32(lengths), {
|
|
78
|
+
logical: { lengthType: LengthType.DICTIONARY },
|
|
80
79
|
technique: PhysicalLevelTechnique.VARINT,
|
|
81
80
|
count: lengths.length,
|
|
82
81
|
}));
|
|
83
82
|
// Add DATA stream
|
|
84
83
|
streams.push(createStream(PhysicalStreamType.DATA, stringBytes, {
|
|
85
|
-
logical:
|
|
84
|
+
logical: { dictionaryType: DictionaryType.SINGLE },
|
|
86
85
|
}));
|
|
87
86
|
return concatenateBuffers(...streams);
|
|
88
87
|
}
|
|
@@ -90,7 +89,7 @@ function createStream(physicalType, data, options = {}) {
|
|
|
90
89
|
const count = options.count ?? 0;
|
|
91
90
|
return buildEncodedStream({
|
|
92
91
|
physicalStreamType: physicalType,
|
|
93
|
-
logicalStreamType: options.logical ??
|
|
92
|
+
logicalStreamType: options.logical ?? {},
|
|
94
93
|
logicalLevelTechnique1: LogicalLevelTechnique.NONE,
|
|
95
94
|
logicalLevelTechnique2: LogicalLevelTechnique.NONE,
|
|
96
95
|
physicalLevelTechnique: options.technique ?? PhysicalLevelTechnique.NONE,
|
|
@@ -147,36 +146,4 @@ function getLogicalSubtypeValue(metadata) {
|
|
|
147
146
|
return 0;
|
|
148
147
|
}
|
|
149
148
|
}
|
|
150
|
-
function encodeNumStreams(numStreams) {
|
|
151
|
-
const buffer = new Uint8Array(5);
|
|
152
|
-
const offset = new IntWrapper(0);
|
|
153
|
-
encodeVarintInt32Value(numStreams, buffer, offset);
|
|
154
|
-
return buffer.slice(0, offset.get());
|
|
155
|
-
}
|
|
156
|
-
function createPresentStream(presentValues) {
|
|
157
|
-
const metadata = {
|
|
158
|
-
physicalStreamType: PhysicalStreamType.PRESENT,
|
|
159
|
-
logicalStreamType: new LogicalStreamType(DictionaryType.NONE),
|
|
160
|
-
logicalLevelTechnique1: LogicalLevelTechnique.NONE,
|
|
161
|
-
logicalLevelTechnique2: LogicalLevelTechnique.NONE,
|
|
162
|
-
physicalLevelTechnique: PhysicalLevelTechnique.VARINT,
|
|
163
|
-
numValues: presentValues.length,
|
|
164
|
-
byteLength: 0,
|
|
165
|
-
decompressedCount: presentValues.length,
|
|
166
|
-
};
|
|
167
|
-
return buildEncodedStream(metadata, encodeBooleanRle(presentValues));
|
|
168
|
-
}
|
|
169
|
-
function createOffsetStream(offsetIndices) {
|
|
170
|
-
const metadata = {
|
|
171
|
-
physicalStreamType: PhysicalStreamType.OFFSET,
|
|
172
|
-
logicalStreamType: new LogicalStreamType(undefined, OffsetType.STRING),
|
|
173
|
-
logicalLevelTechnique1: LogicalLevelTechnique.NONE,
|
|
174
|
-
logicalLevelTechnique2: LogicalLevelTechnique.NONE,
|
|
175
|
-
physicalLevelTechnique: PhysicalLevelTechnique.VARINT,
|
|
176
|
-
numValues: offsetIndices.length,
|
|
177
|
-
byteLength: 0,
|
|
178
|
-
decompressedCount: offsetIndices.length,
|
|
179
|
-
};
|
|
180
|
-
return buildEncodedStream(metadata, encodeVarintInt32(new Int32Array(offsetIndices)));
|
|
181
|
-
}
|
|
182
149
|
//# sourceMappingURL=stringEncoder.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"stringEncoder.js","sourceRoot":"","sources":["../../src/encoding/stringEncoder.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,qCAAqC,CAAC;AACzE,OAAO,EAAE,iBAAiB,EAAE,MAAM,oCAAoC,CAAC;AACvE,OAAO,EAAE,cAAc,EAAE,MAAM,iCAAiC,CAAC;AACjE,OAAO,EAAE,UAAU,EAAE,MAAM,6BAA6B,CAAC;AACzD,OAAO,EAAE,UAAU,EAAE,MAAM,6BAA6B,CAAC;AACzD,OAAO,EAAE,sBAAsB,EAAE,MAAM,yCAAyC,CAAC;AACjF,OAAO,EAAE,qBAAqB,EAAE,MAAM,wCAAwC,CAAC;AAE/E,OAAO,UAAU,MAAM,wBAAwB,CAAC;AAChD,OAAO,EAAE,gBAAgB,EAAE,aAAa,EAAE,mBAAmB,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AAC3G,OAAO,EAAE,sBAAsB,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAEnF;;;;GAIG;AACH,MAAM,UAAU,kBAAkB,CAAC,OAA0B;IACzD,MAAM,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,KAAK,IAAI,CAAC,CAAC;IAChD,MAAM,cAAc,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,EAAe,EAAE,CAAC,CAAC,KAAK,IAAI,CAAC,CAAC;IACtE,MAAM,WAAW,GAAG,aAAa,CAAC,cAAc,CAAC,CAAC;IAElD,MAAM,OAAO,GAAiB,EAAE,CAAC;IAEjC,oCAAoC;IACpC,IAAI,OAAO,EAAE,CAAC;QACV,MAAM,iBAAiB,GAAG,OAAO,CAAC,GAAG,CAA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AC,QAAQ,EAAE,iBAAiB,CAAC,IAAI,UAAU,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC;AAC1F,CAAC","sourcesContent":["import { PhysicalStreamType } from \"../metadata/tile/physicalStreamType\";\nimport { LogicalStreamType } from \"../metadata/tile/logicalStreamType\";\nimport { DictionaryType } from \"../metadata/tile/dictionaryType\";\nimport { LengthType } from \"../metadata/tile/lengthType\";\nimport { OffsetType } from \"../metadata/tile/offsetType\";\nimport { PhysicalLevelTechnique } from \"../metadata/tile/physicalLevelTechnique\";\nimport { LogicalLevelTechnique } from \"../metadata/tile/logicalLevelTechnique\";\nimport type { StreamMetadata } from \"../metadata/tile/streamMetadataDecoder\";\nimport IntWrapper from \"../decoding/intWrapper\";\nimport { encodeBooleanRle, encodeStrings, createStringLengths, concatenateBuffers } from \"./encodingUtils\";\nimport { encodeVarintInt32Value, encodeVarintInt32 } from \"./integerEncodingUtils\";\n\n/**\n * Encodes plain strings into a complete stream with PRESENT (if needed), LENGTH, and DATA streams.\n * @param strings - Array of strings (can include null values)\n * @returns Encoded Uint8Array that can be passed to decodeString\n */\nexport function encodePlainStrings(strings: (string | null)[]): Uint8Array {\n const hasNull = strings.some((s) => s === null);\n const nonNullStrings = strings.filter((s): s is string => s !== null);\n const stringBytes = encodeStrings(nonNullStrings);\n\n const streams: Uint8Array[] = [];\n\n // Add PRESENT stream if nulls exist\n if (hasNull) {\n const nullabilityValues = strings.map((s) => s !== null);\n streams.push(\n createStream(PhysicalStreamType.PRESENT, encodeBooleanRle(nullabilityValues), {\n technique: PhysicalLevelTechnique.VARINT,\n count: nullabilityValues.length,\n }),\n );\n }\n\n // Add LENGTH stream\n const lengths = createStringLengths(nonNullStrings);\n streams.push(\n createStream(PhysicalStreamType.LENGTH, encodeVarintInt32(new Int32Array(lengths)), {\n logical: new LogicalStreamType(undefined, undefined, LengthType.VAR_BINARY),\n technique: PhysicalLevelTechnique.VARINT,\n count: lengths.length,\n }),\n );\n\n // Add DATA stream\n streams.push(\n createStream(PhysicalStreamType.DATA, stringBytes, {\n logical: new LogicalStreamType(DictionaryType.NONE),\n }),\n );\n\n return concatenateBuffers(...streams);\n}\n\n/**\n * Encodes dictionary-compressed strings into a complete stream.\n * @param strings - Array of strings (can include null values)\n * @returns Encoded Uint8Array that can be passed to decodeString\n */\nexport function encodeDictionaryStrings(strings: (string | null)[]): Uint8Array {\n const hasNull = strings.some((s) => s === null);\n const nonNullStrings = strings.filter((s): s is string => s !== null);\n\n // Create dictionary of unique strings\n const uniqueStrings = Array.from(new Set(nonNullStrings));\n const stringMap = new Map(uniqueStrings.map((s, i) => [s, i]));\n const offsets = nonNullStrings.map((s) => {\n const offset = stringMap.get(s);\n if (offset === undefined) {\n throw new Error(`String not found in dictionary: ${s}`);\n }\n return offset;\n });\n\n const stringBytes = encodeStrings(uniqueStrings);\n const lengths = createStringLengths(uniqueStrings);\n\n const streams: Uint8Array[] = [];\n\n // Add PRESENT stream if nulls exist\n if (hasNull) {\n const nullabilityValues = strings.map((s) => s !== null);\n streams.push(\n createStream(PhysicalStreamType.PRESENT, encodeBooleanRle(nullabilityValues), {\n technique: PhysicalLevelTechnique.VARINT,\n count: nullabilityValues.length,\n }),\n );\n }\n\n // Add OFFSET stream\n streams.push(\n createStream(PhysicalStreamType.OFFSET, encodeVarintInt32(new Int32Array(offsets)), {\n logical: new LogicalStreamType(undefined, OffsetType.STRING),\n technique: PhysicalLevelTechnique.VARINT,\n count: offsets.length,\n }),\n );\n\n // Add LENGTH stream (for dictionary)\n streams.push(\n createStream(PhysicalStreamType.LENGTH, encodeVarintInt32(new Int32Array(lengths)), {\n logical: new LogicalStreamType(undefined, undefined, LengthType.DICTIONARY),\n technique: PhysicalLevelTechnique.VARINT,\n count: lengths.length,\n }),\n );\n\n // Add DATA stream\n streams.push(\n createStream(PhysicalStreamType.DATA, stringBytes, {\n logical: new LogicalStreamType(DictionaryType.SINGLE),\n }),\n );\n\n return concatenateBuffers(...streams);\n}\n\nfunction createStream(\n physicalType: PhysicalStreamType,\n data: Uint8Array,\n options: {\n logical?: LogicalStreamType;\n technique?: PhysicalLevelTechnique;\n count?: number;\n } = {},\n): Uint8Array {\n const count = options.count ?? 0;\n return buildEncodedStream(\n {\n physicalStreamType: physicalType,\n logicalStreamType: options.logical ?? new LogicalStreamType(),\n logicalLevelTechnique1: LogicalLevelTechnique.NONE,\n logicalLevelTechnique2: LogicalLevelTechnique.NONE,\n physicalLevelTechnique: options.technique ?? PhysicalLevelTechnique.NONE,\n numValues: count,\n byteLength: data.length,\n decompressedCount: count,\n },\n data,\n );\n}\n\nfunction buildEncodedStream(streamMetadata: StreamMetadata, encodedData: Uint8Array): Uint8Array {\n const updatedMetadata = {\n ...streamMetadata,\n byteLength: encodedData.length,\n };\n\n const metadataBuffer = encodeStreamMetadata(updatedMetadata);\n const result = new Uint8Array(metadataBuffer.length + encodedData.length);\n result.set(metadataBuffer, 0);\n result.set(encodedData, metadataBuffer.length);\n\n return result;\n}\n\nfunction encodeStreamMetadata(metadata: StreamMetadata): Uint8Array {\n const buffer = new Uint8Array(100);\n let writeOffset = 0;\n\n // Byte 1: Stream type\n const physicalTypeIndex = Object.values(PhysicalStreamType).indexOf(metadata.physicalStreamType);\n const lowerNibble = getLogicalSubtypeValue(metadata);\n buffer[writeOffset++] = (physicalTypeIndex << 4) | lowerNibble;\n\n // Byte 2: Encoding techniques\n const llt1Index = Object.values(LogicalLevelTechnique).indexOf(metadata.logicalLevelTechnique1);\n const llt2Index = Object.values(LogicalLevelTechnique).indexOf(metadata.logicalLevelTechnique2);\n const pltIndex = Object.values(PhysicalLevelTechnique).indexOf(metadata.physicalLevelTechnique);\n buffer[writeOffset++] = (llt1Index << 5) | (llt2Index << 2) | pltIndex;\n\n // Variable-length fields\n const offset = new IntWrapper(writeOffset);\n encodeVarintInt32Value(metadata.numValues, buffer, offset);\n encodeVarintInt32Value(metadata.byteLength, buffer, offset);\n\n return buffer.slice(0, offset.get());\n}\n\nfunction getLogicalSubtypeValue(metadata: StreamMetadata): number {\n const { physicalStreamType, logicalStreamType } = metadata;\n\n switch (physicalStreamType) {\n case PhysicalStreamType.DATA:\n return logicalStreamType.dictionaryType !== undefined\n ? Object.values(DictionaryType).indexOf(logicalStreamType.dictionaryType)\n : 0;\n case PhysicalStreamType.OFFSET:\n return logicalStreamType.offsetType !== undefined\n ? Object.values(OffsetType).indexOf(logicalStreamType.offsetType)\n : 0;\n case PhysicalStreamType.LENGTH:\n return logicalStreamType.lengthType !== undefined\n ? Object.values(LengthType).indexOf(logicalStreamType.lengthType)\n : 0;\n default:\n return 0;\n }\n}\n\nfunction encodeNumStreams(numStreams: number): Uint8Array {\n const buffer = new Uint8Array(5);\n const offset = new IntWrapper(0);\n encodeVarintInt32Value(numStreams, buffer, offset);\n return buffer.slice(0, offset.get());\n}\n\nfunction createPresentStream(presentValues: boolean[]): Uint8Array {\n const metadata: StreamMetadata = {\n physicalStreamType: PhysicalStreamType.PRESENT,\n logicalStreamType: new LogicalStreamType(DictionaryType.NONE),\n logicalLevelTechnique1: LogicalLevelTechnique.NONE,\n logicalLevelTechnique2: LogicalLevelTechnique.NONE,\n physicalLevelTechnique: PhysicalLevelTechnique.VARINT,\n numValues: presentValues.length,\n byteLength: 0,\n decompressedCount: presentValues.length,\n };\n return buildEncodedStream(metadata, encodeBooleanRle(presentValues));\n}\n\nfunction createOffsetStream(offsetIndices: number[]): Uint8Array {\n const metadata: StreamMetadata = {\n physicalStreamType: PhysicalStreamType.OFFSET,\n logicalStreamType: new LogicalStreamType(undefined, OffsetType.STRING),\n logicalLevelTechnique1: LogicalLevelTechnique.NONE,\n logicalLevelTechnique2: LogicalLevelTechnique.NONE,\n physicalLevelTechnique: PhysicalLevelTechnique.VARINT,\n numValues: offsetIndices.length,\n byteLength: 0,\n decompressedCount: offsetIndices.length,\n };\n return buildEncodedStream(metadata, encodeVarintInt32(new Int32Array(offsetIndices)));\n}\n"]}
|
|
1
|
+
{"version":3,"file":"stringEncoder.js","sourceRoot":"","sources":["../../src/enc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C,GAAG,EAAE,CAAC,CAAC;AACzC,CAAC;AAED,SAAS,sBAAsB,CAAC,QAAwB;IACpD,MAAM,EAAE,kBAAkB,EAAE,iBAAiB,EAAE,GAAG,QAAQ,CAAC;IAE3D,QAAQ,kBAAkB,EAAE,CAAC;QACzB,KAAK,kBAAkB,CAAC,IAAI;YACxB,OAAO,iBAAiB,CAAC,cAAc,KAAK,SAAS;gBACjD,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC,cAAc,CAAC,CAAC,OAAO,CAAC,iBAAiB,CAAC,cAAc,CAAC;gBACzE,CAAC,CAAC,CAAC,CAAC;QACZ,KAAK,kBAAkB,CAAC,MAAM;YAC1B,OAAO,iBAAiB,CAAC,UAAU,KAAK,SAAS;gBAC7C,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC,OAAO,CAAC,iBAAiB,CAAC,UAAU,CAAC;gBACjE,CAAC,CAAC,CAAC,CAAC;QACZ,KAAK,kBAAkB,CAAC,MAAM;YAC1B,OAAO,iBAAiB,CAAC,UAAU,KAAK,SAAS;gBAC7C,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC,OAAO,CAAC,iBAAiB,CAAC,UAAU,CAAC;gBACjE,CAAC,CAAC,CAAC,CAAC;QACZ;YACI,OAAO,CAAC,CAAC;IACjB,CAAC;AACL,CAAC","sourcesContent":["import { PhysicalStreamType } from \"../metadata/tile/physicalStreamType\";\nimport { DictionaryType } from \"../metadata/tile/dictionaryType\";\nimport { LengthType } from \"../metadata/tile/lengthType\";\nimport { OffsetType } from \"../metadata/tile/offsetType\";\nimport { PhysicalLevelTechnique } from \"../metadata/tile/physicalLevelTechnique\";\nimport { LogicalLevelTechnique } from \"../metadata/tile/logicalLevelTechnique\";\nimport IntWrapper from \"../decoding/intWrapper\";\nimport { encodeBooleanRle, encodeStrings, createStringLengths, concatenateBuffers } from \"./encodingUtils\";\nimport { encodeVarintInt32Value, encodeVarintInt32 } from \"./integerEncodingUtils\";\nimport type { StreamMetadata } from \"../metadata/tile/streamMetadataDecoder\";\nimport type { LogicalStreamType } from \"../metadata/tile/logicalStreamType\";\n\n/**\n * Encodes plain strings into a complete stream with PRESENT (if needed), LENGTH, and DATA streams.\n * @param strings - Array of strings (can include null values)\n * @returns Encoded Uint8Array that can be passed to decodeString\n */\nexport function encodePlainStrings(strings: (string | null)[]): Uint8Array {\n const hasNull = strings.some((s) => s === null);\n const nonNullStrings = strings.filter((s): s is string => s !== null);\n const stringBytes = encodeStrings(nonNullStrings);\n\n const streams: Uint8Array[] = [];\n\n // Add PRESENT stream if nulls exist\n if (hasNull) {\n const nullabilityValues = strings.map((s) => s !== null);\n streams.push(\n createStream(PhysicalStreamType.PRESENT, encodeBooleanRle(nullabilityValues), {\n technique: PhysicalLevelTechnique.VARINT,\n count: nullabilityValues.length,\n }),\n );\n }\n\n // Add LENGTH stream\n const lengths = createStringLengths(nonNullStrings);\n streams.push(\n createStream(PhysicalStreamType.LENGTH, encodeVarintInt32(lengths), {\n logical: { lengthType: LengthType.VAR_BINARY },\n technique: PhysicalLevelTechnique.VARINT,\n count: lengths.length,\n }),\n );\n\n // Add DATA stream\n streams.push(\n createStream(PhysicalStreamType.DATA, stringBytes, {\n logical: { dictionaryType: DictionaryType.NONE },\n }),\n );\n\n return concatenateBuffers(...streams);\n}\n\n/**\n * Encodes dictionary-compressed strings into a complete stream.\n * @param strings - Array of strings (can include null values)\n * @returns Encoded Uint8Array that can be passed to decodeString\n */\nexport function encodeDictionaryStrings(strings: (string | null)[]): Uint8Array {\n const hasNull = strings.some((s) => s === null);\n const nonNullStrings = strings.filter((s): s is string => s !== null);\n\n // Create dictionary of unique strings\n const uniqueStrings = Array.from(new Set(nonNullStrings));\n const stringMap = new Map(uniqueStrings.map((s, i) => [s, i]));\n const offsets = nonNullStrings.map((s) => {\n const offset = stringMap.get(s);\n if (offset === undefined) {\n throw new Error(`String not found in dictionary: ${s}`);\n }\n return offset;\n });\n\n const stringBytes = encodeStrings(uniqueStrings);\n const lengths = createStringLengths(uniqueStrings);\n\n const streams: Uint8Array[] = [];\n\n // Add PRESENT stream if nulls exist\n if (hasNull) {\n const nullabilityValues = strings.map((s) => s !== null);\n streams.push(\n createStream(PhysicalStreamType.PRESENT, encodeBooleanRle(nullabilityValues), {\n technique: PhysicalLevelTechnique.VARINT,\n count: nullabilityValues.length,\n }),\n );\n }\n\n // Add OFFSET stream\n streams.push(\n createStream(PhysicalStreamType.OFFSET, encodeVarintInt32(new Uint32Array(offsets)), {\n logical: { offsetType: OffsetType.STRING },\n technique: PhysicalLevelTechnique.VARINT,\n count: offsets.length,\n }),\n );\n\n // Add LENGTH stream (for dictionary)\n streams.push(\n createStream(PhysicalStreamType.LENGTH, encodeVarintInt32(lengths), {\n logical: { lengthType: LengthType.DICTIONARY },\n technique: PhysicalLevelTechnique.VARINT,\n count: lengths.length,\n }),\n );\n\n // Add DATA stream\n streams.push(\n createStream(PhysicalStreamType.DATA, stringBytes, {\n logical: { dictionaryType: DictionaryType.SINGLE },\n }),\n );\n\n return concatenateBuffers(...streams);\n}\n\nfunction createStream(\n physicalType: PhysicalStreamType,\n data: Uint8Array,\n options: {\n logical?: LogicalStreamType;\n technique?: PhysicalLevelTechnique;\n count?: number;\n } = {},\n): Uint8Array {\n const count = options.count ?? 0;\n return buildEncodedStream(\n {\n physicalStreamType: physicalType,\n logicalStreamType: options.logical ?? {},\n logicalLevelTechnique1: LogicalLevelTechnique.NONE,\n logicalLevelTechnique2: LogicalLevelTechnique.NONE,\n physicalLevelTechnique: options.technique ?? PhysicalLevelTechnique.NONE,\n numValues: count,\n byteLength: data.length,\n decompressedCount: count,\n },\n data,\n );\n}\n\nfunction buildEncodedStream(streamMetadata: StreamMetadata, encodedData: Uint8Array): Uint8Array {\n const updatedMetadata = {\n ...streamMetadata,\n byteLength: encodedData.length,\n };\n\n const metadataBuffer = encodeStreamMetadata(updatedMetadata);\n const result = new Uint8Array(metadataBuffer.length + encodedData.length);\n result.set(metadataBuffer, 0);\n result.set(encodedData, metadataBuffer.length);\n\n return result;\n}\n\nfunction encodeStreamMetadata(metadata: StreamMetadata): Uint8Array {\n const buffer = new Uint8Array(100);\n let writeOffset = 0;\n\n // Byte 1: Stream type\n const physicalTypeIndex = Object.values(PhysicalStreamType).indexOf(metadata.physicalStreamType);\n const lowerNibble = getLogicalSubtypeValue(metadata);\n buffer[writeOffset++] = (physicalTypeIndex << 4) | lowerNibble;\n\n // Byte 2: Encoding techniques\n const llt1Index = Object.values(LogicalLevelTechnique).indexOf(metadata.logicalLevelTechnique1);\n const llt2Index = Object.values(LogicalLevelTechnique).indexOf(metadata.logicalLevelTechnique2);\n const pltIndex = Object.values(PhysicalLevelTechnique).indexOf(metadata.physicalLevelTechnique);\n buffer[writeOffset++] = (llt1Index << 5) | (llt2Index << 2) | pltIndex;\n\n // Variable-length fields\n const offset = new IntWrapper(writeOffset);\n encodeVarintInt32Value(metadata.numValues, buffer, offset);\n encodeVarintInt32Value(metadata.byteLength, buffer, offset);\n\n return buffer.slice(0, offset.get());\n}\n\nfunction getLogicalSubtypeValue(metadata: StreamMetadata): number {\n const { physicalStreamType, logicalStreamType } = metadata;\n\n switch (physicalStreamType) {\n case PhysicalStreamType.DATA:\n return logicalStreamType.dictionaryType !== undefined\n ? Object.values(DictionaryType).indexOf(logicalStreamType.dictionaryType)\n : 0;\n case PhysicalStreamType.OFFSET:\n return logicalStreamType.offsetType !== undefined\n ? Object.values(OffsetType).indexOf(logicalStreamType.offsetType)\n : 0;\n case PhysicalStreamType.LENGTH:\n return logicalStreamType.lengthType !== undefined\n ? Object.values(LengthType).indexOf(logicalStreamType.lengthType)\n : 0;\n default:\n return 0;\n }\n}\n"]}
|
|
@@ -3,7 +3,7 @@ export function encodeZOrderCurve(x, y, numBits, coordinateShift) {
|
|
|
3
3
|
const shiftedY = y + coordinateShift;
|
|
4
4
|
let code = 0;
|
|
5
5
|
for (let i = 0; i < numBits; i++) {
|
|
6
|
-
code |= (shiftedX & (1 << i)) << i | (shiftedY & (1 << i)) << (i + 1);
|
|
6
|
+
code |= ((shiftedX & (1 << i)) << i) | ((shiftedY & (1 << i)) << (i + 1));
|
|
7
7
|
}
|
|
8
8
|
return code;
|
|
9
9
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"zOrderCurveEncoder.js","sourceRoot":"","sources":["../../src/encoding/zOrderCurveEncoder.ts"],"names":[],"mappings":"AAAA,MAAM,UAAU,iBAAiB,
|
|
1
|
+
{"version":3,"file":"zOrderCurveEncoder.js","sourceRoot":"","sources":["../../src/encoding/zOrderCurveEncoder.ts"],"names":[],"mappings":"AAAA,MAAM,UAAU,iBAAiB,CAAC,CAAS,EAAE,CAAS,EAAE,OAAe,EAAE,eAAuB;IAC5F,MAAM,QAAQ,GAAG,CAAC,GAAG,eAAe,CAAC;IACrC,MAAM,QAAQ,GAAG,CAAC,GAAG,eAAe,CAAC;IACrC,IAAI,IAAI,GAAG,CAAC,CAAC;IACb,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,OAAO,EAAE,CAAC,EAAE,EAAE,CAAC;QAC/B,IAAI,IAAI,CAAC,CAAC,QAAQ,GAAG,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC,QAAQ,GAAG,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;IAC9E,CAAC;IACD,OAAO,IAAI,CAAC;AAChB,CAAC","sourcesContent":["export function encodeZOrderCurve(x: number, y: number, numBits: number, coordinateShift: number): number {\n const shiftedX = x + coordinateShift;\n const shiftedY = y + coordinateShift;\n let code = 0;\n for (let i = 0; i < numBits; i++) {\n code |= ((shiftedX & (1 << i)) << i) | ((shiftedY & (1 << i)) << (i + 1));\n }\n return code;\n}\n"]}
|
|
@@ -1,12 +1,8 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
export
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
get dictionaryType(): DictionaryType | undefined;
|
|
10
|
-
get offsetType(): OffsetType | undefined;
|
|
11
|
-
get lengthType(): LengthType | undefined;
|
|
12
|
-
}
|
|
1
|
+
import type { DictionaryType } from "./dictionaryType";
|
|
2
|
+
import type { OffsetType } from "./offsetType";
|
|
3
|
+
import type { LengthType } from "./lengthType";
|
|
4
|
+
export type LogicalStreamType = {
|
|
5
|
+
readonly dictionaryType?: DictionaryType;
|
|
6
|
+
readonly offsetType?: OffsetType;
|
|
7
|
+
readonly lengthType?: LengthType;
|
|
8
|
+
};
|
|
@@ -1,20 +1,2 @@
|
|
|
1
|
-
export
|
|
2
|
-
_dictionaryType;
|
|
3
|
-
_offsetType;
|
|
4
|
-
_lengthType;
|
|
5
|
-
constructor(_dictionaryType, _offsetType, _lengthType) {
|
|
6
|
-
this._dictionaryType = _dictionaryType;
|
|
7
|
-
this._offsetType = _offsetType;
|
|
8
|
-
this._lengthType = _lengthType;
|
|
9
|
-
}
|
|
10
|
-
get dictionaryType() {
|
|
11
|
-
return this._dictionaryType;
|
|
12
|
-
}
|
|
13
|
-
get offsetType() {
|
|
14
|
-
return this._offsetType;
|
|
15
|
-
}
|
|
16
|
-
get lengthType() {
|
|
17
|
-
return this._lengthType;
|
|
18
|
-
}
|
|
19
|
-
}
|
|
1
|
+
export {};
|
|
20
2
|
//# sourceMappingURL=logicalStreamType.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"logicalStreamType.js","sourceRoot":"","sources":["../../../src/metadata/tile/logicalStreamType.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"logicalStreamType.js","sourceRoot":"","sources":["../../../src/metadata/tile/logicalStreamType.ts"],"names":[],"mappings":"","sourcesContent":["import type { DictionaryType } from \"./dictionaryType\";\nimport type { OffsetType } from \"./offsetType\";\nimport type { LengthType } from \"./lengthType\";\n\nexport type LogicalStreamType = {\n readonly dictionaryType?: DictionaryType;\n readonly offsetType?: OffsetType;\n readonly lengthType?: LengthType;\n};\n"]}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { LogicalLevelTechnique } from "./logicalLevelTechnique";
|
|
2
2
|
import { PhysicalLevelTechnique } from "./physicalLevelTechnique";
|
|
3
3
|
import { PhysicalStreamType } from "./physicalStreamType";
|
|
4
|
-
import { LogicalStreamType } from "./logicalStreamType";
|
|
4
|
+
import type { LogicalStreamType } from "./logicalStreamType";
|
|
5
5
|
import type IntWrapper from "../../decoding/intWrapper";
|
|
6
6
|
export type StreamMetadata = {
|
|
7
7
|
readonly physicalStreamType: PhysicalStreamType;
|
|
@@ -2,7 +2,6 @@ import { LogicalLevelTechnique } from "./logicalLevelTechnique";
|
|
|
2
2
|
import { PhysicalLevelTechnique } from "./physicalLevelTechnique";
|
|
3
3
|
import { decodeVarintInt32 } from "../../decoding/integerDecodingUtils";
|
|
4
4
|
import { PhysicalStreamType } from "./physicalStreamType";
|
|
5
|
-
import { LogicalStreamType } from "./logicalStreamType";
|
|
6
5
|
import { DictionaryType } from "./dictionaryType";
|
|
7
6
|
import { OffsetType } from "./offsetType";
|
|
8
7
|
import { LengthType } from "./lengthType";
|
|
@@ -54,13 +53,19 @@ function decodeStreamMetadataInternal(tile, offset) {
|
|
|
54
53
|
let logicalStreamType = null;
|
|
55
54
|
switch (physicalStreamType) {
|
|
56
55
|
case PhysicalStreamType.DATA:
|
|
57
|
-
logicalStreamType =
|
|
56
|
+
logicalStreamType = {
|
|
57
|
+
dictionaryType: Object.values(DictionaryType)[stream_type & 0xf],
|
|
58
|
+
};
|
|
58
59
|
break;
|
|
59
60
|
case PhysicalStreamType.OFFSET:
|
|
60
|
-
logicalStreamType =
|
|
61
|
+
logicalStreamType = {
|
|
62
|
+
offsetType: Object.values(OffsetType)[stream_type & 0xf],
|
|
63
|
+
};
|
|
61
64
|
break;
|
|
62
65
|
case PhysicalStreamType.LENGTH:
|
|
63
|
-
logicalStreamType =
|
|
66
|
+
logicalStreamType = {
|
|
67
|
+
lengthType: Object.values(LengthType)[stream_type & 0xf],
|
|
68
|
+
};
|
|
64
69
|
break;
|
|
65
70
|
}
|
|
66
71
|
offset.increment();
|
|
@@ -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,
|
|
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,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AC,CAAC,gBAAgB,IAAI,CAAC,CAA0B,CAAC;IAClG,MAAM,IAAI,GAAG,MAAM,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,5 +1,5 @@
|
|
|
1
1
|
import type IntWrapper from "../../decoding/intWrapper";
|
|
2
|
-
import {
|
|
2
|
+
import type { Field, TileSetMetadata } from "./tilesetMetadata";
|
|
3
3
|
/**
|
|
4
4
|
* Decodes a Field used as part of complex types (STRUCT children).
|
|
5
5
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"embeddedTilesetMetadataDecoder.js","sourceRoot":"","sources":["../../../src/metadata/tileset/embeddedTilesetMetadataDecoder.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,iBAAiB,EAAE,MAAM,qCAAqC,CAAC;AAExE,OAAO,EAAE,qBAAqB,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,MAAM,WAAW,CAAC;AAEvF,MAAM,WAAW,GAAG,IAAI,WAAW,EAAE,CAAC;AAEtC,MAAM,sBAAsB,GAAG,kDAAkD,CAAC;AAClF,MAAM,qBAAqB,GAAG,4BAA4B,CAAC;AAE3D;;;GAGG;AACH,SAAS,YAAY,CAAC,GAAe,EAAE,MAAkB;IACrD,MAAM,MAAM,GAAG,iBAAiB,CAAC,GAAG,EAAE,MAAM,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;IACpD,IAAI,MAAM,KAAK,CAAC,EAAE,CAAC;QACf,OAAO,EAAE,CAAC;IACd,CAAC;IACD,MAAM,KAAK,GAAG,MAAM,CAAC,GAAG,EAAE,CAAC;IAC3B,MAAM,GAAG,GAAG,KAAK,GAAG,MAAM,CAAC;IAC3B,MAAM,IAAI,GAAG,GAAG,CAAC,QAAQ,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC;IACtC,MAAM,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;IACnB,OAAO,WAAW,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;AACpC,CAAC;AAED;;;GAGG;AACH,SAAS,aAAa,CAAC,MAAc;IACjC,OAAO;QACH,IAAI,EAAE,MAAM,CAAC,IAAI;QACjB,QAAQ,EAAE,MAAM,CAAC,QAAQ;QACzB,WAAW,EAAE,MAAM,CAAC,UAAU;QAC9B,YAAY,EAAE,MAAM,CAAC,WAAW;QAChC,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AAM,UAAU,6BAA6B,CAAC,KAAiB,EAAE,MAAkB;IAC/E,MAAM,IAAI,GAAG,EAAqB,CAAC;IACnC,IAAI,CAAC,aAAa,GAAG,EAAE,CAAC;IAExB,MAAM,KAAK,GAAG,EAAwB,CAAC;IACvC,KAAK,CAAC,IAAI,GAAG,YAAY,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC;IACzC,MAAM,MAAM,GAAG,iBAAiB,CAAC,KAAK,EAAE,MAAM,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC;IAE5D,MAAM,WAAW,GAAG,iBAAiB,CAAC,KAAK,EAAE,MAAM,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC;IACjE,KAAK,CAAC,OAAO,GAAG,IAAI,KAAK,CAAC,WAAW,CAAC,CAAC;IACvC,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,WAAW,EAAE,CAAC,EAAE,EAAE,CAAC;QACnC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,GAAG,YAAY,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC;IACnD,CAAC;IAED,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IAE/B,OAAO,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;AAC1B,CAAC","sourcesContent":["import type IntWrapper from \"../../decoding/intWrapper\";\nimport { decodeVarintInt32 } from \"../../decoding/integerDecodingUtils\";\nimport {
|
|
1
|
+
{"version":3,"file":"embeddedTilesetMetadataDecoder.js","sourceRoot":"","sources":["../../../src/metadata/tileset/embeddedTilesetMetadataDecoder.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,iBAAiB,EAAE,MAAM,qCAAqC,CAAC;AAExE,OAAO,EAAE,qBAAqB,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,MAAM,WAAW,CAAC;AAEvF,MAAM,WAAW,GAAG,IAAI,WAAW,EAAE,CAAC;AAEtC,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C,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC;IACjE,KAAK,CAAC,OAAO,GAAG,IAAI,KAAK,CAAC,WAAW,CAAC,CAAC;IACvC,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,WAAW,EAAE,CAAC,EAAE,EAAE,CAAC;QACnC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,GAAG,YAAY,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC;IACnD,CAAC;IAED,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IAE/B,OAAO,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;AAC1B,CAAC","sourcesContent":["import type IntWrapper from \"../../decoding/intWrapper\";\nimport { decodeVarintInt32 } from \"../../decoding/integerDecodingUtils\";\nimport type { Column, FeatureTableSchema, Field, TileSetMetadata } from \"./tilesetMetadata\";\nimport { columnTypeHasChildren, columnTypeHasName, decodeColumnType } from \"./typeMap\";\n\nconst textDecoder = new TextDecoder();\n\nconst SUPPORTED_COLUMN_TYPES = \"0-3(ID), 4(GEOMETRY), 10-29(scalars), 30(STRUCT)\";\nconst SUPPORTED_FIELD_TYPES = \"10-29(scalars), 30(STRUCT)\";\n\n/**\n * Decodes a length-prefixed UTF-8 string.\n * Layout: [len: varint32][bytes: len]\n */\nfunction decodeString(src: Uint8Array, offset: IntWrapper): string {\n const length = decodeVarintInt32(src, offset, 1)[0];\n if (length === 0) {\n return \"\";\n }\n const start = offset.get();\n const end = start + length;\n const view = src.subarray(start, end);\n offset.add(length);\n return textDecoder.decode(view);\n}\n\n/**\n * Converts a Column to a Field.\n * Used when decoding Field metadata which has the same format as Column.\n */\nfunction columnToField(column: Column): Field {\n return {\n name: column.name,\n nullable: column.nullable,\n scalarField: column.scalarType,\n complexField: column.complexType,\n type: column.type === \"scalarType\" ? \"scalarField\" : \"complexField\",\n };\n}\n\n/**\n * Decodes a Field used as part of complex types (STRUCT children).\n */\nexport function decodeField(src: Uint8Array, offset: IntWrapper): Field {\n const typeCode = decodeVarintInt32(src, offset, 1)[0] >>> 0;\n\n if (typeCode < 10 || typeCode > 30) {\n throw new Error(`Unsupported field type code ${typeCode}. Supported: ${SUPPORTED_FIELD_TYPES}`);\n }\n\n const column = decodeColumnType(typeCode);\n\n if (columnTypeHasName(typeCode)) {\n column.name = decodeString(src, offset);\n }\n\n if (columnTypeHasChildren(typeCode)) {\n const childCount = decodeVarintInt32(src, offset, 1)[0] >>> 0;\n column.complexType.children = new Array(childCount);\n for (let i = 0; i < childCount; i++) {\n column.complexType.children[i] = decodeField(src, offset);\n }\n }\n\n return columnToField(column);\n}\n\n/**\n * The typeCode encodes the column type, nullable flag, and whether it has name/children.\n */\nfunction decodeColumn(src: Uint8Array, offset: IntWrapper): Column {\n const typeCode = decodeVarintInt32(src, offset, 1)[0] >>> 0;\n const column = decodeColumnType(typeCode);\n\n if (!column) {\n throw new Error(`Unsupported column type code ${typeCode}. Supported: ${SUPPORTED_COLUMN_TYPES}`);\n }\n\n if (columnTypeHasName(typeCode)) {\n column.name = decodeString(src, offset);\n } else {\n // ID and GEOMETRY columns have implicit names\n if (typeCode >= 0 && typeCode <= 3) {\n column.name = \"id\";\n } else if (typeCode === 4) {\n column.name = \"geometry\";\n }\n }\n\n if (columnTypeHasChildren(typeCode)) {\n // Only STRUCT (typeCode 30) has children\n const childCount = decodeVarintInt32(src, offset, 1)[0] >>> 0;\n const complexCol = column.complexType;\n complexCol.children = new Array(childCount);\n for (let i = 0; i < childCount; i++) {\n complexCol.children[i] = decodeField(src, offset);\n }\n }\n\n return column;\n}\n\n/**\n * Top-level decoder for embedded tileset metadata.\n * Reads exactly ONE FeatureTableSchema from the stream.\n *\n * @param bytes The byte array containing the metadata\n * @param offset The current offset in the byte array (will be advanced)\n */\nexport function decodeEmbeddedTileSetMetadata(bytes: Uint8Array, offset: IntWrapper): [TileSetMetadata, number] {\n const meta = {} as TileSetMetadata;\n meta.featureTables = [];\n\n const table = {} as FeatureTableSchema;\n table.name = decodeString(bytes, offset);\n const extent = decodeVarintInt32(bytes, offset, 1)[0] >>> 0;\n\n const columnCount = decodeVarintInt32(bytes, offset, 1)[0] >>> 0;\n table.columns = new Array(columnCount);\n for (let j = 0; j < columnCount; j++) {\n table.columns[j] = decodeColumn(bytes, offset);\n }\n\n meta.featureTables.push(table);\n\n return [meta, extent];\n}\n"]}
|
|
@@ -9,7 +9,13 @@ import { type Column } from "./tilesetMetadata";
|
|
|
9
9
|
*/
|
|
10
10
|
/**
|
|
11
11
|
* Decodes a type code into a Column structure.
|
|
12
|
-
*
|
|
12
|
+
*
|
|
13
|
+
* ID type codes (0..3):
|
|
14
|
+
* - Bit 0: nullable
|
|
15
|
+
* - Bit 1: longID (0/1 -> uint32 IDs, 2/3 -> uint64 IDs)
|
|
16
|
+
*
|
|
17
|
+
* ID columns are kept as logical types so they remain distinguishable
|
|
18
|
+
* from feature properties that may also be named "id".
|
|
13
19
|
*/
|
|
14
20
|
export declare function decodeColumnType(typeCode: number): Column | null;
|
|
15
21
|
/**
|
|
@@ -25,6 +31,8 @@ export declare function columnTypeHasName(typeCode: number): boolean;
|
|
|
25
31
|
export declare function columnTypeHasChildren(typeCode: number): boolean;
|
|
26
32
|
/**
|
|
27
33
|
* Determines if a stream count needs to be read for this column.
|
|
28
|
-
* Mirrors the logic in cpp/include/mlt/metadata/type_map.hpp lines
|
|
34
|
+
* Mirrors the logic in cpp/include/mlt/metadata/type_map.hpp lines 85-122
|
|
29
35
|
*/
|
|
30
36
|
export declare function hasStreamCount(column: Column): boolean;
|
|
37
|
+
export declare function isLogicalIdColumn(column: Column): boolean;
|
|
38
|
+
export declare function isGeometryColumn(column: Column): boolean;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ColumnScope, ComplexType, ScalarType, } from "./tilesetMetadata";
|
|
1
|
+
import { ColumnScope, ComplexType, LogicalScalarType, ScalarType, } from "./tilesetMetadata";
|
|
2
2
|
/**
|
|
3
3
|
* The type code is a single varint32 that encodes:
|
|
4
4
|
* - Physical or logical type
|
|
@@ -9,7 +9,13 @@ import { ColumnScope, ComplexType, ScalarType, } from "./tilesetMetadata";
|
|
|
9
9
|
*/
|
|
10
10
|
/**
|
|
11
11
|
* Decodes a type code into a Column structure.
|
|
12
|
-
*
|
|
12
|
+
*
|
|
13
|
+
* ID type codes (0..3):
|
|
14
|
+
* - Bit 0: nullable
|
|
15
|
+
* - Bit 1: longID (0/1 -> uint32 IDs, 2/3 -> uint64 IDs)
|
|
16
|
+
*
|
|
17
|
+
* ID columns are kept as logical types so they remain distinguishable
|
|
18
|
+
* from feature properties that may also be named "id".
|
|
13
19
|
*/
|
|
14
20
|
export function decodeColumnType(typeCode) {
|
|
15
21
|
switch (typeCode) {
|
|
@@ -17,15 +23,13 @@ export function decodeColumnType(typeCode) {
|
|
|
17
23
|
case 1:
|
|
18
24
|
case 2:
|
|
19
25
|
case 3: {
|
|
20
|
-
// ID columns: 0=uint32, 1=uint64, 2=nullable uint32, 3=nullable uint64
|
|
21
26
|
const column = {};
|
|
22
|
-
column.nullable = (typeCode & 1) !== 0;
|
|
27
|
+
column.nullable = (typeCode & 1) !== 0;
|
|
23
28
|
column.columnScope = ColumnScope.FEATURE;
|
|
24
29
|
const scalarCol = {};
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
scalarCol.
|
|
28
|
-
scalarCol.type = "physicalType";
|
|
30
|
+
scalarCol.type = "logicalType";
|
|
31
|
+
scalarCol.logicalType = LogicalScalarType.ID;
|
|
32
|
+
scalarCol.longID = (typeCode & 2) !== 0;
|
|
29
33
|
column.scalarType = scalarCol;
|
|
30
34
|
column.type = "scalarType";
|
|
31
35
|
return column;
|
|
@@ -75,13 +79,9 @@ export function columnTypeHasChildren(typeCode) {
|
|
|
75
79
|
}
|
|
76
80
|
/**
|
|
77
81
|
* Determines if a stream count needs to be read for this column.
|
|
78
|
-
* Mirrors the logic in cpp/include/mlt/metadata/type_map.hpp lines
|
|
82
|
+
* Mirrors the logic in cpp/include/mlt/metadata/type_map.hpp lines 85-122
|
|
79
83
|
*/
|
|
80
84
|
export function hasStreamCount(column) {
|
|
81
|
-
// ID columns don't have stream count (identified by name)
|
|
82
|
-
if (column.name === "id") {
|
|
83
|
-
return false;
|
|
84
|
-
}
|
|
85
85
|
if (column.type === "scalarType") {
|
|
86
86
|
const scalarCol = column.scalarType;
|
|
87
87
|
if (scalarCol.type === "physicalType") {
|
|
@@ -103,7 +103,7 @@ export function hasStreamCount(column) {
|
|
|
103
103
|
return false;
|
|
104
104
|
}
|
|
105
105
|
}
|
|
106
|
-
|
|
106
|
+
if (scalarCol.type === "logicalType") {
|
|
107
107
|
return false;
|
|
108
108
|
}
|
|
109
109
|
}
|
|
@@ -123,13 +123,23 @@ export function hasStreamCount(column) {
|
|
|
123
123
|
console.warn("Unexpected column type in hasStreamCount", column);
|
|
124
124
|
return false;
|
|
125
125
|
}
|
|
126
|
+
export function isLogicalIdColumn(column) {
|
|
127
|
+
return (column.type === "scalarType" &&
|
|
128
|
+
column.scalarType?.type === "logicalType" &&
|
|
129
|
+
column.scalarType.logicalType === LogicalScalarType.ID);
|
|
130
|
+
}
|
|
131
|
+
export function isGeometryColumn(column) {
|
|
132
|
+
return (column.type === "complexType" &&
|
|
133
|
+
column.complexType?.type === "physicalType" &&
|
|
134
|
+
column.complexType.physicalType === ComplexType.GEOMETRY);
|
|
135
|
+
}
|
|
126
136
|
/**
|
|
127
137
|
* Maps a scalar type code to a Column with ScalarType.
|
|
128
138
|
* Type codes 10-29 encode scalar types with nullable flag.
|
|
129
139
|
* Even codes are non-nullable, odd codes are nullable.
|
|
130
140
|
*/
|
|
131
141
|
function mapScalarType(typeCode) {
|
|
132
|
-
let scalarType
|
|
142
|
+
let scalarType;
|
|
133
143
|
switch (typeCode) {
|
|
134
144
|
case 10:
|
|
135
145
|
case 11:
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"typeMap.js","sourceRoot":"","sources":["../../../src/metadata/tileset/typeMap.ts"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AC;IAC3B,MAAM,CAAC,UAAU,GAAG,SAAS,CAAC;IAC9B,OAAO,MAAM,CAAC;AAClB,CAAC","sourcesContent":["import {\n type Column,\n ColumnScope,\n type ComplexColumn,\n ComplexType,\n type ScalarColumn,\n ScalarType,\n} from \"./tilesetMetadata\";\n\n/**\n * The type code is a single varint32 that encodes:\n * - Physical or logical type\n * - Nullable flag\n * - Whether the column has a name (typeCode >= 10)\n * - Whether the column has children (typeCode == 30 for STRUCT)\n * - For ID types: whether it uses long (64-bit) IDs\n */\n\n/**\n * Decodes a type code into a Column structure.\n * ID columns (0-3) are represented as physical UINT_32 or UINT_64 types in TypeScript\n */\nexport function decodeColumnType(typeCode: number): Column | null {\n switch (typeCode) {\n case 0:\n case 1:\n case 2:\n case 3: {\n // ID columns: 0=uint32, 1=uint64, 2=nullable uint32, 3=nullable uint64\n const column = {} as Column;\n column.nullable = (typeCode & 1) !== 0; // Bit 0 = nullable;\n column.columnScope = ColumnScope.FEATURE;\n const scalarCol = {} as ScalarColumn;\n // Map to physical type since TS schema doesn't have LogicalScalarType.ID\n const physicalType = typeCode > 1 ? ScalarType.UINT_64 : ScalarType.UINT_32; // Bit 1 = longID\n scalarCol.physicalType = physicalType;\n scalarCol.type = \"physicalType\";\n column.scalarType = scalarCol;\n column.type = \"scalarType\";\n return column;\n }\n case 4: {\n // GEOMETRY (non-nullable, no children)\n const column = {} as Column;\n column.nullable = false;\n column.columnScope = ColumnScope.FEATURE;\n const complexCol = {} as ComplexColumn;\n complexCol.type = \"physicalType\";\n complexCol.physicalType = ComplexType.GEOMETRY;\n column.type = \"complexType\";\n column.complexType = complexCol;\n return column;\n }\n case 30: {\n // STRUCT (non-nullable with children)\n const column = {} as Column;\n column.nullable = false;\n column.columnScope = ColumnScope.FEATURE;\n const complexCol = {} as ComplexColumn;\n complexCol.type = \"physicalType\";\n complexCol.physicalType = ComplexType.STRUCT;\n column.type = \"complexType\";\n column.complexType = complexCol;\n return column;\n }\n default:\n return mapScalarType(typeCode);\n }\n}\n\n/**\n * Returns true if this type code requires a name to be stored.\n * ID (0-3) and GEOMETRY (4) columns have implicit names.\n * All other types (>= 10) require explicit names.\n */\nexport function columnTypeHasName(typeCode: number): boolean {\n return typeCode >= 10;\n}\n\n/**\n * Returns true if this type code has child fields.\n * Only STRUCT (typeCode 30) has children.\n */\nexport function columnTypeHasChildren(typeCode: number): boolean {\n return typeCode === 30;\n}\n\n/**\n * Determines if a stream count needs to be read for this column.\n * Mirrors the logic in cpp/include/mlt/metadata/type_map.hpp lines 81-118\n */\nexport function hasStreamCount(column: Column): boolean {\n // ID columns don't have stream count (identified by name)\n if (column.name === \"id\") {\n return false;\n }\n\n if (column.type === \"scalarType\") {\n const scalarCol = column.scalarType;\n\n if (scalarCol.type === \"physicalType\") {\n const physicalType = scalarCol.physicalType;\n switch (physicalType) {\n case ScalarType.BOOLEAN:\n case ScalarType.INT_8:\n case ScalarType.UINT_8:\n case ScalarType.INT_32:\n case ScalarType.UINT_32:\n case ScalarType.INT_64:\n case ScalarType.UINT_64:\n case ScalarType.FLOAT:\n case ScalarType.DOUBLE:\n return false;\n case ScalarType.STRING:\n return true;\n default:\n return false;\n }\n } else if (scalarCol.type === \"logicalType\") {\n return false;\n }\n } else if (column.type === \"complexType\") {\n const complexCol = column.complexType;\n\n if (complexCol.type === \"physicalType\") {\n const physicalType = complexCol.physicalType;\n switch (physicalType) {\n case ComplexType.GEOMETRY:\n case ComplexType.STRUCT:\n return true;\n default:\n return false;\n }\n }\n }\n\n console.warn(\"Unexpected column type in hasStreamCount\", column);\n return false;\n}\n\n/**\n * Maps a scalar type code to a Column with ScalarType.\n * Type codes 10-29 encode scalar types with nullable flag.\n * Even codes are non-nullable, odd codes are nullable.\n */\nfunction mapScalarType(typeCode: number): Column | null {\n let scalarType: number | null = null;\n\n switch (typeCode) {\n case 10:\n case 11:\n scalarType = ScalarType.BOOLEAN;\n break;\n case 12:\n case 13:\n scalarType = ScalarType.INT_8;\n break;\n case 14:\n case 15:\n scalarType = ScalarType.UINT_8;\n break;\n case 16:\n case 17:\n scalarType = ScalarType.INT_32;\n break;\n case 18:\n case 19:\n scalarType = ScalarType.UINT_32;\n break;\n case 20:\n case 21:\n scalarType = ScalarType.INT_64;\n break;\n case 22:\n case 23:\n scalarType = ScalarType.UINT_64;\n break;\n case 24:\n case 25:\n scalarType = ScalarType.FLOAT;\n break;\n case 26:\n case 27:\n scalarType = ScalarType.DOUBLE;\n break;\n case 28:\n case 29:\n scalarType = ScalarType.STRING;\n break;\n default:\n return null;\n }\n\n const column = {} as Column;\n column.nullable = (typeCode & 1) !== 0;\n column.columnScope = ColumnScope.FEATURE;\n const scalarCol = {} as ScalarColumn;\n scalarCol.type = \"physicalType\";\n scalarCol.physicalType = scalarType;\n column.type = \"scalarType\";\n column.scalarType = scalarCol;\n return column;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"typeMap.js","sourceRoot":"","sources":["../../../src/metadata/tileset/typeMap.ts"],"names":[],"mappings":"AAAA,OAAO,EAEH,WAAW,EAEX,WAAW,EACX,iBAAiB,EAEjB,UAAU,GACb,MAAM,mBAAmB,CAAC;AAE3B;;;;;;;GAOG;AAEH;;;;;;;;;GASG;AACH,MAAM,UAAU,gBAAgB,CAAC,QAAgB;IAC7C,QAAQ,QAAQ,EAAE,CAAC;QACf,KAAK,CAAC,CAAC;QACP,KAAK,CAAC,CAAC;QACP,KAAK,CAAC,CAAC;QACP,KAAK,CAAC,CAAC,CAAC,CAAC;YACL,MAAM,MAAM,GAAG,EAAY,CAAC;YAC5B,MAAM,CAAC,QAAQ,GAAG,CAAC,QAAQ,GAAG,CAAC,CAAC,KAAK,CAAC,CAAC;YACvC,MAAM,CAAC,WAAW,GAAG,WAAW,CAAC,OAAO,CAAC;YACzC,MAAM,SAAS,GAAG,EAAkB,CAAC;YACrC,SAAS,CAAC,IAAI,GAAG,aAAa,CAAC;YAC/B,SAAS,CAAC,WAAW,GAAG,iBAAiB,CAAC,EAAE,CAAC;YAC7C,SAAS,C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AChC,MAAM;QACV,KAAK,EAAE,CAAC;QACR,KAAK,EAAE;YACH,UAAU,GAAG,UAAU,CAAC,MAAM,CAAC;YAC/B,MAAM;QACV,KAAK,EAAE,CAAC;QACR,KAAK,EAAE;YACH,UAAU,GAAG,UAAU,CAAC,OAAO,CAAC;YAChC,MAAM;QACV,KAAK,EAAE,CAAC;QACR,KAAK,EAAE;YACH,UAAU,GAAG,UAAU,CAAC,KAAK,CAAC;YAC9B,MAAM;QACV,KAAK,EAAE,CAAC;QACR,KAAK,EAAE;YACH,UAAU,GAAG,UAAU,CAAC,MAAM,CAAC;YAC/B,MAAM;QACV,KAAK,EAAE,CAAC;QACR,KAAK,EAAE;YACH,UAAU,GAAG,UAAU,CAAC,MAAM,CAAC;YAC/B,MAAM;QACV;YACI,OAAO,IAAI,CAAC;IACpB,CAAC;IAED,MAAM,MAAM,GAAG,EAAY,CAAC;IAC5B,MAAM,CAAC,QAAQ,GAAG,CAAC,QAAQ,GAAG,CAAC,CAAC,KAAK,CAAC,CAAC;IACvC,MAAM,CAAC,WAAW,GAAG,WAAW,CAAC,OAAO,CAAC;IACzC,MAAM,SAAS,GAAG,EAAkB,CAAC;IACrC,SAAS,CAAC,IAAI,GAAG,cAAc,CAAC;IAChC,SAAS,CAAC,YAAY,GAAG,UAAU,CAAC;IACpC,MAAM,CAAC,IAAI,GAAG,YAAY,CAAC;IAC3B,MAAM,CAAC,UAAU,GAAG,SAAS,CAAC;IAC9B,OAAO,MAAM,CAAC;AAClB,CAAC","sourcesContent":["import {\n type Column,\n ColumnScope,\n type ComplexColumn,\n ComplexType,\n LogicalScalarType,\n type ScalarColumn,\n ScalarType,\n} from \"./tilesetMetadata\";\n\n/**\n * The type code is a single varint32 that encodes:\n * - Physical or logical type\n * - Nullable flag\n * - Whether the column has a name (typeCode >= 10)\n * - Whether the column has children (typeCode == 30 for STRUCT)\n * - For ID types: whether it uses long (64-bit) IDs\n */\n\n/**\n * Decodes a type code into a Column structure.\n *\n * ID type codes (0..3):\n * - Bit 0: nullable\n * - Bit 1: longID (0/1 -> uint32 IDs, 2/3 -> uint64 IDs)\n *\n * ID columns are kept as logical types so they remain distinguishable\n * from feature properties that may also be named \"id\".\n */\nexport function decodeColumnType(typeCode: number): Column | null {\n switch (typeCode) {\n case 0:\n case 1:\n case 2:\n case 3: {\n const column = {} as Column;\n column.nullable = (typeCode & 1) !== 0;\n column.columnScope = ColumnScope.FEATURE;\n const scalarCol = {} as ScalarColumn;\n scalarCol.type = \"logicalType\";\n scalarCol.logicalType = LogicalScalarType.ID;\n scalarCol.longID = (typeCode & 2) !== 0;\n column.scalarType = scalarCol;\n column.type = \"scalarType\";\n return column;\n }\n case 4: {\n // GEOMETRY (non-nullable, no children)\n const column = {} as Column;\n column.nullable = false;\n column.columnScope = ColumnScope.FEATURE;\n const complexCol = {} as ComplexColumn;\n complexCol.type = \"physicalType\";\n complexCol.physicalType = ComplexType.GEOMETRY;\n column.type = \"complexType\";\n column.complexType = complexCol;\n return column;\n }\n case 30: {\n // STRUCT (non-nullable with children)\n const column = {} as Column;\n column.nullable = false;\n column.columnScope = ColumnScope.FEATURE;\n const complexCol = {} as ComplexColumn;\n complexCol.type = \"physicalType\";\n complexCol.physicalType = ComplexType.STRUCT;\n column.type = \"complexType\";\n column.complexType = complexCol;\n return column;\n }\n default:\n return mapScalarType(typeCode);\n }\n}\n\n/**\n * Returns true if this type code requires a name to be stored.\n * ID (0-3) and GEOMETRY (4) columns have implicit names.\n * All other types (>= 10) require explicit names.\n */\nexport function columnTypeHasName(typeCode: number): boolean {\n return typeCode >= 10;\n}\n\n/**\n * Returns true if this type code has child fields.\n * Only STRUCT (typeCode 30) has children.\n */\nexport function columnTypeHasChildren(typeCode: number): boolean {\n return typeCode === 30;\n}\n\n/**\n * Determines if a stream count needs to be read for this column.\n * Mirrors the logic in cpp/include/mlt/metadata/type_map.hpp lines 85-122\n */\nexport function hasStreamCount(column: Column): boolean {\n if (column.type === \"scalarType\") {\n const scalarCol = column.scalarType;\n\n if (scalarCol.type === \"physicalType\") {\n const physicalType = scalarCol.physicalType;\n switch (physicalType) {\n case ScalarType.BOOLEAN:\n case ScalarType.INT_8:\n case ScalarType.UINT_8:\n case ScalarType.INT_32:\n case ScalarType.UINT_32:\n case ScalarType.INT_64:\n case ScalarType.UINT_64:\n case ScalarType.FLOAT:\n case ScalarType.DOUBLE:\n return false;\n case ScalarType.STRING:\n return true;\n default:\n return false;\n }\n }\n if (scalarCol.type === \"logicalType\") {\n return false;\n }\n } else if (column.type === \"complexType\") {\n const complexCol = column.complexType;\n\n if (complexCol.type === \"physicalType\") {\n const physicalType = complexCol.physicalType;\n switch (physicalType) {\n case ComplexType.GEOMETRY:\n case ComplexType.STRUCT:\n return true;\n default:\n return false;\n }\n }\n }\n\n console.warn(\"Unexpected column type in hasStreamCount\", column);\n return false;\n}\n\nexport function isLogicalIdColumn(column: Column): boolean {\n return (\n column.type === \"scalarType\" &&\n column.scalarType?.type === \"logicalType\" &&\n column.scalarType.logicalType === LogicalScalarType.ID\n );\n}\n\nexport function isGeometryColumn(column: Column): boolean {\n return (\n column.type === \"complexType\" &&\n column.complexType?.type === \"physicalType\" &&\n column.complexType.physicalType === ComplexType.GEOMETRY\n );\n}\n\n/**\n * Maps a scalar type code to a Column with ScalarType.\n * Type codes 10-29 encode scalar types with nullable flag.\n * Even codes are non-nullable, odd codes are nullable.\n */\nfunction mapScalarType(typeCode: number): Column | null {\n let scalarType: number | null;\n\n switch (typeCode) {\n case 10:\n case 11:\n scalarType = ScalarType.BOOLEAN;\n break;\n case 12:\n case 13:\n scalarType = ScalarType.INT_8;\n break;\n case 14:\n case 15:\n scalarType = ScalarType.UINT_8;\n break;\n case 16:\n case 17:\n scalarType = ScalarType.INT_32;\n break;\n case 18:\n case 19:\n scalarType = ScalarType.UINT_32;\n break;\n case 20:\n case 21:\n scalarType = ScalarType.INT_64;\n break;\n case 22:\n case 23:\n scalarType = ScalarType.UINT_64;\n break;\n case 24:\n case 25:\n scalarType = ScalarType.FLOAT;\n break;\n case 26:\n case 27:\n scalarType = ScalarType.DOUBLE;\n break;\n case 28:\n case 29:\n scalarType = ScalarType.STRING;\n break;\n default:\n return null;\n }\n\n const column = {} as Column;\n column.nullable = (typeCode & 1) !== 0;\n column.columnScope = ColumnScope.FEATURE;\n const scalarCol = {} as ScalarColumn;\n scalarCol.type = \"physicalType\";\n scalarCol.physicalType = scalarType;\n column.type = \"scalarType\";\n column.scalarType = scalarCol;\n return column;\n}\n"]}
|