@loaders.gl/mvt 4.0.3 → 4.1.0-alpha.1

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.
@@ -58,5 +58,11 @@ export type TileJSONField = {
58
58
  /** An array of this attribute's first 100 unique values */
59
59
  values?: unknown[];
60
60
  };
61
+ /**
62
+ * Parse TileJSON from metadata
63
+ * @param jsonMetadata - metadata object
64
+ * @param options - options
65
+ * @returns - parsed TileJSON
66
+ */
61
67
  export declare function parseTileJSON(jsonMetadata: any, options: TileJSONOptions): TileJSON | null;
62
68
  //# sourceMappingURL=parse-tilejson.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"parse-tilejson.d.ts","sourceRoot":"","sources":["../../src/lib/parse-tilejson.ts"],"names":[],"mappings":"AAGA,MAAM,MAAM,eAAe,GAAG;IAC5B,SAAS,CAAC,EAAE,MAAM,GAAG,KAAK,CAAC;CAC5B,CAAC;AAEF,yEAAyE;AACzE,MAAM,MAAM,QAAQ,GAAG;IACrB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,OAAO,CAAC,EAAE,MAAM,CAAC;IAEjB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,WAAW,CAAC,EAAE,MAAM,CAAC;IAErB,oDAAoD;IACpD,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,4DAA4D;IAC5D,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAE1B,2BAA2B;IAC3B,MAAM,CAAC,EAAE,KAAK,GAAG,KAAK,CAAC;IACvB,mBAAmB;IACnB,KAAK,CAAC,EAAE,MAAM,EAAE,CAAC;IACjB,wHAAwH;IACxH,WAAW,CAAC,EAAE,CAAC,GAAG,EAAE,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,CAAC,EAAE,GAAG,EAAE,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,CAAC,CAAC,CA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2FAA2F;IAC3F,IAAI,EAAE,MAAM,CAAC;IAEb,iEAAiE;IACjE,WAAW,CAAC,EAAE,MAAM,CAAC;IAIrB,mEAAmE;IACnE,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,0EAA0E;IAC1E,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,uEAAuE;IAEvE,OAAO;IACP,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,MAAM,EAAE,aAAa,EAAE,CAAC;CACzB,CAAC;AAEF,MAAM,MAAM,aAAa,GAAG;IAC1B,iCAAiC;IACjC,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,CAAC,EAAE,MAAM,CAAC;IAIrB,IAAI,EAAE,MAAM,CAAC;IACb,2DAA2D;IAC3D,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,2DAA2D;IAC3D,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,iDAAiD;IACjD,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,2DAA2D;IAC3D,MAAM,CAAC,EAAE,OAAO,EAAE,CAAC;CACpB,CAAC;AA+CF;;;;;GAKG;AAEH,wBAAgB,aAAa,CAAC,YAAY,EAAE,GAAG,EAAE,OAAO,EAAE,eAAe,GAAG,QAAQ,GAAG,IAAI,CAiE1F"}
