@deck.gl/carto 8.8.0-alpha.2 → 8.8.0-alpha.5
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/dist.dev.js +1752 -1262
- package/dist/es5/api/layer-map.js +17 -5
- package/dist/es5/api/layer-map.js.map +1 -1
- package/dist/es5/api/maps-api-common.js +1 -0
- package/dist/es5/api/maps-api-common.js.map +1 -1
- package/dist/es5/api/parseMap.js +14 -3
- package/dist/es5/api/parseMap.js.map +1 -1
- package/dist/es5/index.js +16 -0
- package/dist/es5/index.js.map +1 -1
- package/dist/es5/layers/carto-layer.js +16 -1
- package/dist/es5/layers/carto-layer.js.map +1 -1
- package/dist/es5/layers/carto-tile-layer.js +17 -12
- package/dist/es5/layers/carto-tile-layer.js.map +1 -1
- package/dist/es5/layers/h3-tile-layer.js +107 -0
- package/dist/es5/layers/h3-tile-layer.js.map +1 -0
- package/dist/es5/layers/h3-tileset-2d.js +175 -0
- package/dist/es5/layers/h3-tileset-2d.js.map +1 -0
- package/dist/es5/layers/quadkey-tile-layer.js +103 -0
- package/dist/es5/layers/quadkey-tile-layer.js.map +1 -0
- package/dist/es5/layers/quadkey-tileset-2d.js +89 -0
- package/dist/es5/layers/quadkey-tileset-2d.js.map +1 -0
- package/dist/es5/layers/schema/carto-tile.js +261 -188
- package/dist/es5/layers/schema/carto-tile.js.map +1 -1
- package/dist/es5/layers/spatial-index-tile-layer.js +92 -0
- package/dist/es5/layers/spatial-index-tile-layer.js.map +1 -0
- package/dist/esm/api/layer-map.js +12 -4
- package/dist/esm/api/layer-map.js.map +1 -1
- package/dist/esm/api/maps-api-common.js +1 -0
- package/dist/esm/api/maps-api-common.js.map +1 -1
- package/dist/esm/api/parseMap.js +15 -4
- package/dist/esm/api/parseMap.js.map +1 -1
- package/dist/esm/index.js +2 -0
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/layers/carto-layer.js +15 -2
- package/dist/esm/layers/carto-layer.js.map +1 -1
- package/dist/esm/layers/carto-tile-layer.js +20 -16
- package/dist/esm/layers/carto-tile-layer.js.map +1 -1
- package/dist/esm/layers/h3-tile-layer.js +69 -0
- package/dist/esm/layers/h3-tile-layer.js.map +1 -0
- package/dist/esm/layers/h3-tileset-2d.js +118 -0
- package/dist/esm/layers/h3-tileset-2d.js.map +1 -0
- package/dist/esm/layers/quadkey-tile-layer.js +63 -0
- package/dist/esm/layers/quadkey-tile-layer.js.map +1 -0
- package/dist/esm/layers/quadkey-tileset-2d.js +48 -0
- package/dist/esm/layers/quadkey-tileset-2d.js.map +1 -0
- package/dist/esm/layers/schema/carto-tile.js +174 -189
- package/dist/esm/layers/schema/carto-tile.js.map +1 -1
- package/dist/esm/layers/spatial-index-tile-layer.js +57 -0
- package/dist/esm/layers/spatial-index-tile-layer.js.map +1 -0
- package/dist.min.js +14 -14
- package/package.json +5 -3
- package/src/api/layer-map.ts +14 -4
- package/src/api/maps-api-common.ts +1 -0
- package/src/api/parseMap.ts +20 -5
- package/src/index.ts +2 -0
- package/src/layers/carto-layer.ts +16 -2
- package/src/layers/{carto-tile-layer.js → carto-tile-layer.ts} +64 -27
- package/src/layers/h3-tile-layer.js +52 -0
- package/src/layers/h3-tileset-2d.js +108 -0
- package/src/layers/quadkey-tile-layer.js +47 -0
- package/src/layers/quadkey-tileset-2d.js +36 -0
- package/src/layers/schema/carto-tile.ts +221 -0
- package/src/layers/spatial-index-tile-layer.js +48 -0
- package/src/layers/schema/carto-tile.js +0 -195
|
@@ -0,0 +1,221 @@
|
|
|
1
|
+
// KeyValueObject ========================================
|
|
2
|
+
interface KeyValueObject {
|
|
3
|
+
key: string;
|
|
4
|
+
value: string;
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
class KeyValueObjectReader {
|
|
8
|
+
static read(pbf, end?: number): KeyValueObject {
|
|
9
|
+
return pbf.readFields(KeyValueObjectReader._readField, {key: '', value: ''}, end);
|
|
10
|
+
}
|
|
11
|
+
static _readField(this: void, tag: number, obj: KeyValueObject, pbf) {
|
|
12
|
+
if (tag === 1) obj.key = pbf.readString();
|
|
13
|
+
else if (tag === 2) obj.value = pbf.readString();
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
// Properties ========================================
|
|
18
|
+
|
|
19
|
+
export interface Properties {
|
|
20
|
+
data: KeyValueObject[];
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
class PropertiesReader {
|
|
24
|
+
static read(pbf, end?: number) {
|
|
25
|
+
return pbf.readFields(PropertiesReader._readField, {data: []}, end);
|
|
26
|
+
}
|
|
27
|
+
static _readField(this: void, tag: number, obj: Properties, pbf) {
|
|
28
|
+
if (tag === 1) obj.data.push(KeyValueObjectReader.read(pbf, pbf.readVarint() + pbf.pos));
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
// Doubles ========================================
|
|
33
|
+
|
|
34
|
+
interface Doubles {
|
|
35
|
+
value: Float32Array;
|
|
36
|
+
size: number;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
class DoublesReader {
|
|
40
|
+
static read(pbf, end?: number): Doubles {
|
|
41
|
+
// TODO perhaps we can do better and directly map from the source
|
|
42
|
+
// ArrayBuffer using ArrayBuffer.slice()
|
|
43
|
+
const {value, size} = pbf.readFields(DoublesReader._readField, {value: [], size: 0}, end);
|
|
44
|
+
return {value: new Float32Array(value), size};
|
|
45
|
+
}
|
|
46
|
+
static _readField(this: void, tag: number, obj, pbf) {
|
|
47
|
+
if (tag === 1) pbf.readPackedDouble(obj.value);
|
|
48
|
+
else if (tag === 2) obj.size = pbf.readVarint(true);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
// Ints ========================================
|
|
53
|
+
|
|
54
|
+
interface Ints {
|
|
55
|
+
value: Uint32Array;
|
|
56
|
+
size: number;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
class IntsReader {
|
|
60
|
+
static read(pbf, end?: number): Ints {
|
|
61
|
+
const {value, size} = pbf.readFields(IntsReader._readField, {value: [], size: 0}, end);
|
|
62
|
+
return {value: new Uint32Array(value), size};
|
|
63
|
+
}
|
|
64
|
+
static _readField(this: void, tag: number, obj, pbf) {
|
|
65
|
+
if (tag === 1) pbf.readPackedVarint(obj.value);
|
|
66
|
+
else if (tag === 2) obj.size = pbf.readVarint(true);
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
// NumericProp ========================================
|
|
71
|
+
|
|
72
|
+
interface NumericProp {
|
|
73
|
+
value: number[];
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
class NumericPropReader {
|
|
77
|
+
static read(pbf, end?: number): NumericProp {
|
|
78
|
+
return pbf.readFields(NumericPropReader._readField, {value: []}, end);
|
|
79
|
+
}
|
|
80
|
+
static _readField(this: void, tag: number, obj: NumericProp, pbf) {
|
|
81
|
+
if (tag === 1) pbf.readPackedDouble(obj.value);
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
// NumericPropKeyValue ========================================
|
|
86
|
+
interface NumbericPropKeyValue {
|
|
87
|
+
key: string;
|
|
88
|
+
value: NumericProp;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
class NumericPropKeyValueReader {
|
|
92
|
+
static read(pbf, end?: number): NumbericPropKeyValue {
|
|
93
|
+
return pbf.readFields(NumericPropKeyValueReader._readField, {key: '', value: null}, end);
|
|
94
|
+
}
|
|
95
|
+
static _readField(this: void, tag: number, obj: NumbericPropKeyValue, pbf) {
|
|
96
|
+
if (tag === 1) obj.key = pbf.readString();
|
|
97
|
+
else if (tag === 2) obj.value = NumericPropReader.read(pbf, pbf.readVarint() + pbf.pos);
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
// Points ========================================
|
|
102
|
+
|
|
103
|
+
interface Points {
|
|
104
|
+
positions: Doubles;
|
|
105
|
+
globalFeatureIds: Ints;
|
|
106
|
+
featureIds: Ints;
|
|
107
|
+
properties: Properties[];
|
|
108
|
+
numericProps: Record<string, NumericProp>;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
class PointsReader {
|
|
112
|
+
static read(pbf, end?: number): Points {
|
|
113
|
+
return pbf.readFields(
|
|
114
|
+
PointsReader._readField,
|
|
115
|
+
{positions: null, globalFeatureIds: null, featureIds: null, properties: [], numericProps: {}},
|
|
116
|
+
end
|
|
117
|
+
);
|
|
118
|
+
}
|
|
119
|
+
static _readField(this: void, tag: number, obj: Points, pbf) {
|
|
120
|
+
if (tag === 1) obj.positions = DoublesReader.read(pbf, pbf.readVarint() + pbf.pos);
|
|
121
|
+
else if (tag === 2) obj.globalFeatureIds = IntsReader.read(pbf, pbf.readVarint() + pbf.pos);
|
|
122
|
+
else if (tag === 3) obj.featureIds = IntsReader.read(pbf, pbf.readVarint() + pbf.pos);
|
|
123
|
+
else if (tag === 4) obj.properties.push(PropertiesReader.read(pbf, pbf.readVarint() + pbf.pos));
|
|
124
|
+
else if (tag === 5) {
|
|
125
|
+
const entry = NumericPropKeyValueReader.read(pbf, pbf.readVarint() + pbf.pos);
|
|
126
|
+
obj.numericProps[entry.key] = entry.value;
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
interface Lines extends Points {
|
|
132
|
+
pathIndices: Ints;
|
|
133
|
+
}
|
|
134
|
+
// Lines ========================================
|
|
135
|
+
|
|
136
|
+
class LinesReader {
|
|
137
|
+
static read(pbf, end?: number): Lines {
|
|
138
|
+
return pbf.readFields(
|
|
139
|
+
LinesReader._readField,
|
|
140
|
+
{
|
|
141
|
+
positions: null,
|
|
142
|
+
pathIndices: null,
|
|
143
|
+
globalFeatureIds: null,
|
|
144
|
+
featureIds: null,
|
|
145
|
+
properties: [],
|
|
146
|
+
numericProps: {}
|
|
147
|
+
},
|
|
148
|
+
end
|
|
149
|
+
);
|
|
150
|
+
}
|
|
151
|
+
static _readField(this: void, tag: number, obj: Lines, pbf) {
|
|
152
|
+
if (tag === 1) obj.positions = DoublesReader.read(pbf, pbf.readVarint() + pbf.pos);
|
|
153
|
+
else if (tag === 2) obj.pathIndices = IntsReader.read(pbf, pbf.readVarint() + pbf.pos);
|
|
154
|
+
else if (tag === 3) obj.globalFeatureIds = IntsReader.read(pbf, pbf.readVarint() + pbf.pos);
|
|
155
|
+
else if (tag === 4) obj.featureIds = IntsReader.read(pbf, pbf.readVarint() + pbf.pos);
|
|
156
|
+
else if (tag === 5) obj.properties.push(PropertiesReader.read(pbf, pbf.readVarint() + pbf.pos));
|
|
157
|
+
else if (tag === 6) {
|
|
158
|
+
const entry = NumericPropKeyValueReader.read(pbf, pbf.readVarint() + pbf.pos);
|
|
159
|
+
obj.numericProps[entry.key] = entry.value;
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
// Polygons ========================================
|
|
164
|
+
|
|
165
|
+
interface Polygons extends Points {
|
|
166
|
+
polygonIndices: Ints;
|
|
167
|
+
primitivePolygonIndices: Ints;
|
|
168
|
+
triangles: Ints;
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
class PolygonsReader {
|
|
172
|
+
static read(pbf, end?: number): Polygons {
|
|
173
|
+
return pbf.readFields(
|
|
174
|
+
PolygonsReader._readField,
|
|
175
|
+
{
|
|
176
|
+
positions: null,
|
|
177
|
+
polygonIndices: null,
|
|
178
|
+
globalFeatureIds: null,
|
|
179
|
+
featureIds: null,
|
|
180
|
+
primitivePolygonIndices: null,
|
|
181
|
+
triangles: null,
|
|
182
|
+
properties: [],
|
|
183
|
+
numericProps: {}
|
|
184
|
+
},
|
|
185
|
+
end
|
|
186
|
+
);
|
|
187
|
+
}
|
|
188
|
+
static _readField(this: void, tag: number, obj: Polygons, pbf) {
|
|
189
|
+
if (tag === 1) obj.positions = DoublesReader.read(pbf, pbf.readVarint() + pbf.pos);
|
|
190
|
+
else if (tag === 2) obj.polygonIndices = IntsReader.read(pbf, pbf.readVarint() + pbf.pos);
|
|
191
|
+
else if (tag === 3) obj.globalFeatureIds = IntsReader.read(pbf, pbf.readVarint() + pbf.pos);
|
|
192
|
+
else if (tag === 4) obj.featureIds = IntsReader.read(pbf, pbf.readVarint() + pbf.pos);
|
|
193
|
+
else if (tag === 5)
|
|
194
|
+
obj.primitivePolygonIndices = IntsReader.read(pbf, pbf.readVarint() + pbf.pos);
|
|
195
|
+
else if (tag === 6) obj.triangles = IntsReader.read(pbf, pbf.readVarint() + pbf.pos);
|
|
196
|
+
else if (tag === 7) obj.properties.push(PropertiesReader.read(pbf, pbf.readVarint() + pbf.pos));
|
|
197
|
+
else if (tag === 8) {
|
|
198
|
+
const entry = NumericPropKeyValueReader.read(pbf, pbf.readVarint() + pbf.pos);
|
|
199
|
+
obj.numericProps[entry.key] = entry.value;
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
// Tile ========================================
|
|
205
|
+
|
|
206
|
+
export interface Tile {
|
|
207
|
+
points: Points;
|
|
208
|
+
lines: Lines;
|
|
209
|
+
polygons: Polygons;
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
export class TileReader {
|
|
213
|
+
static read(pbf, end?: number): Tile {
|
|
214
|
+
return pbf.readFields(TileReader._readField, {points: null, lines: null, polygons: null}, end);
|
|
215
|
+
}
|
|
216
|
+
static _readField(this: void, tag: number, obj: Tile, pbf) {
|
|
217
|
+
if (tag === 1) obj.points = PointsReader.read(pbf, pbf.readVarint() + pbf.pos);
|
|
218
|
+
else if (tag === 2) obj.lines = LinesReader.read(pbf, pbf.readVarint() + pbf.pos);
|
|
219
|
+
else if (tag === 3) obj.polygons = PolygonsReader.read(pbf, pbf.readVarint() + pbf.pos);
|
|
220
|
+
}
|
|
221
|
+
}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import {TileLayer} from '@deck.gl/geo-layers';
|
|
2
|
+
|
|
3
|
+
function isFeatureIdDefined(value) {
|
|
4
|
+
return value !== undefined && value !== null && value !== '';
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
export default class SpatialIndexTileLayer extends TileLayer {
|
|
8
|
+
_updateAutoHighlight(info) {
|
|
9
|
+
const {hoveredFeatureId} = this.state;
|
|
10
|
+
const hoveredFeature = info.object;
|
|
11
|
+
let newHoveredFeatureId;
|
|
12
|
+
|
|
13
|
+
if (hoveredFeature) {
|
|
14
|
+
newHoveredFeatureId = hoveredFeature.id;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
if (hoveredFeatureId !== newHoveredFeatureId) {
|
|
18
|
+
let {highlightColor} = this.props;
|
|
19
|
+
if (typeof highlightColor === 'function') {
|
|
20
|
+
highlightColor = highlightColor(info);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
this.setState({
|
|
24
|
+
highlightColor,
|
|
25
|
+
hoveredFeatureId: newHoveredFeatureId
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
getSubLayerPropsByTile(tile) {
|
|
31
|
+
return {
|
|
32
|
+
highlightedObjectIndex: this.getHighlightedObjectIndex(tile),
|
|
33
|
+
highlightColor: this.state.highlightColor
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
getHighlightedObjectIndex(tile) {
|
|
38
|
+
const {hoveredFeatureId} = this.state;
|
|
39
|
+
const data = tile.content;
|
|
40
|
+
|
|
41
|
+
const isFeatureIdPresent = isFeatureIdDefined(hoveredFeatureId);
|
|
42
|
+
if (!isFeatureIdPresent || !Array.isArray(data)) {
|
|
43
|
+
return -1;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
return data.findIndex(feature => feature.id === hoveredFeatureId);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
@@ -1,195 +0,0 @@
|
|
|
1
|
-
// KeyValueObject ========================================
|
|
2
|
-
|
|
3
|
-
const KeyValueObject = {};
|
|
4
|
-
|
|
5
|
-
KeyValueObject.read = function (pbf, end) {
|
|
6
|
-
return pbf.readFields(KeyValueObject._readField, {key: '', value: ''}, end);
|
|
7
|
-
};
|
|
8
|
-
KeyValueObject._readField = function (tag, obj, pbf) {
|
|
9
|
-
if (tag === 1) obj.key = pbf.readString();
|
|
10
|
-
else if (tag === 2) obj.value = pbf.readString();
|
|
11
|
-
};
|
|
12
|
-
|
|
13
|
-
// Properties ========================================
|
|
14
|
-
|
|
15
|
-
const Properties = {};
|
|
16
|
-
|
|
17
|
-
Properties.read = function (pbf, end) {
|
|
18
|
-
return pbf.readFields(Properties._readField, {data: []}, end);
|
|
19
|
-
};
|
|
20
|
-
Properties._readField = function (tag, obj, pbf) {
|
|
21
|
-
if (tag === 1) obj.data.push(KeyValueObject.read(pbf, pbf.readVarint() + pbf.pos));
|
|
22
|
-
};
|
|
23
|
-
|
|
24
|
-
// Doubles ========================================
|
|
25
|
-
|
|
26
|
-
const Doubles = {};
|
|
27
|
-
|
|
28
|
-
Doubles.read = function (pbf, end) {
|
|
29
|
-
// TODO perhaps we can do better and directly map from the source
|
|
30
|
-
// ArrayBuffer using ArrayBuffer.slice()
|
|
31
|
-
const {value, size} = pbf.readFields(Doubles._readField, {value: [], size: 0}, end);
|
|
32
|
-
return {value: new Float32Array(value), size};
|
|
33
|
-
};
|
|
34
|
-
Doubles._readField = function (tag, obj, pbf) {
|
|
35
|
-
if (tag === 1) pbf.readPackedDouble(obj.value);
|
|
36
|
-
else if (tag === 2) obj.size = pbf.readVarint(true);
|
|
37
|
-
};
|
|
38
|
-
|
|
39
|
-
// Ints ========================================
|
|
40
|
-
|
|
41
|
-
const Ints = {};
|
|
42
|
-
|
|
43
|
-
Ints.read = function (pbf, end) {
|
|
44
|
-
const {value, size} = pbf.readFields(Ints._readField, {value: [], size: 0}, end);
|
|
45
|
-
return {value: new Uint32Array(value), size};
|
|
46
|
-
};
|
|
47
|
-
Ints._readField = function (tag, obj, pbf) {
|
|
48
|
-
if (tag === 1) pbf.readPackedVarint(obj.value);
|
|
49
|
-
else if (tag === 2) obj.size = pbf.readVarint(true);
|
|
50
|
-
};
|
|
51
|
-
|
|
52
|
-
// NumericProp ========================================
|
|
53
|
-
|
|
54
|
-
const NumericProp = {};
|
|
55
|
-
|
|
56
|
-
NumericProp.read = function (pbf, end) {
|
|
57
|
-
return pbf.readFields(NumericProp._readField, {value: []}, end);
|
|
58
|
-
};
|
|
59
|
-
NumericProp._readField = function (tag, obj, pbf) {
|
|
60
|
-
if (tag === 1) pbf.readPackedDouble(obj.value);
|
|
61
|
-
};
|
|
62
|
-
|
|
63
|
-
// NumericPropKeyValue ========================================
|
|
64
|
-
|
|
65
|
-
const NumericPropKeyValue = {};
|
|
66
|
-
|
|
67
|
-
NumericPropKeyValue.read = function (pbf, end) {
|
|
68
|
-
return pbf.readFields(NumericPropKeyValue._readField, {key: '', value: null}, end);
|
|
69
|
-
};
|
|
70
|
-
NumericPropKeyValue._readField = function (tag, obj, pbf) {
|
|
71
|
-
if (tag === 1) obj.key = pbf.readString();
|
|
72
|
-
else if (tag === 2) obj.value = NumericProp.read(pbf, pbf.readVarint() + pbf.pos);
|
|
73
|
-
};
|
|
74
|
-
|
|
75
|
-
// NumericProp._FieldEntry1 ========================================
|
|
76
|
-
|
|
77
|
-
NumericProp._FieldEntry1 = {};
|
|
78
|
-
|
|
79
|
-
NumericProp._FieldEntry1.read = function (pbf, end) {
|
|
80
|
-
return pbf.readFields(NumericProp._FieldEntry1._readField, {key: '', value: 0}, end);
|
|
81
|
-
};
|
|
82
|
-
NumericProp._FieldEntry1._readField = function (tag, obj, pbf) {
|
|
83
|
-
if (tag === 1) obj.key = pbf.readString();
|
|
84
|
-
else if (tag === 2) obj.value = pbf.readDouble();
|
|
85
|
-
};
|
|
86
|
-
|
|
87
|
-
// StringProp ========================================
|
|
88
|
-
|
|
89
|
-
const StringProp = {};
|
|
90
|
-
|
|
91
|
-
StringProp.read = function (pbf, end) {
|
|
92
|
-
return pbf.readFields(StringProp._readField, {value: []}, end);
|
|
93
|
-
};
|
|
94
|
-
StringProp._readField = function (tag, obj, pbf) {
|
|
95
|
-
if (tag === 1) obj.value.push(pbf.readString());
|
|
96
|
-
};
|
|
97
|
-
|
|
98
|
-
// Points ========================================
|
|
99
|
-
|
|
100
|
-
const Points = {};
|
|
101
|
-
|
|
102
|
-
Points.read = function (pbf, end) {
|
|
103
|
-
return pbf.readFields(
|
|
104
|
-
Points._readField,
|
|
105
|
-
{positions: null, globalFeatureIds: null, featureIds: null, properties: [], numericProps: {}},
|
|
106
|
-
end
|
|
107
|
-
);
|
|
108
|
-
};
|
|
109
|
-
Points._readField = function (tag, obj, pbf) {
|
|
110
|
-
if (tag === 1) obj.positions = Doubles.read(pbf, pbf.readVarint() + pbf.pos);
|
|
111
|
-
else if (tag === 2) obj.globalFeatureIds = Ints.read(pbf, pbf.readVarint() + pbf.pos);
|
|
112
|
-
else if (tag === 3) obj.featureIds = Ints.read(pbf, pbf.readVarint() + pbf.pos);
|
|
113
|
-
else if (tag === 4) obj.properties.push(Properties.read(pbf, pbf.readVarint() + pbf.pos));
|
|
114
|
-
else if (tag === 5) {
|
|
115
|
-
const entry = NumericPropKeyValue.read(pbf, pbf.readVarint() + pbf.pos);
|
|
116
|
-
obj.numericProps[entry.key] = entry.value;
|
|
117
|
-
}
|
|
118
|
-
};
|
|
119
|
-
|
|
120
|
-
// Lines ========================================
|
|
121
|
-
|
|
122
|
-
const Lines = {};
|
|
123
|
-
|
|
124
|
-
Lines.read = function (pbf, end) {
|
|
125
|
-
return pbf.readFields(
|
|
126
|
-
Lines._readField,
|
|
127
|
-
{
|
|
128
|
-
positions: null,
|
|
129
|
-
pathIndices: null,
|
|
130
|
-
globalFeatureIds: null,
|
|
131
|
-
featureIds: null,
|
|
132
|
-
properties: [],
|
|
133
|
-
numericProps: {}
|
|
134
|
-
},
|
|
135
|
-
end
|
|
136
|
-
);
|
|
137
|
-
};
|
|
138
|
-
Lines._readField = function (tag, obj, pbf) {
|
|
139
|
-
if (tag === 1) obj.positions = Doubles.read(pbf, pbf.readVarint() + pbf.pos);
|
|
140
|
-
else if (tag === 2) obj.pathIndices = Ints.read(pbf, pbf.readVarint() + pbf.pos);
|
|
141
|
-
else if (tag === 3) obj.globalFeatureIds = Ints.read(pbf, pbf.readVarint() + pbf.pos);
|
|
142
|
-
else if (tag === 4) obj.featureIds = Ints.read(pbf, pbf.readVarint() + pbf.pos);
|
|
143
|
-
else if (tag === 5) obj.properties.push(Properties.read(pbf, pbf.readVarint() + pbf.pos));
|
|
144
|
-
else if (tag === 6) {
|
|
145
|
-
const entry = NumericPropKeyValue.read(pbf, pbf.readVarint() + pbf.pos);
|
|
146
|
-
obj.numericProps[entry.key] = entry.value;
|
|
147
|
-
}
|
|
148
|
-
};
|
|
149
|
-
|
|
150
|
-
// Polygons ========================================
|
|
151
|
-
|
|
152
|
-
const Polygons = {};
|
|
153
|
-
|
|
154
|
-
Polygons.read = function (pbf, end) {
|
|
155
|
-
return pbf.readFields(
|
|
156
|
-
Polygons._readField,
|
|
157
|
-
{
|
|
158
|
-
positions: null,
|
|
159
|
-
polygonIndices: null,
|
|
160
|
-
globalFeatureIds: null,
|
|
161
|
-
featureIds: null,
|
|
162
|
-
primitivePolygonIndices: null,
|
|
163
|
-
triangles: null,
|
|
164
|
-
properties: [],
|
|
165
|
-
numericProps: {}
|
|
166
|
-
},
|
|
167
|
-
end
|
|
168
|
-
);
|
|
169
|
-
};
|
|
170
|
-
Polygons._readField = function (tag, obj, pbf) {
|
|
171
|
-
if (tag === 1) obj.positions = Doubles.read(pbf, pbf.readVarint() + pbf.pos);
|
|
172
|
-
else if (tag === 2) obj.polygonIndices = Ints.read(pbf, pbf.readVarint() + pbf.pos);
|
|
173
|
-
else if (tag === 3) obj.globalFeatureIds = Ints.read(pbf, pbf.readVarint() + pbf.pos);
|
|
174
|
-
else if (tag === 4) obj.featureIds = Ints.read(pbf, pbf.readVarint() + pbf.pos);
|
|
175
|
-
else if (tag === 5) obj.primitivePolygonIndices = Ints.read(pbf, pbf.readVarint() + pbf.pos);
|
|
176
|
-
else if (tag === 6) obj.triangles = Ints.read(pbf, pbf.readVarint() + pbf.pos);
|
|
177
|
-
else if (tag === 7) obj.properties.push(Properties.read(pbf, pbf.readVarint() + pbf.pos));
|
|
178
|
-
else if (tag === 8) {
|
|
179
|
-
const entry = NumericPropKeyValue.read(pbf, pbf.readVarint() + pbf.pos);
|
|
180
|
-
obj.numericProps[entry.key] = entry.value;
|
|
181
|
-
}
|
|
182
|
-
};
|
|
183
|
-
|
|
184
|
-
// Tile ========================================
|
|
185
|
-
|
|
186
|
-
export const Tile = {};
|
|
187
|
-
|
|
188
|
-
Tile.read = function (pbf, end) {
|
|
189
|
-
return pbf.readFields(Tile._readField, {points: null, lines: null, polygons: null}, end);
|
|
190
|
-
};
|
|
191
|
-
Tile._readField = function (tag, obj, pbf) {
|
|
192
|
-
if (tag === 1) obj.points = Points.read(pbf, pbf.readVarint() + pbf.pos);
|
|
193
|
-
else if (tag === 2) obj.lines = Lines.read(pbf, pbf.readVarint() + pbf.pos);
|
|
194
|
-
else if (tag === 3) obj.polygons = Polygons.read(pbf, pbf.readVarint() + pbf.pos);
|
|
195
|
-
};
|