@deck.gl/carto 8.8.9 → 8.8.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/dist.dev.js +1747 -1555
- package/dist/es5/api/layer-map.js +104 -9
- package/dist/es5/api/layer-map.js.map +1 -1
- package/dist/es5/api/maps-v3-client.js +8 -8
- package/dist/es5/api/maps-v3-client.js.map +1 -1
- package/dist/es5/api/parseMap.js +38 -4
- package/dist/es5/api/parseMap.js.map +1 -1
- package/dist/es5/api/types.js +2 -0
- package/dist/es5/api/types.js.map +1 -0
- package/dist/es5/layers/carto-tile-layer.js +33 -107
- package/dist/es5/layers/carto-tile-layer.js.map +1 -1
- package/dist/es5/layers/schema/carto-spatial-tile-loader.js +6 -30
- package/dist/es5/layers/schema/carto-spatial-tile-loader.js.map +1 -1
- package/dist/es5/layers/schema/carto-tile.js +30 -6
- package/dist/es5/layers/schema/carto-tile.js.map +1 -1
- package/dist/es5/layers/schema/carto-vector-tile-loader.js +81 -0
- package/dist/es5/layers/schema/carto-vector-tile-loader.js.map +1 -0
- package/dist/es5/layers/schema/tile-loader-utils.js +34 -0
- package/dist/es5/layers/schema/tile-loader-utils.js.map +1 -0
- package/dist/es5/layers/spatial-index-tile-layer.js +40 -0
- package/dist/es5/layers/spatial-index-tile-layer.js.map +1 -1
- package/dist/esm/api/layer-map.js +85 -9
- package/dist/esm/api/layer-map.js.map +1 -1
- package/dist/esm/api/maps-v3-client.js +3 -2
- package/dist/esm/api/maps-v3-client.js.map +1 -1
- package/dist/esm/api/parseMap.js +41 -5
- package/dist/esm/api/parseMap.js.map +1 -1
- package/dist/esm/api/types.js +2 -0
- package/dist/esm/api/types.js.map +1 -0
- package/dist/esm/layers/carto-tile-layer.js +31 -82
- package/dist/esm/layers/carto-tile-layer.js.map +1 -1
- package/dist/esm/layers/schema/carto-spatial-tile-loader.js +4 -27
- package/dist/esm/layers/schema/carto-spatial-tile-loader.js.map +1 -1
- package/dist/esm/layers/schema/carto-tile.js +22 -6
- package/dist/esm/layers/schema/carto-tile.js.map +1 -1
- package/dist/esm/layers/schema/carto-vector-tile-loader.js +40 -0
- package/dist/esm/layers/schema/carto-vector-tile-loader.js.map +1 -0
- package/dist/esm/layers/schema/tile-loader-utils.js +23 -0
- package/dist/esm/layers/schema/tile-loader-utils.js.map +1 -0
- package/dist/esm/layers/spatial-index-tile-layer.js +40 -1
- package/dist/esm/layers/spatial-index-tile-layer.js.map +1 -1
- package/dist.min.js +138 -138
- package/package.json +2 -2
- package/src/api/layer-map.ts +103 -17
- package/src/api/maps-v3-client.ts +3 -3
- package/src/api/parseMap.ts +80 -15
- package/src/api/types.ts +108 -0
- package/src/layers/carto-tile-layer.ts +32 -82
- package/src/layers/schema/carto-spatial-tile-loader.ts +4 -27
- package/src/layers/schema/carto-tile.ts +31 -6
- package/src/layers/schema/carto-vector-tile-loader.ts +39 -0
- package/src/layers/schema/tile-loader-utils.ts +22 -0
- package/src/layers/spatial-index-tile-layer.ts +37 -1
- package/typed/api/layer-map.d.ts +10 -13
- package/typed/api/layer-map.d.ts.map +1 -1
- package/typed/api/parseMap.d.ts.map +1 -1
- package/typed/api/types.d.ts +87 -0
- package/typed/api/types.d.ts.map +1 -0
- package/typed/layers/carto-tile-layer.d.ts +2 -0
- package/typed/layers/carto-tile-layer.d.ts.map +1 -1
- package/typed/layers/schema/carto-spatial-tile-loader.d.ts.map +1 -1
- package/typed/layers/schema/carto-tile.d.ts +4 -0
- package/typed/layers/schema/carto-tile.d.ts.map +1 -1
- package/typed/layers/schema/carto-vector-tile-loader.d.ts +4 -0
- package/typed/layers/schema/carto-vector-tile-loader.d.ts.map +1 -0
- package/typed/layers/schema/tile-loader-utils.d.ts +5 -0
- package/typed/layers/schema/tile-loader-utils.d.ts.map +1 -0
- package/typed/layers/spatial-index-tile-layer.d.ts +2 -1
- package/typed/layers/spatial-index-tile-layer.d.ts.map +1 -1
- package/typed/api/index.js +0 -3
- package/typed/api/layer-map.js +0 -264
- package/typed/api/maps-api-common.js +0 -50
- package/typed/api/maps-client.js +0 -125
- package/typed/api/maps-v3-client.js +0 -304
- package/typed/api/parseMap.js +0 -178
- package/typed/basemap.js +0 -9
- package/typed/config.js +0 -35
- package/typed/index.js +0 -10
- package/typed/layers/carto-layer.js +0 -173
- package/typed/layers/carto-tile-layer.js +0 -105
- package/typed/layers/h3-tile-layer.js +0 -47
- package/typed/layers/h3-tileset-2d.js +0 -85
- package/typed/layers/quadkey-tile-layer.d.ts +0 -21
- package/typed/layers/quadkey-tile-layer.d.ts.map +0 -1
- package/typed/layers/quadkey-tile-layer.js +0 -42
- package/typed/layers/quadkey-tileset-2d.d.ts +0 -15
- package/typed/layers/quadkey-tileset-2d.d.ts.map +0 -1
- package/typed/layers/quadkey-tileset-2d.js +0 -36
- package/typed/layers/schema/carto-tile.js +0 -161
- package/typed/layers/spatial-index-tile-layer.js +0 -40
- package/typed/style/color-bins-style.js +0 -12
- package/typed/style/color-categories-style.js +0 -16
- package/typed/style/color-continuous-style.js +0 -12
- package/typed/style/palette.js +0 -62
- package/typed/style/utils.js +0 -15
- package/typed/utils.js +0 -4
|
@@ -67,6 +67,19 @@ class IntsReader {
|
|
|
67
67
|
|
|
68
68
|
}
|
|
69
69
|
|
|
70
|
+
class FieldsReader {
|
|
71
|
+
static read(pbf, end) {
|
|
72
|
+
return pbf.readFields(FieldsReader._readField, {
|
|
73
|
+
id: 0
|
|
74
|
+
}, end);
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
static _readField(tag, obj, pbf) {
|
|
78
|
+
if (tag === 1) obj.id = pbf.readVarint();
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
}
|
|
82
|
+
|
|
70
83
|
class NumericPropReader {
|
|
71
84
|
static read(pbf, end) {
|
|
72
85
|
return pbf.readFields(NumericPropReader._readField, {
|
|
@@ -101,7 +114,8 @@ class PointsReader {
|
|
|
101
114
|
globalFeatureIds: null,
|
|
102
115
|
featureIds: null,
|
|
103
116
|
properties: [],
|
|
104
|
-
numericProps: {}
|
|
117
|
+
numericProps: {},
|
|
118
|
+
fields: []
|
|
105
119
|
}, end);
|
|
106
120
|
}
|
|
107
121
|
|
|
@@ -109,7 +123,7 @@ class PointsReader {
|
|
|
109
123
|
if (tag === 1) obj.positions = DoublesReader.read(pbf, pbf.readVarint() + pbf.pos);else if (tag === 2) obj.globalFeatureIds = IntsReader.read(pbf, pbf.readVarint() + pbf.pos);else if (tag === 3) obj.featureIds = IntsReader.read(pbf, pbf.readVarint() + pbf.pos);else if (tag === 4) obj.properties.push(PropertiesReader.read(pbf, pbf.readVarint() + pbf.pos));else if (tag === 5) {
|
|
110
124
|
const entry = NumericPropKeyValueReader.read(pbf, pbf.readVarint() + pbf.pos);
|
|
111
125
|
obj.numericProps[entry.key] = entry.value;
|
|
112
|
-
}
|
|
126
|
+
} else if (tag === 6) obj.fields.push(FieldsReader.read(pbf, pbf.readVarint() + pbf.pos));
|
|
113
127
|
}
|
|
114
128
|
|
|
115
129
|
}
|
|
@@ -122,7 +136,8 @@ class LinesReader {
|
|
|
122
136
|
globalFeatureIds: null,
|
|
123
137
|
featureIds: null,
|
|
124
138
|
properties: [],
|
|
125
|
-
numericProps: {}
|
|
139
|
+
numericProps: {},
|
|
140
|
+
fields: []
|
|
126
141
|
}, end);
|
|
127
142
|
}
|
|
128
143
|
|
|
@@ -130,7 +145,7 @@ class LinesReader {
|
|
|
130
145
|
if (tag === 1) obj.positions = DoublesReader.read(pbf, pbf.readVarint() + pbf.pos);else if (tag === 2) obj.pathIndices = IntsReader.read(pbf, pbf.readVarint() + pbf.pos);else if (tag === 3) obj.globalFeatureIds = IntsReader.read(pbf, pbf.readVarint() + pbf.pos);else if (tag === 4) obj.featureIds = IntsReader.read(pbf, pbf.readVarint() + pbf.pos);else if (tag === 5) obj.properties.push(PropertiesReader.read(pbf, pbf.readVarint() + pbf.pos));else if (tag === 6) {
|
|
131
146
|
const entry = NumericPropKeyValueReader.read(pbf, pbf.readVarint() + pbf.pos);
|
|
132
147
|
obj.numericProps[entry.key] = entry.value;
|
|
133
|
-
}
|
|
148
|
+
} else if (tag === 7) obj.fields.push(FieldsReader.read(pbf, pbf.readVarint() + pbf.pos));
|
|
134
149
|
}
|
|
135
150
|
|
|
136
151
|
}
|
|
@@ -145,7 +160,8 @@ class PolygonsReader {
|
|
|
145
160
|
primitivePolygonIndices: null,
|
|
146
161
|
triangles: null,
|
|
147
162
|
properties: [],
|
|
148
|
-
numericProps: {}
|
|
163
|
+
numericProps: {},
|
|
164
|
+
fields: []
|
|
149
165
|
}, end);
|
|
150
166
|
}
|
|
151
167
|
|
|
@@ -153,7 +169,7 @@ class PolygonsReader {
|
|
|
153
169
|
if (tag === 1) obj.positions = DoublesReader.read(pbf, pbf.readVarint() + pbf.pos);else if (tag === 2) obj.polygonIndices = IntsReader.read(pbf, pbf.readVarint() + pbf.pos);else if (tag === 3) obj.globalFeatureIds = IntsReader.read(pbf, pbf.readVarint() + pbf.pos);else if (tag === 4) obj.featureIds = IntsReader.read(pbf, pbf.readVarint() + pbf.pos);else if (tag === 5) obj.primitivePolygonIndices = IntsReader.read(pbf, pbf.readVarint() + pbf.pos);else if (tag === 6) obj.triangles = IntsReader.read(pbf, pbf.readVarint() + pbf.pos);else if (tag === 7) obj.properties.push(PropertiesReader.read(pbf, pbf.readVarint() + pbf.pos));else if (tag === 8) {
|
|
154
170
|
const entry = NumericPropKeyValueReader.read(pbf, pbf.readVarint() + pbf.pos);
|
|
155
171
|
obj.numericProps[entry.key] = entry.value;
|
|
156
|
-
}
|
|
172
|
+
} else if (tag === 9) obj.fields.push(FieldsReader.read(pbf, pbf.readVarint() + pbf.pos));
|
|
157
173
|
}
|
|
158
174
|
|
|
159
175
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/layers/schema/carto-tile.ts"],"names":["KeyValueObjectReader","read","pbf","end","readFields","_readField","key","value","tag","obj","readString","PropertiesReader","data","push","readVarint","pos","DoublesReader","size","Float32Array","readPackedDouble","IntsReader","Uint32Array","readPackedVarint","NumericPropReader","NumericPropKeyValueReader","PointsReader","positions","globalFeatureIds","featureIds","properties","numericProps","entry","LinesReader","pathIndices","PolygonsReader","polygonIndices","primitivePolygonIndices","triangles","TileReader","points","lines","polygons"],"mappings":"AAMA,MAAMA,oBAAN,CAA2B;AACd,SAAJC,IAAI,CAACC,GAAD,EAAMC,GAAN,EAAoC;AAC7C,WAAOD,GAAG,CAACE,UAAJ,CAAeJ,oBAAoB,CAACK,UAApC,EAAgD;AAACC,MAAAA,GAAG,EAAE,EAAN;AAAUC,MAAAA,KAAK,EAAE;AAAjB,KAAhD,EAAsEJ,GAAtE,CAAP;AACD;;AACgB,SAAVE,UAAU,CAAaG,GAAb,EAA0BC,GAA1B,EAA+CP,GAA/C,EAAoD;AACnE,QAAIM,GAAG,KAAK,CAAZ,EAAeC,GAAG,CAACH,GAAJ,GAAUJ,GAAG,CAACQ,UAAJ,EAAV,CAAf,KACK,IAAIF,GAAG,KAAK,CAAZ,EAAeC,GAAG,CAACF,KAAJ,GAAYL,GAAG,CAACQ,UAAJ,EAAZ;AACrB;;AAPwB;;AAgB3B,OAAO,MAAMC,gBAAN,CAAuB;AACjB,SAAJV,IAAI,CAACC,GAAD,EAAMC,GAAN,EAAoB;AAC7B,WAAOD,GAAG,CAACE,UAAJ,CAAeO,gBAAgB,CAACN,UAAhC,EAA4C;AAACO,MAAAA,IAAI,EAAE;AAAP,KAA5C,EAAwDT,GAAxD,CAAP;AACD;;AACgB,SAAVE,UAAU,CAAaG,GAAb,EAA0BC,GAA1B,EAAmDP,GAAnD,EAAwD;AACvE,QAAIM,GAAG,KAAK,CAAZ,EAAeC,GAAG,CAACG,IAAJ,CAASC,IAAT,CAAcb,oBAAoB,CAACC,IAArB,CAA0BC,GAA1B,EAA+BA,GAAG,CAACY,UAAJ,KAAmBZ,GAAG,CAACa,GAAtD,CAAd;AAChB;;AAN2B;;AAgB9B,MAAMC,aAAN,CAAoB;AACP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AN,CAAiB;AACX,SAAJrC,IAAI,CAACC,GAAD,EAAMC,GAAN,EAA0B;AACnC,WAAOD,GAAG,CAACE,UAAJ,CAAekC,UAAU,CAACjC,UAA1B,EAAsC;AAACkC,MAAAA,MAAM,EAAE,IAAT;AAAeC,MAAAA,KAAK,EAAE,IAAtB;AAA4BC,MAAAA,QAAQ,EAAE;AAAtC,KAAtC,EAAmFtC,GAAnF,CAAP;AACD;;AACgB,SAAVE,UAAU,CAAaG,GAAb,EAA0BC,GAA1B,EAAqCP,GAArC,EAA0C;AACzD,QAAIM,GAAG,KAAK,CAAZ,EAAeC,GAAG,CAAC8B,MAAJ,GAAad,YAAY,CAACxB,IAAb,CAAkBC,GAAlB,EAAuBA,GAAG,CAACY,UAAJ,KAAmBZ,GAAG,CAACa,GAA9C,CAAb,CAAf,KACK,IAAIP,GAAG,KAAK,CAAZ,EAAeC,GAAG,CAAC+B,KAAJ,GAAYR,WAAW,CAAC/B,IAAZ,CAAiBC,GAAjB,EAAsBA,GAAG,CAACY,UAAJ,KAAmBZ,GAAG,CAACa,GAA7C,CAAZ,CAAf,KACA,IAAIP,GAAG,KAAK,CAAZ,EAAeC,GAAG,CAACgC,QAAJ,GAAeP,cAAc,CAACjC,IAAf,CAAoBC,GAApB,EAAyBA,GAAG,CAACY,UAAJ,KAAmBZ,GAAG,CAACa,GAAhD,CAAf;AACrB;;AARqB","sourcesContent":["// KeyValueObject ========================================\ninterface KeyValueObject {\n key: string;\n value: string;\n}\n\nclass KeyValueObjectReader {\n static read(pbf, end?: number): KeyValueObject {\n return pbf.readFields(KeyValueObjectReader._readField, {key: '', value: ''}, end);\n }\n static _readField(this: void, tag: number, obj: KeyValueObject, pbf) {\n if (tag === 1) obj.key = pbf.readString();\n else if (tag === 2) obj.value = pbf.readString();\n }\n}\n\n// Properties ========================================\n\nexport interface KeyValueProperties {\n data: KeyValueObject[];\n}\n\nexport class PropertiesReader {\n static read(pbf, end?: number) {\n return pbf.readFields(PropertiesReader._readField, {data: []}, end);\n }\n static _readField(this: void, tag: number, obj: KeyValueProperties, pbf) {\n if (tag === 1) obj.data.push(KeyValueObjectReader.read(pbf, pbf.readVarint() + pbf.pos));\n }\n}\n\n// Doubles ========================================\n\ninterface Doubles {\n value: Float32Array;\n size: number;\n}\n\nclass DoublesReader {\n static read(pbf, end?: number): Doubles {\n // TODO perhaps we can do better and directly map from the source\n // ArrayBuffer using ArrayBuffer.slice()\n const {value, size} = pbf.readFields(DoublesReader._readField, {value: [], size: 0}, end);\n return {value: new Float32Array(value), size};\n }\n static _readField(this: void, tag: number, obj, pbf) {\n if (tag === 1) pbf.readPackedDouble(obj.value);\n else if (tag === 2) obj.size = pbf.readVarint(true);\n }\n}\n\n// Ints ========================================\n\ninterface Ints {\n value: Uint32Array;\n size: number;\n}\n\nclass IntsReader {\n static read(pbf, end?: number): Ints {\n const {value, size} = pbf.readFields(IntsReader._readField, {value: [], size: 0}, end);\n return {value: new Uint32Array(value), size};\n }\n static _readField(this: void, tag: number, obj, pbf) {\n if (tag === 1) pbf.readPackedVarint(obj.value);\n else if (tag === 2) obj.size = pbf.readVarint(true);\n }\n}\n\n// NumericProp ========================================\n\nexport interface NumericProp {\n value: number[];\n}\n\nclass NumericPropReader {\n static read(pbf, end?: number): NumericProp {\n return pbf.readFields(NumericPropReader._readField, {value: []}, end);\n }\n static _readField(this: void, tag: number, obj: NumericProp, pbf) {\n if (tag === 1) pbf.readPackedDouble(obj.value);\n }\n}\n\n// NumericPropKeyValue ========================================\ninterface NumbericPropKeyValue {\n key: string;\n value: NumericProp;\n}\n\nexport class NumericPropKeyValueReader {\n static read(pbf, end?: number): NumbericPropKeyValue {\n return pbf.readFields(NumericPropKeyValueReader._readField, {key: '', value: null}, end);\n }\n static _readField(this: void, tag: number, obj: NumbericPropKeyValue, pbf) {\n if (tag === 1) obj.key = pbf.readString();\n else if (tag === 2) obj.value = NumericPropReader.read(pbf, pbf.readVarint() + pbf.pos);\n }\n}\n\n// Points ========================================\n\ninterface Points {\n positions: Doubles;\n globalFeatureIds: Ints;\n featureIds: Ints;\n properties: KeyValueProperties[];\n numericProps: Record<string, NumericProp>;\n}\n\nclass PointsReader {\n static read(pbf, end?: number): Points {\n return pbf.readFields(\n PointsReader._readField,\n {positions: null, globalFeatureIds: null, featureIds: null, properties: [], numericProps: {}},\n end\n );\n }\n static _readField(this: void, tag: number, obj: Points, pbf) {\n if (tag === 1) obj.positions = DoublesReader.read(pbf, pbf.readVarint() + pbf.pos);\n else if (tag === 2) obj.globalFeatureIds = IntsReader.read(pbf, pbf.readVarint() + pbf.pos);\n else if (tag === 3) obj.featureIds = IntsReader.read(pbf, pbf.readVarint() + pbf.pos);\n else if (tag === 4) obj.properties.push(PropertiesReader.read(pbf, pbf.readVarint() + pbf.pos));\n else if (tag === 5) {\n const entry = NumericPropKeyValueReader.read(pbf, pbf.readVarint() + pbf.pos);\n obj.numericProps[entry.key] = entry.value;\n }\n }\n}\n\ninterface Lines extends Points {\n pathIndices: Ints;\n}\n// Lines ========================================\n\nclass LinesReader {\n static read(pbf, end?: number): Lines {\n return pbf.readFields(\n LinesReader._readField,\n {\n positions: null,\n pathIndices: null,\n globalFeatureIds: null,\n featureIds: null,\n properties: [],\n numericProps: {}\n },\n end\n );\n }\n static _readField(this: void, tag: number, obj: Lines, pbf) {\n if (tag === 1) obj.positions = DoublesReader.read(pbf, pbf.readVarint() + pbf.pos);\n else if (tag === 2) obj.pathIndices = IntsReader.read(pbf, pbf.readVarint() + pbf.pos);\n else if (tag === 3) obj.globalFeatureIds = IntsReader.read(pbf, pbf.readVarint() + pbf.pos);\n else if (tag === 4) obj.featureIds = IntsReader.read(pbf, pbf.readVarint() + pbf.pos);\n else if (tag === 5) obj.properties.push(PropertiesReader.read(pbf, pbf.readVarint() + pbf.pos));\n else if (tag === 6) {\n const entry = NumericPropKeyValueReader.read(pbf, pbf.readVarint() + pbf.pos);\n obj.numericProps[entry.key] = entry.value;\n }\n }\n}\n// Polygons ========================================\n\ninterface Polygons extends Points {\n polygonIndices: Ints;\n primitivePolygonIndices: Ints;\n triangles: Ints;\n}\n\nclass PolygonsReader {\n static read(pbf, end?: number): Polygons {\n return pbf.readFields(\n PolygonsReader._readField,\n {\n positions: null,\n polygonIndices: null,\n globalFeatureIds: null,\n featureIds: null,\n primitivePolygonIndices: null,\n triangles: null,\n properties: [],\n numericProps: {}\n },\n end\n );\n }\n static _readField(this: void, tag: number, obj: Polygons, pbf) {\n if (tag === 1) obj.positions = DoublesReader.read(pbf, pbf.readVarint() + pbf.pos);\n else if (tag === 2) obj.polygonIndices = IntsReader.read(pbf, pbf.readVarint() + pbf.pos);\n else if (tag === 3) obj.globalFeatureIds = IntsReader.read(pbf, pbf.readVarint() + pbf.pos);\n else if (tag === 4) obj.featureIds = IntsReader.read(pbf, pbf.readVarint() + pbf.pos);\n else if (tag === 5)\n obj.primitivePolygonIndices = IntsReader.read(pbf, pbf.readVarint() + pbf.pos);\n else if (tag === 6) obj.triangles = IntsReader.read(pbf, pbf.readVarint() + pbf.pos);\n else if (tag === 7) obj.properties.push(PropertiesReader.read(pbf, pbf.readVarint() + pbf.pos));\n else if (tag === 8) {\n const entry = NumericPropKeyValueReader.read(pbf, pbf.readVarint() + pbf.pos);\n obj.numericProps[entry.key] = entry.value;\n }\n }\n}\n\n// Tile ========================================\n\nexport interface Tile {\n points: Points;\n lines: Lines;\n polygons: Polygons;\n}\n\nexport class TileReader {\n static read(pbf, end?: number): Tile {\n return pbf.readFields(TileReader._readField, {points: null, lines: null, polygons: null}, end);\n }\n static _readField(this: void, tag: number, obj: Tile, pbf) {\n if (tag === 1) obj.points = PointsReader.read(pbf, pbf.readVarint() + pbf.pos);\n else if (tag === 2) obj.lines = LinesReader.read(pbf, pbf.readVarint() + pbf.pos);\n else if (tag === 3) obj.polygons = PolygonsReader.read(pbf, pbf.readVarint() + pbf.pos);\n }\n}\n"],"file":"carto-tile.js"}
|
|
1
|
+
{"version":3,"sources":["../../../../src/layers/schema/carto-tile.ts"],"names":["KeyValueObjectReader","read","pbf","end","readFields","_readField","key","value","tag","obj","readString","PropertiesReader","data","push","readVarint","pos","DoublesReader","size","Float32Array","readPackedDouble","IntsReader","Uint32Array","readPackedVarint","FieldsReader","id","NumericPropReader","NumericPropKeyValueReader","PointsReader","positions","globalFeatureIds","featureIds","properties","numericProps","fields","entry","LinesReader","pathIndices","PolygonsReader","polygonIndices","primitivePolygonIndices","triangles","TileReader","points","lines","polygons"],"mappings":"AAMA,MAAMA,oBAAN,CAA2B;AACd,SAAJC,IAAI,CAACC,GAAD,EAAMC,GAAN,EAAoC;AAC7C,WAAOD,GAAG,CAACE,UAAJ,CAAeJ,oBAAoB,CAACK,UAApC,EAAgD;AAACC,MAAAA,GAAG,EAAE,EAAN;AAAUC,MAAAA,KAAK,EAAE;AAAjB,KAAhD,EAAsEJ,GAAtE,CAAP;AACD;;AACgB,SAAVE,UAAU,CAAaG,GAAb,EAA0BC,GAA1B,EAA+CP,GAA/C,EAAoD;AACnE,QAAIM,GAAG,KAAK,CAAZ,EAAeC,GAAG,CAACH,GAAJ,GAAUJ,GAAG,CAACQ,UAAJ,EAAV,CAAf,KACK,IAAIF,GAAG,KAAK,CAAZ,EAAeC,GAAG,CAACF,KAAJ,GAAYL,GAAG,CAACQ,UAAJ,EAAZ;AACrB;;AAPwB;;AAgB3B,OAAO,MAAMC,gBAAN,CAAuB;AACjB,SAAJV,IAAI,CAACC,GAAD,EAAMC,GAAN,EAAoB;AAC7B,WAAOD,GAAG,CAACE,UAAJ,CAAeO,gBAAgB,CAACN,UAAhC,EAA4C;AAACO,MAAAA,IAAI,EAAE;AAAP,KAA5C,EAAwDT,GAAxD,CAAP;AACD;;AACgB,SAAVE,UAAU,CAAaG,GAAb,EAA0BC,GAA1B,EAAmDP,GAAnD,EAAwD;AACvE,QAAIM,GAAG,KAAK,CAAZ,EAAeC,GAAG,CAACG,IAAJ,CAASC,IAAT,CAAcb,oBAAoB,CAACC,IAArB,CAA0BC,GAA1B,EAA+BA,GAAG,CAAC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AACE,UAAJ,CAAeqC,UAAU,CAACpC,UAA1B,EAAsC;AAACqC,MAAAA,MAAM,EAAE,IAAT;AAAeC,MAAAA,KAAK,EAAE,IAAtB;AAA4BC,MAAAA,QAAQ,EAAE;AAAtC,KAAtC,EAAmFzC,GAAnF,CAAP;AACD;;AACgB,SAAVE,UAAU,CAAaG,GAAb,EAA0BC,GAA1B,EAAqCP,GAArC,EAA0C;AACzD,QAAIM,GAAG,KAAK,CAAZ,EAAeC,GAAG,CAACiC,MAAJ,GAAaf,YAAY,CAAC1B,IAAb,CAAkBC,GAAlB,EAAuBA,GAAG,CAACY,UAAJ,KAAmBZ,GAAG,CAACa,GAA9C,CAAb,CAAf,KACK,IAAIP,GAAG,KAAK,CAAZ,EAAeC,GAAG,CAACkC,KAAJ,GAAYR,WAAW,CAAClC,IAAZ,CAAiBC,GAAjB,EAAsBA,GAAG,CAACY,UAAJ,KAAmBZ,GAAG,CAACa,GAA7C,CAAZ,CAAf,KACA,IAAIP,GAAG,KAAK,CAAZ,EAAeC,GAAG,CAACmC,QAAJ,GAAeP,cAAc,CAACpC,IAAf,CAAoBC,GAApB,EAAyBA,GAAG,CAACY,UAAJ,KAAmBZ,GAAG,CAACa,GAAhD,CAAf;AACrB;;AARqB","sourcesContent":["// KeyValueObject ========================================\ninterface KeyValueObject {\n key: string;\n value: string;\n}\n\nclass KeyValueObjectReader {\n static read(pbf, end?: number): KeyValueObject {\n return pbf.readFields(KeyValueObjectReader._readField, {key: '', value: ''}, end);\n }\n static _readField(this: void, tag: number, obj: KeyValueObject, pbf) {\n if (tag === 1) obj.key = pbf.readString();\n else if (tag === 2) obj.value = pbf.readString();\n }\n}\n\n// Properties ========================================\n\nexport interface KeyValueProperties {\n data: KeyValueObject[];\n}\n\nexport class PropertiesReader {\n static read(pbf, end?: number) {\n return pbf.readFields(PropertiesReader._readField, {data: []}, end);\n }\n static _readField(this: void, tag: number, obj: KeyValueProperties, pbf) {\n if (tag === 1) obj.data.push(KeyValueObjectReader.read(pbf, pbf.readVarint() + pbf.pos));\n }\n}\n\n// Doubles ========================================\n\ninterface Doubles {\n value: Float32Array;\n size: number;\n}\n\nclass DoublesReader {\n static read(pbf, end?: number): Doubles {\n // TODO perhaps we can do better and directly map from the source\n // ArrayBuffer using ArrayBuffer.slice()\n const {value, size} = pbf.readFields(DoublesReader._readField, {value: [], size: 0}, end);\n return {value: new Float32Array(value), size};\n }\n static _readField(this: void, tag: number, obj, pbf) {\n if (tag === 1) pbf.readPackedDouble(obj.value);\n else if (tag === 2) obj.size = pbf.readVarint(true);\n }\n}\n\n// Ints ========================================\n\ninterface Ints {\n value: Uint32Array;\n size: number;\n}\n\nclass IntsReader {\n static read(pbf, end?: number): Ints {\n const {value, size} = pbf.readFields(IntsReader._readField, {value: [], size: 0}, end);\n return {value: new Uint32Array(value), size};\n }\n static _readField(this: void, tag: number, obj, pbf) {\n if (tag === 1) pbf.readPackedVarint(obj.value);\n else if (tag === 2) obj.size = pbf.readVarint(true);\n }\n}\n\n// Fields ========================================\n\ninterface Fields {\n id: number;\n}\n\nclass FieldsReader {\n static read(pbf, end?: number): Fields {\n return pbf.readFields(FieldsReader._readField, {id: 0}, end);\n }\n static _readField(this: void, tag: number, obj: Fields, pbf) {\n if (tag === 1) obj.id = pbf.readVarint();\n }\n}\n\n// NumericProp ========================================\n\nexport interface NumericProp {\n value: number[];\n}\n\nclass NumericPropReader {\n static read(pbf, end?: number): NumericProp {\n return pbf.readFields(NumericPropReader._readField, {value: []}, end);\n }\n static _readField(this: void, tag: number, obj: NumericProp, pbf) {\n if (tag === 1) pbf.readPackedDouble(obj.value);\n }\n}\n\n// NumericPropKeyValue ========================================\ninterface NumbericPropKeyValue {\n key: string;\n value: NumericProp;\n}\n\nexport class NumericPropKeyValueReader {\n static read(pbf, end?: number): NumbericPropKeyValue {\n return pbf.readFields(NumericPropKeyValueReader._readField, {key: '', value: null}, end);\n }\n static _readField(this: void, tag: number, obj: NumbericPropKeyValue, pbf) {\n if (tag === 1) obj.key = pbf.readString();\n else if (tag === 2) obj.value = NumericPropReader.read(pbf, pbf.readVarint() + pbf.pos);\n }\n}\n\n// Points ========================================\n\ninterface Points {\n positions: Doubles;\n globalFeatureIds: Ints;\n featureIds: Ints;\n properties: KeyValueProperties[];\n numericProps: Record<string, NumericProp>;\n fields: Fields[];\n}\n\nclass PointsReader {\n static read(pbf, end?: number): Points {\n return pbf.readFields(\n PointsReader._readField,\n {\n positions: null,\n globalFeatureIds: null,\n featureIds: null,\n properties: [],\n numericProps: {},\n fields: []\n },\n end\n );\n }\n static _readField(this: void, tag: number, obj: Points, pbf) {\n if (tag === 1) obj.positions = DoublesReader.read(pbf, pbf.readVarint() + pbf.pos);\n else if (tag === 2) obj.globalFeatureIds = IntsReader.read(pbf, pbf.readVarint() + pbf.pos);\n else if (tag === 3) obj.featureIds = IntsReader.read(pbf, pbf.readVarint() + pbf.pos);\n else if (tag === 4) obj.properties.push(PropertiesReader.read(pbf, pbf.readVarint() + pbf.pos));\n else if (tag === 5) {\n const entry = NumericPropKeyValueReader.read(pbf, pbf.readVarint() + pbf.pos);\n obj.numericProps[entry.key] = entry.value;\n } else if (tag === 6) obj.fields.push(FieldsReader.read(pbf, pbf.readVarint() + pbf.pos));\n }\n}\n\ninterface Lines extends Points {\n pathIndices: Ints;\n}\n// Lines ========================================\n\nclass LinesReader {\n static read(pbf, end?: number): Lines {\n return pbf.readFields(\n LinesReader._readField,\n {\n positions: null,\n pathIndices: null,\n globalFeatureIds: null,\n featureIds: null,\n properties: [],\n numericProps: {},\n fields: []\n },\n end\n );\n }\n static _readField(this: void, tag: number, obj: Lines, pbf) {\n if (tag === 1) obj.positions = DoublesReader.read(pbf, pbf.readVarint() + pbf.pos);\n else if (tag === 2) obj.pathIndices = IntsReader.read(pbf, pbf.readVarint() + pbf.pos);\n else if (tag === 3) obj.globalFeatureIds = IntsReader.read(pbf, pbf.readVarint() + pbf.pos);\n else if (tag === 4) obj.featureIds = IntsReader.read(pbf, pbf.readVarint() + pbf.pos);\n else if (tag === 5) obj.properties.push(PropertiesReader.read(pbf, pbf.readVarint() + pbf.pos));\n else if (tag === 6) {\n const entry = NumericPropKeyValueReader.read(pbf, pbf.readVarint() + pbf.pos);\n obj.numericProps[entry.key] = entry.value;\n } else if (tag === 7) obj.fields.push(FieldsReader.read(pbf, pbf.readVarint() + pbf.pos));\n }\n}\n// Polygons ========================================\n\ninterface Polygons extends Points {\n polygonIndices: Ints;\n primitivePolygonIndices: Ints;\n triangles: Ints;\n}\n\nclass PolygonsReader {\n static read(pbf, end?: number): Polygons {\n return pbf.readFields(\n PolygonsReader._readField,\n {\n positions: null,\n polygonIndices: null,\n globalFeatureIds: null,\n featureIds: null,\n primitivePolygonIndices: null,\n triangles: null,\n properties: [],\n numericProps: {},\n fields: []\n },\n end\n );\n }\n static _readField(this: void, tag: number, obj: Polygons, pbf) {\n if (tag === 1) obj.positions = DoublesReader.read(pbf, pbf.readVarint() + pbf.pos);\n else if (tag === 2) obj.polygonIndices = IntsReader.read(pbf, pbf.readVarint() + pbf.pos);\n else if (tag === 3) obj.globalFeatureIds = IntsReader.read(pbf, pbf.readVarint() + pbf.pos);\n else if (tag === 4) obj.featureIds = IntsReader.read(pbf, pbf.readVarint() + pbf.pos);\n else if (tag === 5)\n obj.primitivePolygonIndices = IntsReader.read(pbf, pbf.readVarint() + pbf.pos);\n else if (tag === 6) obj.triangles = IntsReader.read(pbf, pbf.readVarint() + pbf.pos);\n else if (tag === 7) obj.properties.push(PropertiesReader.read(pbf, pbf.readVarint() + pbf.pos));\n else if (tag === 8) {\n const entry = NumericPropKeyValueReader.read(pbf, pbf.readVarint() + pbf.pos);\n obj.numericProps[entry.key] = entry.value;\n } else if (tag === 9) obj.fields.push(FieldsReader.read(pbf, pbf.readVarint() + pbf.pos));\n }\n}\n\n// Tile ========================================\n\nexport interface Tile {\n points: Points;\n lines: Lines;\n polygons: Polygons;\n}\n\nexport class TileReader {\n static read(pbf, end?: number): Tile {\n return pbf.readFields(TileReader._readField, {points: null, lines: null, polygons: null}, end);\n }\n static _readField(this: void, tag: number, obj: Tile, pbf) {\n if (tag === 1) obj.points = PointsReader.read(pbf, pbf.readVarint() + pbf.pos);\n else if (tag === 2) obj.lines = LinesReader.read(pbf, pbf.readVarint() + pbf.pos);\n else if (tag === 3) obj.polygons = PolygonsReader.read(pbf, pbf.readVarint() + pbf.pos);\n }\n}\n"],"file":"carto-tile.js"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { TileReader } from './carto-tile';
|
|
2
|
+
import { parsePbf, unpackProperties } from './tile-loader-utils';
|
|
3
|
+
const CartoVectorTileLoader = {
|
|
4
|
+
name: 'CARTO Vector Tile',
|
|
5
|
+
version: '1',
|
|
6
|
+
id: 'cartoVectorTile',
|
|
7
|
+
module: 'carto',
|
|
8
|
+
extensions: ['pbf'],
|
|
9
|
+
mimeTypes: ['application/vnd.carto-vector-tile'],
|
|
10
|
+
category: 'geometry',
|
|
11
|
+
worker: false,
|
|
12
|
+
parse: async (arrayBuffer, options) => parseCartoVectorTile(arrayBuffer, options),
|
|
13
|
+
parseSync: parseCartoVectorTile,
|
|
14
|
+
options: {}
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
function parseCartoVectorTile(arrayBuffer, options) {
|
|
18
|
+
if (!arrayBuffer) return null;
|
|
19
|
+
const tile = parsePbf(arrayBuffer, TileReader);
|
|
20
|
+
const {
|
|
21
|
+
points,
|
|
22
|
+
lines,
|
|
23
|
+
polygons
|
|
24
|
+
} = tile;
|
|
25
|
+
const data = {
|
|
26
|
+
points: { ...points,
|
|
27
|
+
properties: unpackProperties(points.properties)
|
|
28
|
+
},
|
|
29
|
+
lines: { ...lines,
|
|
30
|
+
properties: unpackProperties(lines.properties)
|
|
31
|
+
},
|
|
32
|
+
polygons: { ...polygons,
|
|
33
|
+
properties: unpackProperties(polygons.properties)
|
|
34
|
+
}
|
|
35
|
+
};
|
|
36
|
+
return data;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export default CartoVectorTileLoader;
|
|
40
|
+
//# sourceMappingURL=carto-vector-tile-loader.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../src/layers/schema/carto-vector-tile-loader.ts"],"names":["TileReader","parsePbf","unpackProperties","CartoVectorTileLoader","name","version","id","module","extensions","mimeTypes","category","worker","parse","arrayBuffer","options","parseCartoVectorTile","parseSync","tile","points","lines","polygons","data","properties"],"mappings":"AAGA,SAAQA,UAAR,QAAyB,cAAzB;AACA,SAAQC,QAAR,EAAkBC,gBAAlB,QAAyC,qBAAzC;AAEA,MAAMC,qBAAuC,GAAG;AAC9CC,EAAAA,IAAI,EAAE,mBADwC;AAE9CC,EAAAA,OAAO,EAAE,GAFqC;AAG9CC,EAAAA,EAAE,EAAE,iBAH0C;AAI9CC,EAAAA,MAAM,EAAE,OAJsC;AAK9CC,EAAAA,UAAU,EAAE,CAAC,KAAD,CALkC;AAM9CC,EAAAA,SAAS,EAAE,CAAC,mCAAD,CANmC;AAO9CC,EAAAA,QAAQ,EAAE,UAPoC;AAQ9CC,EAAAA,MAAM,EAAE,KARsC;AAS9CC,EAAAA,KAAK,EAAE,OAAOC,WAAP,EAAoBC,OAApB,KAAgCC,oBAAoB,CAACF,WAAD,EAAcC,OAAd,CATb;AAU9CE,EAAAA,SAAS,EAAED,oBAVmC;AAW9CD,EAAAA,OAAO,EAAE;AAXqC,CAAhD;;AAcA,SAASC,oBAAT,CACEF,WADF,EAEEC,OAFF,EAGyB;AACvB,MAAI,CAACD,WAAL,EAAkB,OAAO,IAAP;AAClB,QAAMI,IAAI,GAAGhB,QAAQ,CAACY,WAAD,EAAcb,UAAd,CAArB;AAEA,QAAM;AAACkB,IAAAA,MAAD;AAASC,IAAAA,KAAT;AAAgBC,IAAAA;AAAhB,MAA4BH,IAAlC;AACA,QAAMI,IAAI,GAAG;AACXH,IAAAA,MAAM,EAAE,EAAC,GAAGA,MAAJ;AAAYI,MAAAA,UAAU,EAAEpB,gBAAgB,CAACgB,MAAM,CAACI,UAAR;AAAxC,KADG;AAEXH,IAAAA,KAAK,EAAE,EAAC,GAAGA,KAAJ;AAAWG,MAAAA,UAAU,EAAEpB,gBAAgB,CAACiB,KAAK,CAACG,UAAP;AAAvC,KAFI;AAGXF,IAAAA,QAAQ,EAAE,EAAC,GAAGA,QAAJ;AAAcE,MAAAA,UAAU,EAAEpB,gBAAgB,CAACkB,QAAQ,CAACE,UAAV;AAA1C;AAHC,GAAb;AAOA,SAAOD,IAAP;AACD;;AAED,eAAelB,qBAAf","sourcesContent":["import {LoaderOptions, LoaderWithParser} from '@loaders.gl/loader-utils';\nimport type {BinaryFeatures} from '@loaders.gl/schema';\n\nimport {TileReader} from './carto-tile';\nimport {parsePbf, unpackProperties} from './tile-loader-utils';\n\nconst CartoVectorTileLoader: LoaderWithParser = {\n name: 'CARTO Vector Tile',\n version: '1',\n id: 'cartoVectorTile',\n module: 'carto',\n extensions: ['pbf'],\n mimeTypes: ['application/vnd.carto-vector-tile'],\n category: 'geometry',\n worker: false,\n parse: async (arrayBuffer, options) => parseCartoVectorTile(arrayBuffer, options),\n parseSync: parseCartoVectorTile,\n options: {}\n};\n\nfunction parseCartoVectorTile(\n arrayBuffer: ArrayBuffer,\n options?: LoaderOptions\n): BinaryFeatures | null {\n if (!arrayBuffer) return null;\n const tile = parsePbf(arrayBuffer, TileReader);\n\n const {points, lines, polygons} = tile;\n const data = {\n points: {...points, properties: unpackProperties(points.properties)},\n lines: {...lines, properties: unpackProperties(lines.properties)},\n polygons: {...polygons, properties: unpackProperties(polygons.properties)}\n };\n\n // Note: there is slight, difference in `numericProps` type, however geojson/mvtlayer can cope with this\n return data as unknown as BinaryFeatures;\n}\n\nexport default CartoVectorTileLoader;\n"],"file":"carto-vector-tile-loader.js"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import Protobuf from 'pbf';
|
|
2
|
+
export function parsePbf(buffer, TileReader) {
|
|
3
|
+
const pbf = new Protobuf(buffer);
|
|
4
|
+
const tile = TileReader.read(pbf);
|
|
5
|
+
return tile;
|
|
6
|
+
}
|
|
7
|
+
export function unpackProperties(properties) {
|
|
8
|
+
if (!properties || !properties.length) {
|
|
9
|
+
return [];
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
return properties.map(item => {
|
|
13
|
+
const currentRecord = {};
|
|
14
|
+
item.data.forEach(({
|
|
15
|
+
key,
|
|
16
|
+
value
|
|
17
|
+
}) => {
|
|
18
|
+
currentRecord[key] = value;
|
|
19
|
+
});
|
|
20
|
+
return currentRecord;
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
//# sourceMappingURL=tile-loader-utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../src/layers/schema/tile-loader-utils.ts"],"names":["Protobuf","parsePbf","buffer","TileReader","pbf","tile","read","unpackProperties","properties","length","map","item","currentRecord","data","forEach","key","value"],"mappings":"AAAA,OAAOA,QAAP,MAAqB,KAArB;AAIA,OAAO,SAASC,QAAT,CAAkBC,MAAlB,EAAuCC,UAAvC,EAAmD;AACxD,QAAMC,GAAG,GAAG,IAAIJ,QAAJ,CAAaE,MAAb,CAAZ;AACA,QAAMG,IAAI,GAAGF,UAAU,CAACG,IAAX,CAAgBF,GAAhB,CAAb;AACA,SAAOC,IAAP;AACD;AAED,OAAO,SAASE,gBAAT,CAA0BC,UAA1B,EAA0E;AAC/E,MAAI,CAACA,UAAD,IAAe,CAACA,UAAU,CAACC,MAA/B,EAAuC;AACrC,WAAO,EAAP;AACD;;AACD,SAAOD,UAAU,CAACE,GAAX,CAAeC,IAAI,IAAI;AAC5B,UAAMC,aAAyB,GAAG,EAAlC;AACAD,IAAAA,IAAI,CAACE,IAAL,CAAUC,OAAV,CAAkB,CAAC;AAACC,MAAAA,GAAD;AAAMC,MAAAA;AAAN,KAAD,KAAkB;AAClCJ,MAAAA,aAAa,CAACG,GAAD,CAAb,GAAqBC,KAArB;AACD,KAFD;AAGA,WAAOJ,aAAP;AACD,GANM,CAAP;AAOD","sourcesContent":["import Protobuf from 'pbf';\nimport {KeyValueProperties} from './carto-tile';\nimport {Properties} from './spatialjson-utils';\n\nexport function parsePbf(buffer: ArrayBuffer, TileReader) {\n const pbf = new Protobuf(buffer);\n const tile = TileReader.read(pbf);\n return tile;\n}\n\nexport function unpackProperties(properties: KeyValueProperties[]): Properties[] {\n if (!properties || !properties.length) {\n return [];\n }\n return properties.map(item => {\n const currentRecord: Properties = {};\n item.data.forEach(({key, value}) => {\n currentRecord[key] = value;\n });\n return currentRecord;\n });\n}\n"],"file":"tile-loader-utils.js"}
|
|
@@ -2,13 +2,52 @@ import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
|
|
2
2
|
import { registerLoaders } from '@loaders.gl/core';
|
|
3
3
|
import CartoSpatialTileLoader from './schema/carto-spatial-tile-loader';
|
|
4
4
|
registerLoaders([CartoSpatialTileLoader]);
|
|
5
|
-
import { TileLayer } from '@deck.gl/geo-layers';
|
|
5
|
+
import { TileLayer, _getURLFromTemplate } from '@deck.gl/geo-layers';
|
|
6
|
+
import { TILE_FORMATS } from '../api/maps-api-common';
|
|
6
7
|
|
|
7
8
|
function isFeatureIdDefined(value) {
|
|
8
9
|
return value !== undefined && value !== null && value !== '';
|
|
9
10
|
}
|
|
10
11
|
|
|
11
12
|
export default class SpatialIndexTileLayer extends TileLayer {
|
|
13
|
+
getTileData(tile) {
|
|
14
|
+
const {
|
|
15
|
+
data,
|
|
16
|
+
getTileData,
|
|
17
|
+
fetch
|
|
18
|
+
} = this.props;
|
|
19
|
+
const {
|
|
20
|
+
signal
|
|
21
|
+
} = tile;
|
|
22
|
+
tile.url = typeof data === 'string' || Array.isArray(data) ? _getURLFromTemplate(data, tile) : null;
|
|
23
|
+
|
|
24
|
+
if (!tile.url) {
|
|
25
|
+
return Promise.reject('Invalid URL');
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
if (getTileData) {
|
|
29
|
+
return getTileData(tile);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
let loadOptions = this.getLoadOptions();
|
|
33
|
+
const {
|
|
34
|
+
formatTiles
|
|
35
|
+
} = this.props;
|
|
36
|
+
|
|
37
|
+
if (formatTiles === TILE_FORMATS.BINARY) {
|
|
38
|
+
loadOptions = { ...loadOptions,
|
|
39
|
+
mimeType: 'application/vnd.carto-spatial-tile'
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
return fetch(tile.url, {
|
|
44
|
+
propName: 'data',
|
|
45
|
+
layer: this,
|
|
46
|
+
loadOptions,
|
|
47
|
+
signal
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
|
|
12
51
|
_updateAutoHighlight(info) {
|
|
13
52
|
const {
|
|
14
53
|
hoveredFeatureId
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/layers/spatial-index-tile-layer.ts"],"names":["registerLoaders","CartoSpatialTileLoader","TileLayer","isFeatureIdDefined","value","undefined","SpatialIndexTileLayer","_updateAutoHighlight","info","hoveredFeatureId","state","hoveredFeature","object","newHoveredFeatureId","id","highlightColor","
|
|
1
|
+
{"version":3,"sources":["../../../src/layers/spatial-index-tile-layer.ts"],"names":["registerLoaders","CartoSpatialTileLoader","TileLayer","_getURLFromTemplate","TILE_FORMATS","isFeatureIdDefined","value","undefined","SpatialIndexTileLayer","getTileData","tile","data","fetch","props","signal","url","Array","isArray","Promise","reject","loadOptions","getLoadOptions","formatTiles","BINARY","mimeType","propName","layer","_updateAutoHighlight","info","hoveredFeatureId","state","hoveredFeature","object","newHoveredFeatureId","id","highlightColor","setState","getSubLayerPropsByTile","highlightedObjectIndex","getHighlightedObjectIndex","content","isFeatureIdPresent","findIndex","feature"],"mappings":";AAAA,SAAQA,eAAR,QAA8B,kBAA9B;AACA,OAAOC,sBAAP,MAAmC,oCAAnC;AACAD,eAAe,CAAC,CAACC,sBAAD,CAAD,CAAf;AAGA,SACEC,SADF,EAEEC,mBAF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AAM;AAACC,MAAAA;AAAD,QAAqB,KAAKC,KAAhC;AACA,UAAMC,cAAc,GAAGH,IAAI,CAACI,MAA5B;AACA,QAAIC,mBAAJ;;AAEA,QAAIF,cAAJ,EAAoB;AAClBE,MAAAA,mBAAmB,GAAGF,cAAc,CAACG,EAArC;AACD;;AAED,QAAIL,gBAAgB,KAAKI,mBAAzB,EAA8C;AAC5C,UAAI;AAACE,QAAAA;AAAD,UAAmB,KAAKtB,KAA5B;;AACA,UAAI,OAAOsB,cAAP,KAA0B,UAA9B,EAA0C;AACxCA,QAAAA,cAAc,GAAGA,cAAc,CAACP,IAAD,CAA/B;AACD;;AAED,WAAKQ,QAAL,CAAc;AACZD,QAAAA,cADY;AAEZN,QAAAA,gBAAgB,EAAEI;AAFN,OAAd;AAID;AACF;;AAEDI,EAAAA,sBAAsB,CAAC3B,IAAD,EAAqB;AACzC,WAAO;AACL4B,MAAAA,sBAAsB,EAAE,KAAKC,yBAAL,CAA+B7B,IAA/B,CADnB;AAELyB,MAAAA,cAAc,EAAE,KAAKL,KAAL,CAAWK;AAFtB,KAAP;AAID;;AAEDI,EAAAA,yBAAyB,CAAC7B,IAAD,EAAqB;AAC5C,UAAM;AAACmB,MAAAA;AAAD,QAAqB,KAAKC,KAAhC;AACA,UAAMnB,IAAI,GAAGD,IAAI,CAAC8B,OAAlB;AAEA,UAAMC,kBAAkB,GAAGpC,kBAAkB,CAACwB,gBAAD,CAA7C;;AACA,QAAI,CAACY,kBAAD,IAAuB,CAACzB,KAAK,CAACC,OAAN,CAAcN,IAAd,CAA5B,EAAiD;AAC/C,aAAO,CAAC,CAAR;AACD;;AAED,WAAOA,IAAI,CAAC+B,SAAL,CAAeC,OAAO,IAAIA,OAAO,CAACT,EAAR,KAAeL,gBAAzC,CAAP;AACD;;AAxE4F;;gBAA1ErB,qB,eACA,uB","sourcesContent":["import {registerLoaders} from '@loaders.gl/core';\nimport CartoSpatialTileLoader from './schema/carto-spatial-tile-loader';\nregisterLoaders([CartoSpatialTileLoader]);\n\nimport {PickingInfo} from '@deck.gl/core';\nimport {\n TileLayer,\n _getURLFromTemplate,\n _Tile2DHeader as Tile2DHeader,\n _TileLoadProps as TileLoadProps\n} from '@deck.gl/geo-layers';\nimport {TILE_FORMATS} from '../api/maps-api-common';\n\nfunction isFeatureIdDefined(value: unknown): boolean {\n return value !== undefined && value !== null && value !== '';\n}\n\nexport default class SpatialIndexTileLayer<ExtraProps = {}> extends TileLayer<any, ExtraProps> {\n static layerName = 'SpatialIndexTileLayer';\n\n getTileData(tile: TileLoadProps) {\n const {data, getTileData, fetch} = this.props;\n const {signal} = tile;\n\n tile.url =\n typeof data === 'string' || Array.isArray(data) ? _getURLFromTemplate(data, tile) : null;\n if (!tile.url) {\n return Promise.reject('Invalid URL');\n }\n\n if (getTileData) {\n return getTileData(tile);\n }\n\n let loadOptions = this.getLoadOptions();\n // @ts-ignore\n const {formatTiles} = this.props;\n\n // The backend doesn't yet support our custom mime-type, so force it here\n // TODO remove entire `getTileData` method once backend sends the correct mime-type\n if (formatTiles === TILE_FORMATS.BINARY) {\n loadOptions = {\n ...loadOptions,\n mimeType: 'application/vnd.carto-spatial-tile'\n };\n }\n\n return fetch(tile.url, {propName: 'data', layer: this, loadOptions, signal});\n }\n\n protected _updateAutoHighlight(info: PickingInfo): void {\n const {hoveredFeatureId} = this.state;\n const hoveredFeature = info.object;\n let newHoveredFeatureId;\n\n if (hoveredFeature) {\n newHoveredFeatureId = hoveredFeature.id;\n }\n\n if (hoveredFeatureId !== newHoveredFeatureId) {\n let {highlightColor} = this.props;\n if (typeof highlightColor === 'function') {\n highlightColor = highlightColor(info);\n }\n\n this.setState({\n highlightColor,\n hoveredFeatureId: newHoveredFeatureId\n });\n }\n }\n\n getSubLayerPropsByTile(tile: Tile2DHeader) {\n return {\n highlightedObjectIndex: this.getHighlightedObjectIndex(tile),\n highlightColor: this.state.highlightColor\n };\n }\n\n getHighlightedObjectIndex(tile: Tile2DHeader) {\n const {hoveredFeatureId} = this.state;\n const data = tile.content;\n\n const isFeatureIdPresent = isFeatureIdDefined(hoveredFeatureId);\n if (!isFeatureIdPresent || !Array.isArray(data)) {\n return -1;\n }\n\n return data.findIndex(feature => feature.id === hoveredFeatureId);\n }\n}\n"],"file":"spatial-index-tile-layer.js"}
|