@@ -1 +1 @@
1
- {"version":3,"file":"parse-tilejson.js","names":["isObject","x","parseTileJSON","jsonMetadata","options","_tileJSON$metaJson","tileJSON","name","description","generator","generator_options","generatorOptions","boundingBox","parseBounds","bounds","antimeridian_adjusted_bounds","center","parseCenter","maxZoom","safeParseFloat","maxzoom","minZoom","minzoom","json","metaJson","JSON","parse","error","console","warn","tilestats","tileStatsLayers","parseTilestatsLayers","tileJSONlayers","parseTileJSONLayers","vector_layers","layers","mergeLayers","length","Array","isArray","map","layer","parseTileJSONLayer","fields","Object","entries","_ref","key","datatype","attributeTypeToFieldType","String","layer2","id","parseTilestatsForLayer","indexedAttributes","attributes","attribute","split","fname","push","attributeToField","dominantGeometry","geometry","tilestatsLayers","tilestatsLayer","find","tsLayer","result","fromArrayOrString","every","isLng","isLat","undefined","isZoom","input","parseFloat","isNaN","num","Number","isFinite","data","attrTypeMap","number","type","numeric","string","vachar","float","int","int4","boolean","bool","arguments","fieldTypes","field","min","max","count","uniqueValueCount","maxValues","values","_attribute$values","slice","aType","toLowerCase"],"sources":["../../src/lib/parse-tilejson.ts"],"sourcesContent":["// loaders.gl, MIT license\n// Copyright (c) vis.gl contributors\n\nexport type TileJSONOptions = {\n maxValues?: number | false;\n};\n\n/** Parsed and typed TileJSON, merges Tilestats information if present */\nexport type TileJSON = {\n name?: string;\n description?: string;\n version?: string;\n\n tileFormat?: string;\n tilesetType?: string;\n\n /** Generating application. Tippecanoe adds this. */\n generator?: string;\n /** Generating application options. Tippecanoe adds this. */\n generatorOptions?: string;\n\n /** Tile indexing scheme */\n scheme?: 'xyz' | 'tms';\n /** Sharded URLs */\n tiles?: string[];\n /** `[[w, s], [e, n]]`, indicates the limits of the bounding box using the axis units and order of the specified CRS. */\n boundingBox?: [min: [w: number, s: number], max: [e: number, n: number]];\n /** May be set to the maxZoom of the first layer */\n maxZoom?: number | null;\n /** May be set to the minZoom of the first layer */\n minZoom?: number | null;\n center?: number[] | null;\n htmlAttribution?: string;\n htmlLegend?: string;\n\n // Combination of tilestats (if present) and tilejson layer information\n layers?: TileJSONLayer[];\n\n /** Any nested JSON metadata */\n metaJson?: any | null;\n};\n\nexport type TileJSONLayer = {\n /** The name (id) of this layer (tilejson.vector_layers[].id / tilestats.layers[].layer) */\n name: string;\n\n /** The description of this layer (tilejson.layer.description) */\n description?: string;\n\n // tilestats\n\n /** The number of features in this layer (tilestats.layer.count) */\n featureCount?: number;\n /** The dominant geometry type in this layer (tilestats.layer.geometry) */\n dominantGeometry?: string;\n /** An array of details about the first 100 attributes in this layer */\n\n /** */\n minZoom?: number;\n maxZoom?: number;\n fields: TileJSONField[];\n};\n\nexport type TileJSONField = {\n /** The name of this attribute */\n name: string;\n description?: string;\n\n // tilestats\n\n type: string;\n /** min value (if there are *any* numbers in the values) */\n min?: number;\n /** max value (if there are *any* numbers in the values) */\n max?: number;\n /** Number of unique values across the tileset */\n uniqueValueCount?: number;\n /** An array of this attribute's first 100 unique values */\n values?: unknown[];\n};\n\n/**\n * The raw/unparsed tilestats layer type\n * @see https://github.com/mapbox/mapbox-geostats#output-the-stats\n */\ntype TilestatsLayer = {\n /** The name of this layer */\n layer: string;\n /** The number of features in this layer */\n count: number;\n /** The dominant geometry type in this layer */\n geometry: string;\n /** The number of unique attributes in this layer (max. 1000) */\n attributeCount: number;\n /** Fields for this layer */\n attributes?: TilestatsLayerAttribute[];\n};\n\n/**\n * The raw/unparsed tilestats attribute type\n * @see https://github.com/mapbox/mapbox-geostats#output-the-stats\n */\ntype TilestatsLayerAttribute = {\n /** The name of this layer */\n attribute?: string;\n /** Each attribute has one of the following types:\n * - 'string' if all its values are strings (or null).\n * - 'number' if all its values are numbers (or null).\n * - 'boolean' if all its values are booleans (or null).\n * - 'null' if its only value is null.\n * - 'mixed' if it has values of multiple types.\n * - Array and object values are coerced to strings.\n */\n type?: string;\n /** min value (if there are *any* numbers in the values) */\n min?: number;\n /** max value (if there are *any* numbers in the values) */\n max?: number;\n /** Number of unique values */\n count?: number;\n /** First 100 values */\n values?: unknown[];\n};\n\nconst isObject: (x: unknown) => boolean = (x) => x !== null && typeof x === 'object';\n\nexport function parseTileJSON(jsonMetadata: any, options: TileJSONOptions): TileJSON | null {\n if (!jsonMetadata || !isObject(jsonMetadata)) {\n return null;\n }\n\n let tileJSON: TileJSON = {\n name: jsonMetadata.name || '',\n description: jsonMetadata.description || ''\n };\n\n // tippecanoe\n\n if (typeof jsonMetadata.generator === 'string') {\n tileJSON.generator = jsonMetadata.generator;\n }\n if (typeof jsonMetadata.generator_options === 'string') {\n tileJSON.generatorOptions = jsonMetadata.generator_options;\n }\n\n // Tippecanoe emits `antimeridian_adjusted_bounds` instead of `bounds`\n tileJSON.boundingBox =\n parseBounds(jsonMetadata.bounds) || parseBounds(jsonMetadata.antimeridian_adjusted_bounds);\n\n // TODO - can be undefined - we could set to center of bounds...\n tileJSON.center = parseCenter(jsonMetadata.center);\n // TODO - can be undefined, we could extract from layers...\n tileJSON.maxZoom = safeParseFloat(jsonMetadata.maxzoom);\n // TODO - can be undefined, we could extract from layers...\n tileJSON.minZoom = safeParseFloat(jsonMetadata.minzoom);\n\n // Look for nested metadata embedded in .json field\n // TODO - document what source this applies to, when is this needed?\n if (typeof jsonMetadata?.json === 'string') {\n // try to parse json\n try {\n tileJSON.metaJson = JSON.parse(jsonMetadata.json);\n } catch (error) {\n // eslint-disable-next-line no-console\n console.warn('Failed to parse tilejson.json field', error);\n // do nothing\n }\n }\n\n // Look for fields in tilestats\n\n const tilestats = jsonMetadata.tilestats || tileJSON.metaJson?.tilestats;\n const tileStatsLayers = parseTilestatsLayers(tilestats, options);\n const tileJSONlayers = parseTileJSONLayers(jsonMetadata.vector_layers); // eslint-disable-line camelcase\n // TODO - merge in description from tilejson\n const layers = mergeLayers(tileJSONlayers, tileStatsLayers);\n\n tileJSON = {\n ...tileJSON,\n layers\n };\n\n if (tileJSON.maxZoom === null && layers.length > 0) {\n tileJSON.maxZoom = layers[0].maxZoom || null;\n }\n\n if (tileJSON.minZoom === null && layers.length > 0) {\n tileJSON.minZoom = layers[0].minZoom || null;\n }\n\n return tileJSON;\n}\n\nfunction parseTileJSONLayers(layers: any[]): TileJSONLayer[] {\n // Look for fields in vector_layers\n if (!Array.isArray(layers)) {\n return [];\n }\n return layers.map((layer) => parseTileJSONLayer(layer));\n}\n\nfunction parseTileJSONLayer(layer: any): TileJSONLayer {\n const fields = Object.entries(layer.fields || []).map(([key, datatype]) => ({\n name: key,\n ...attributeTypeToFieldType(String(datatype))\n }));\n const layer2 = {...layer};\n delete layer2.fields;\n return {\n name: layer.id || '',\n ...layer2,\n fields\n };\n}\n\n/** parse Layers array from tilestats */\nfunction parseTilestatsLayers(tilestats: any, options: TileJSONOptions): TileJSONLayer[] {\n if (isObject(tilestats) && Array.isArray(tilestats.layers)) {\n // we are in luck!\n return tilestats.layers.map((layer) => parseTilestatsForLayer(layer, options));\n }\n return [];\n}\n\nfunction parseTilestatsForLayer(layer: TilestatsLayer, options: TileJSONOptions): TileJSONLayer {\n const fields: TileJSONField[] = [];\n const indexedAttributes: {[key: string]: TilestatsLayerAttribute[]} = {};\n\n const attributes = layer.attributes || [];\n for (const attribute of attributes) {\n const name = attribute.attribute;\n if (typeof name === 'string') {\n // TODO - code copied from kepler.gl, need sample tilestats files to test\n if (name.split('|').length > 1) {\n // indexed field\n const fname = name.split('|')[0];\n indexedAttributes[fname] = indexedAttributes[fname] || [];\n indexedAttributes[fname].push(attribute);\n // eslint-disable-next-line no-console\n console.warn('ignoring tilestats indexed field', fname);\n } else if (!fields[name]) {\n fields.push(attributeToField(attribute, options));\n } else {\n // return (fields[name], attribute);\n }\n }\n }\n return {\n name: layer.layer || '',\n dominantGeometry: layer.geometry,\n fields\n };\n}\n\nfunction mergeLayers(layers: TileJSONLayer[], tilestatsLayers: TileJSONLayer[]): TileJSONLayer[] {\n return layers.map((layer) => {\n const tilestatsLayer = tilestatsLayers.find((tsLayer) => tsLayer.name === layer.name);\n // For aesthetics in JSON dumps, we preserve field order (make sure layers is last)\n const fields = tilestatsLayer?.fields || [];\n const layer2: Partial<TileJSONLayer> = {...layer};\n delete layer2.fields;\n return {\n ...layer2,\n ...tilestatsLayer,\n fields\n } as TileJSONLayer;\n });\n}\n\n/**\n * bounds should be [minLng, minLat, maxLng, maxLat]\n *`[[w, s], [e, n]]`, indicates the limits of the bounding box using the axis units and order of the specified CRS.\n */\nfunction parseBounds(\n bounds: string | number[]\n): [[east: number, south: number], [west: number, north: number]] | undefined {\n // supported formats\n // string: \"-96.657715,40.126127,-90.140061,43.516689\",\n // array: [ -180, -85.05112877980659, 180, 85.0511287798066 ]\n const result = fromArrayOrString(bounds);\n // validate bounds\n if (\n Array.isArray(result) &&\n result.length === 4 &&\n [result[0], result[2]].every(isLng) &&\n [result[1], result[3]].every(isLat)\n ) {\n return [\n [result[0], result[1]],\n [result[2], result[3]]\n ];\n }\n return undefined;\n}\n\nfunction parseCenter(center: string | number[]): number[] | null {\n // supported formats\n // string: \"-96.657715,40.126127,-90.140061,43.516689\",\n // array: [-91.505127,41.615442,14]\n const result = fromArrayOrString(center);\n if (\n Array.isArray(result) &&\n result.length === 3 &&\n isLng(result[0]) &&\n isLat(result[1]) &&\n isZoom(result[2])\n ) {\n return result;\n }\n return null;\n}\n\nfunction safeParseFloat(input: unknown): number | null {\n const result =\n typeof input === 'string' ? parseFloat(input) : typeof input === 'number' ? input : null;\n return result === null || isNaN(result) ? null : result;\n}\n\n// https://github.com/mapbox/tilejson-spec/tree/master/2.2.0\nfunction isLat(num: any): boolean {\n return Number.isFinite(num) && num <= 90 && num >= -90;\n}\nfunction isLng(num: any): boolean {\n return Number.isFinite(num) && num <= 180 && num >= -180;\n}\nfunction isZoom(num: any): boolean {\n return Number.isFinite(num) && num >= 0 && num <= 22;\n}\nfunction fromArrayOrString(data: string | number[]): number[] | null {\n if (typeof data === 'string') {\n return data.split(',').map(parseFloat);\n } else if (Array.isArray(data)) {\n return data;\n }\n return null;\n}\n\n// possible types https://github.com/mapbox/tippecanoe#modifying-feature-attributes\nconst attrTypeMap = {\n number: {\n type: 'float32'\n },\n numeric: {\n type: 'float32'\n },\n string: {\n type: 'utf8'\n },\n vachar: {\n type: 'utf8'\n },\n float: {\n type: 'float32'\n },\n int: {\n type: 'int32'\n },\n int4: {\n type: 'int32'\n },\n boolean: {\n type: 'boolean'\n },\n bool: {\n type: 'boolean'\n }\n};\n\nfunction attributeToField(\n attribute: TilestatsLayerAttribute = {},\n options: TileJSONOptions\n): TileJSONField {\n const fieldTypes = attributeTypeToFieldType(attribute.type!);\n const field: TileJSONField = {\n name: attribute.attribute as string,\n // what happens if attribute type is string...\n // filterProps: getFilterProps(fieldTypes.type, attribute),\n ...fieldTypes\n };\n\n // attribute: \"_season_peaks_color\"\n // count: 1000\n // max: 0.95\n // min: 0.24375\n // type: \"number\"\n\n if (typeof attribute.min === 'number') {\n field.min = attribute.min;\n }\n if (typeof attribute.max === 'number') {\n field.max = attribute.max;\n }\n if (typeof attribute.count === 'number') {\n field.uniqueValueCount = attribute.count;\n }\n if (options.maxValues !== false && attribute.values) {\n // Too much data? Add option?\n field.values = attribute.values?.slice(0, options.maxValues);\n }\n return field;\n}\n\nfunction attributeTypeToFieldType(aType: string): {type: string} {\n const type = aType.toLowerCase();\n if (!type || !attrTypeMap[type]) {\n // console.warn(\n // `cannot convert attribute type ${type} to loaders.gl data type, use string by default`\n // );\n }\n return attrTypeMap[type] || {type: 'string'};\n}\n"],"mappings":"AA4HA,MAAMA,QAAiC,GAAIC,CAAC,IAAKA,CAAC,KAAK,IAAI,IAAI,OAAOA,CAAC,KAAK,QAAQ;AAEpF,OAAO,SAASC,aAAaA,CAACC,YAAiB,EAAEC,OAAwB,EAAmB;EAAA,IAAAC,kBAAA;EAC1F,IAAI,CAACF,YAAY,IAAI,CAACH,QAAQ,CAACG,YAAY,CAAC,EAAE;IAC5C,OAAO,IAAI;EACb;EAEA,IAAIG,QAAkB,GAAG;IACvBC,IAAI,EAAEJ,YAAY,CAACI,IAAI,IAAI,EAAE;IAC7BC,WAAW,EAAEL,YAAY,CAACK,WAAW,IAAI;EAC3C,CAAC;EAID,IAAI,OAAOL,YAAY,CAACM,SAAS,KAAK,QAAQ,EAAE;IAC9CH,QAAQ,CAACG,SAAS,GAAGN,YAAY,CAACM,SAAS;EAC7C;EACA,IAAI,OAAON,YAAY,CAACO,iBAAiB,KAAK,QAAQ,EAAE;IACtDJ,QAAQ,CAACK,gBAAgB,GAAGR,YAAY,CAACO,iBAAiB;EAC5D;EAGAJ,QAAQ,CAACM,WAAW,GAClBC,WAAW,CAACV,YAAY,CAACW,MAAM,CAAC,IAAID,WAAW,CAACV,YAAY,CAACY,4BAA4B,CAA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;EAC/D,MAAMpB,IAAI,GAAGoB,KAAK,CAACC,WAAW,CAAC,CAAC;EAChC,IAAI,CAACrB,IAAI,IAAI,CAACF,WAAW,CAACE,IAAI,CAAC,EAAE,CAIjC;EACA,OAAOF,WAAW,CAACE,IAAI,CAAC,IAAI;IAACA,IAAI,EAAE;EAAQ,CAAC;AAC9C"}
1
+ {"version":3,"file":"parse-tilejson.js","names":["isObject","x","parseTileJSON","jsonMetadata","options","_tileJSON$metaJson","tileJSON","name","description","generator","generator_options","generatorOptions","boundingBox","parseBounds","bounds","antimeridian_adjusted_bounds","center","parseCenter","maxZoom","safeParseFloat","maxzoom","minZoom","minzoom","json","metaJson","JSON","parse","error","console","warn","tilestats","tileStatsLayers","parseTilestatsLayers","tileJSONlayers","parseTileJSONLayers","vector_layers","layers","mergeLayers","length","Array","isArray","map","layer","parseTileJSONLayer","fields","Object","entries","_ref","key","datatype","attributeTypeToFieldType","String","layer2","id","parseTilestatsForLayer","indexedAttributes","attributes","attribute","split","fname","push","attributeToField","dominantGeometry","geometry","tilestatsLayers","tilestatsLayer","find","tsLayer","result","fromArrayOrString","every","isLng","isLat","undefined","isZoom","input","parseFloat","isNaN","num","Number","isFinite","data","attrTypeMap","number","type","numeric","string","vachar","float","int","int4","boolean","bool","arguments","fieldTypes","field","min","max","count","uniqueValueCount","maxValues","values","_attribute$values","slice","aType","toLowerCase"],"sources":["../../src/lib/parse-tilejson.ts"],"sourcesContent":["// loaders.gl, MIT license\n// Copyright (c) vis.gl contributors\n\nexport type TileJSONOptions = {\n maxValues?: number | false;\n};\n\n/** Parsed and typed TileJSON, merges Tilestats information if present */\nexport type TileJSON = {\n name?: string;\n description?: string;\n version?: string;\n\n tileFormat?: string;\n tilesetType?: string;\n\n /** Generating application. Tippecanoe adds this. */\n generator?: string;\n /** Generating application options. Tippecanoe adds this. */\n generatorOptions?: string;\n\n /** Tile indexing scheme */\n scheme?: 'xyz' | 'tms';\n /** Sharded URLs */\n tiles?: string[];\n /** `[[w, s], [e, n]]`, indicates the limits of the bounding box using the axis units and order of the specified CRS. */\n boundingBox?: [min: [w: number, s: number], max: [e: number, n: number]];\n /** May be set to the maxZoom of the first layer */\n maxZoom?: number | null;\n /** May be set to the minZoom of the first layer */\n minZoom?: number | null;\n center?: number[] | null;\n htmlAttribution?: string;\n htmlLegend?: string;\n\n // Combination of tilestats (if present) and tilejson layer information\n layers?: TileJSONLayer[];\n\n /** Any nested JSON metadata */\n metaJson?: any | null;\n};\n\nexport type TileJSONLayer = {\n /** The name (id) of this layer (tilejson.vector_layers[].id / tilestats.layers[].layer) */\n name: string;\n\n /** The description of this layer (tilejson.layer.description) */\n description?: string;\n\n // tilestats\n\n /** The number of features in this layer (tilestats.layer.count) */\n featureCount?: number;\n /** The dominant geometry type in this layer (tilestats.layer.geometry) */\n dominantGeometry?: string;\n /** An array of details about the first 100 attributes in this layer */\n\n /** */\n minZoom?: number;\n maxZoom?: number;\n fields: TileJSONField[];\n};\n\nexport type TileJSONField = {\n /** The name of this attribute */\n name: string;\n description?: string;\n\n // tilestats\n\n type: string;\n /** min value (if there are *any* numbers in the values) */\n min?: number;\n /** max value (if there are *any* numbers in the values) */\n max?: number;\n /** Number of unique values across the tileset */\n uniqueValueCount?: number;\n /** An array of this attribute's first 100 unique values */\n values?: unknown[];\n};\n\n/**\n * The raw/unparsed tilestats layer type\n * @see https://github.com/mapbox/mapbox-geostats#output-the-stats\n */\ntype TilestatsLayer = {\n /** The name of this layer */\n layer: string;\n /** The number of features in this layer */\n count: number;\n /** The dominant geometry type in this layer */\n geometry: string;\n /** The number of unique attributes in this layer (max. 1000) */\n attributeCount: number;\n /** Fields for this layer */\n attributes?: TilestatsLayerAttribute[];\n};\n\n/**\n * The raw/unparsed tilestats attribute type\n * @see https://github.com/mapbox/mapbox-geostats#output-the-stats\n */\ntype TilestatsLayerAttribute = {\n /** The name of this layer */\n attribute?: string;\n /** Each attribute has one of the following types:\n * - 'string' if all its values are strings (or null).\n * - 'number' if all its values are numbers (or null).\n * - 'boolean' if all its values are booleans (or null).\n * - 'null' if its only value is null.\n * - 'mixed' if it has values of multiple types.\n * - Array and object values are coerced to strings.\n */\n type?: string;\n /** min value (if there are *any* numbers in the values) */\n min?: number;\n /** max value (if there are *any* numbers in the values) */\n max?: number;\n /** Number of unique values */\n count?: number;\n /** First 100 values */\n values?: unknown[];\n};\n\nconst isObject: (x: unknown) => boolean = (x) => x !== null && typeof x === 'object';\n\n/**\n * Parse TileJSON from metadata\n * @param jsonMetadata - metadata object\n * @param options - options\n * @returns - parsed TileJSON\n */\n// eslint-disable-next-line complexity\nexport function parseTileJSON(jsonMetadata: any, options: TileJSONOptions): TileJSON | null {\n if (!jsonMetadata || !isObject(jsonMetadata)) {\n return null;\n }\n\n let tileJSON: TileJSON = {\n name: jsonMetadata.name || '',\n description: jsonMetadata.description || ''\n };\n\n // tippecanoe\n\n if (typeof jsonMetadata.generator === 'string') {\n tileJSON.generator = jsonMetadata.generator;\n }\n if (typeof jsonMetadata.generator_options === 'string') {\n tileJSON.generatorOptions = jsonMetadata.generator_options;\n }\n\n // Tippecanoe emits `antimeridian_adjusted_bounds` instead of `bounds`\n tileJSON.boundingBox =\n parseBounds(jsonMetadata.bounds) || parseBounds(jsonMetadata.antimeridian_adjusted_bounds);\n\n // TODO - can be undefined - we could set to center of bounds...\n tileJSON.center = parseCenter(jsonMetadata.center);\n // TODO - can be undefined, we could extract from layers...\n tileJSON.maxZoom = safeParseFloat(jsonMetadata.maxzoom);\n // TODO - can be undefined, we could extract from layers...\n tileJSON.minZoom = safeParseFloat(jsonMetadata.minzoom);\n\n // Look for nested metadata embedded in .json field\n // TODO - document what source this applies to, when is this needed?\n if (typeof jsonMetadata?.json === 'string') {\n // try to parse json\n try {\n tileJSON.metaJson = JSON.parse(jsonMetadata.json);\n } catch (error) {\n // eslint-disable-next-line no-console\n console.warn('Failed to parse tilejson.json field', error);\n // do nothing\n }\n }\n\n // Look for fields in tilestats\n\n const tilestats = jsonMetadata.tilestats || tileJSON.metaJson?.tilestats;\n const tileStatsLayers = parseTilestatsLayers(tilestats, options);\n const tileJSONlayers = parseTileJSONLayers(jsonMetadata.vector_layers); // eslint-disable-line camelcase\n // TODO - merge in description from tilejson\n const layers = mergeLayers(tileJSONlayers, tileStatsLayers);\n\n tileJSON = {\n ...tileJSON,\n layers\n };\n\n if (tileJSON.maxZoom === null && layers.length > 0) {\n tileJSON.maxZoom = layers[0].maxZoom || null;\n }\n\n if (tileJSON.minZoom === null && layers.length > 0) {\n tileJSON.minZoom = layers[0].minZoom || null;\n }\n\n return tileJSON;\n}\n\nfunction parseTileJSONLayers(layers: any[]): TileJSONLayer[] {\n // Look for fields in vector_layers\n if (!Array.isArray(layers)) {\n return [];\n }\n return layers.map((layer) => parseTileJSONLayer(layer));\n}\n\nfunction parseTileJSONLayer(layer: any): TileJSONLayer {\n const fields = Object.entries(layer.fields || []).map(([key, datatype]) => ({\n name: key,\n ...attributeTypeToFieldType(String(datatype))\n }));\n const layer2 = {...layer};\n delete layer2.fields;\n return {\n name: layer.id || '',\n ...layer2,\n fields\n };\n}\n\n/** parse Layers array from tilestats */\nfunction parseTilestatsLayers(tilestats: any, options: TileJSONOptions): TileJSONLayer[] {\n if (isObject(tilestats) && Array.isArray(tilestats.layers)) {\n // we are in luck!\n return tilestats.layers.map((layer) => parseTilestatsForLayer(layer, options));\n }\n return [];\n}\n\nfunction parseTilestatsForLayer(layer: TilestatsLayer, options: TileJSONOptions): TileJSONLayer {\n const fields: TileJSONField[] = [];\n const indexedAttributes: {[key: string]: TilestatsLayerAttribute[]} = {};\n\n const attributes = layer.attributes || [];\n for (const attribute of attributes) {\n const name = attribute.attribute;\n if (typeof name === 'string') {\n // TODO - code copied from kepler.gl, need sample tilestats files to test\n if (name.split('|').length > 1) {\n // indexed field\n const fname = name.split('|')[0];\n indexedAttributes[fname] = indexedAttributes[fname] || [];\n indexedAttributes[fname].push(attribute);\n // eslint-disable-next-line no-console\n console.warn('ignoring tilestats indexed field', fname);\n } else if (!fields[name]) {\n fields.push(attributeToField(attribute, options));\n } else {\n // return (fields[name], attribute);\n }\n }\n }\n return {\n name: layer.layer || '',\n dominantGeometry: layer.geometry,\n fields\n };\n}\n\nfunction mergeLayers(layers: TileJSONLayer[], tilestatsLayers: TileJSONLayer[]): TileJSONLayer[] {\n return layers.map((layer) => {\n const tilestatsLayer = tilestatsLayers.find((tsLayer) => tsLayer.name === layer.name);\n // For aesthetics in JSON dumps, we preserve field order (make sure layers is last)\n const fields = tilestatsLayer?.fields || [];\n const layer2: Partial<TileJSONLayer> = {...layer};\n delete layer2.fields;\n return {\n ...layer2,\n ...tilestatsLayer,\n fields\n } as TileJSONLayer;\n });\n}\n\n/**\n * bounds should be [minLng, minLat, maxLng, maxLat]\n *`[[w, s], [e, n]]`, indicates the limits of the bounding box using the axis units and order of the specified CRS.\n */\nfunction parseBounds(\n bounds: string | number[]\n): [[east: number, south: number], [west: number, north: number]] | undefined {\n // supported formats\n // string: \"-96.657715,40.126127,-90.140061,43.516689\",\n // array: [ -180, -85.05112877980659, 180, 85.0511287798066 ]\n const result = fromArrayOrString(bounds);\n // validate bounds\n if (\n Array.isArray(result) &&\n result.length === 4 &&\n [result[0], result[2]].every(isLng) &&\n [result[1], result[3]].every(isLat)\n ) {\n return [\n [result[0], result[1]],\n [result[2], result[3]]\n ];\n }\n return undefined;\n}\n\nfunction parseCenter(center: string | number[]): number[] | null {\n // supported formats\n // string: \"-96.657715,40.126127,-90.140061,43.516689\",\n // array: [-91.505127,41.615442,14]\n const result = fromArrayOrString(center);\n if (\n Array.isArray(result) &&\n result.length === 3 &&\n isLng(result[0]) &&\n isLat(result[1]) &&\n isZoom(result[2])\n ) {\n return result;\n }\n return null;\n}\n\nfunction safeParseFloat(input: unknown): number | null {\n const result =\n typeof input === 'string' ? parseFloat(input) : typeof input === 'number' ? input : null;\n return result === null || isNaN(result) ? null : result;\n}\n\n// https://github.com/mapbox/tilejson-spec/tree/master/2.2.0\nfunction isLat(num: any): boolean {\n return Number.isFinite(num) && num <= 90 && num >= -90;\n}\nfunction isLng(num: any): boolean {\n return Number.isFinite(num) && num <= 180 && num >= -180;\n}\nfunction isZoom(num: any): boolean {\n return Number.isFinite(num) && num >= 0 && num <= 22;\n}\nfunction fromArrayOrString(data: string | number[]): number[] | null {\n if (typeof data === 'string') {\n return data.split(',').map(parseFloat);\n } else if (Array.isArray(data)) {\n return data;\n }\n return null;\n}\n\n// possible types https://github.com/mapbox/tippecanoe#modifying-feature-attributes\nconst attrTypeMap = {\n number: {\n type: 'float32'\n },\n numeric: {\n type: 'float32'\n },\n string: {\n type: 'utf8'\n },\n vachar: {\n type: 'utf8'\n },\n float: {\n type: 'float32'\n },\n int: {\n type: 'int32'\n },\n int4: {\n type: 'int32'\n },\n boolean: {\n type: 'boolean'\n },\n bool: {\n type: 'boolean'\n }\n};\n\nfunction attributeToField(\n attribute: TilestatsLayerAttribute = {},\n options: TileJSONOptions\n): TileJSONField {\n const fieldTypes = attributeTypeToFieldType(attribute.type!);\n const field: TileJSONField = {\n name: attribute.attribute as string,\n // what happens if attribute type is string...\n // filterProps: getFilterProps(fieldTypes.type, attribute),\n ...fieldTypes\n };\n\n // attribute: \"_season_peaks_color\"\n // count: 1000\n // max: 0.95\n // min: 0.24375\n // type: \"number\"\n\n if (typeof attribute.min === 'number') {\n field.min = attribute.min;\n }\n if (typeof attribute.max === 'number') {\n field.max = attribute.max;\n }\n if (typeof attribute.count === 'number') {\n field.uniqueValueCount = attribute.count;\n }\n if (options.maxValues !== false && attribute.values) {\n // Too much data? Add option?\n field.values = attribute.values?.slice(0, options.maxValues);\n }\n return field;\n}\n\nfunction attributeTypeToFieldType(aType: string): {type: string} {\n const type = aType.toLowerCase();\n if (!type || !attrTypeMap[type]) {\n // console.warn(\n // `cannot convert attribute type ${type} to loaders.gl data type, use string by default`\n // );\n }\n return attrTypeMap[type] || {type: 'string'};\n}\n"],"mappings":"AA4HA,MAAMA,QAAiC,GAAIC,CAAC,IAAKA,CAAC,KAAK,I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CAAC;EAQD,IAAI,OAAOrC,SAAS,CAACuC,GAAG,KAAK,QAAQ,EAAE;IACrCD,KAAK,CAACC,GAAG,GAAGvC,SAAS,CAACuC,GAAG;EAC3B;EACA,IAAI,OAAOvC,SAAS,CAACwC,GAAG,KAAK,QAAQ,EAAE;IACrCF,KAAK,CAACE,GAAG,GAAGxC,SAAS,CAACwC,GAAG;EAC3B;EACA,IAAI,OAAOxC,SAAS,CAACyC,KAAK,KAAK,QAAQ,EAAE;IACvCH,KAAK,CAACI,gBAAgB,GAAG1C,SAAS,CAACyC,KAAK;EAC1C;EACA,IAAI9F,OAAO,CAACgG,SAAS,KAAK,KAAK,IAAI3C,SAAS,CAAC4C,MAAM,EAAE;IAAA,IAAAC,iBAAA;IAEnDP,KAAK,CAACM,MAAM,IAAAC,iBAAA,GAAG7C,SAAS,CAAC4C,MAAM,cAAAC,iBAAA,uBAAhBA,iBAAA,CAAkBC,KAAK,CAAC,CAAC,EAAEnG,OAAO,CAACgG,SAAS,CAAC;EAC9D;EACA,OAAOL,KAAK;AACd;AAEA,SAAS7C,wBAAwBA,CAACsD,KAAa,EAAkB;EAC/D,MAAMpB,IAAI,GAAGoB,KAAK,CAACC,WAAW,CAAC,CAAC;EAChC,IAAI,CAACrB,IAAI,IAAI,CAACF,WAAW,CAACE,IAAI,CAAC,EAAE,CAIjC;EACA,OAAOF,WAAW,CAACE,IAAI,CAAC,IAAI;IAACA,IAAI,EAAE;EAAQ,CAAC;AAC9C"}
@@ -2303,7 +2303,7 @@
2303
2303
  }
2304
2304
 
2305
2305
  // src/mvt-loader.ts
2306
- var VERSION = true ? "4.0.3" : "latest";
2306
+ var VERSION = true ? "4.1.0-alpha.1" : "latest";
2307
2307
  var MVTWorkerLoader = {
2308
2308
  name: "Mapbox Vector Tile",
2309
2309
  id: "mvt",
@@ -2336,6 +2336,9 @@
2336
2336
  binary: true
2337
2337
  };
2338
2338
 
2339
+ // ../worker-utils/src/lib/node/worker_threads-browser.ts
2340
+ var parentPort = null;
2341
+
2339
2342
  // ../worker-utils/src/lib/worker-utils/get-transfer-list.ts
2340
2343
  function getTransferList(object, recursive = true, transfers) {
2341
2344
  const transfersSet = transfers || /* @__PURE__ */ new Set();
@@ -2373,19 +2376,6 @@
2373
2376
 
2374
2377
  // ../worker-utils/src/lib/worker-farm/worker-body.ts
2375
2378
  async function getParentPort() {
2376
- let parentPort;
2377
- try {
2378
- eval("globalThis.parentPort = require('worker_threads').parentPort");
2379
- parentPort = globalThis.parentPort;
2380
- } catch {
2381
- try {
2382
- eval("globalThis.workerThreadsPromise = import('worker_threads')");
2383
- const workerThreads = await globalThis.workerThreadsPromise;
2384
- parentPort = workerThreads.parentPort;
2385
- } catch (error) {
2386
- console.error(error.message);
2387
- }
2388
- }
2389
2379
  return parentPort;
2390
2380
  }
2391
2381
  var onMessageWrapperMap = /* @__PURE__ */ new Map();
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@loaders.gl/mvt",
3
3
  "description": "Loader for Mapbox Vector Tiles",
4
- "version": "4.0.3",
4
+ "version": "4.1.0-alpha.1",
5
5
  "license": "MIT",
6
6
  "type": "module",
7
7
  "publishConfig": {
@@ -40,15 +40,15 @@
40
40
  "build-worker": "esbuild src/workers/mvt-worker.ts --bundle --outfile=dist/mvt-worker.js --define:__VERSION__=\\\"$npm_package_version\\\""
41
41
  },
42
42
  "dependencies": {
43
- "@loaders.gl/gis": "4.0.3",
44
- "@loaders.gl/images": "4.0.3",
45
- "@loaders.gl/loader-utils": "4.0.3",
46
- "@loaders.gl/schema": "4.0.3",
43
+ "@loaders.gl/gis": "4.1.0-alpha.1",
44
+ "@loaders.gl/images": "4.1.0-alpha.1",
45
+ "@loaders.gl/loader-utils": "4.1.0-alpha.1",
46
+ "@loaders.gl/schema": "4.1.0-alpha.1",
47
47
  "@math.gl/polygon": "^4.0.0",
48
48
  "pbf": "^3.2.1"
49
49
  },
50
50
  "devDependencies": {
51
51
  "@types/pbf": "^3.0.2"
52
52
  },
53
- "gitHead": "03c871839b36c997249dabae1844df53a35d3760"
53
+ "gitHead": "6a4d3da93d45115ad99861474a43c3f4a0b280a7"
54
54
  }
@@ -124,6 +124,13 @@ type TilestatsLayerAttribute = {
124
124
 
125
125
  const isObject: (x: unknown) => boolean = (x) => x !== null && typeof x === 'object';
126
126
 
127
+ /**
128
+ * Parse TileJSON from metadata
129
+ * @param jsonMetadata - metadata object
130
+ * @param options - options
131
+ * @returns - parsed TileJSON
132
+ */
133
+ // eslint-disable-next-line complexity
127
134
  export function parseTileJSON(jsonMetadata: any, options: TileJSONOptions): TileJSON | null {
128
135
  if (!jsonMetadata || !isObject(jsonMetadata)) {
129
136
  return null;