{"version":3,"file":"geojson-vt.mjs","names":[],"sources":["../src/simplify.ts","../src/feature.ts","../src/convert.ts","../src/deconvert.ts","../src/clip.ts","../src/wrap.ts","../src/difference.ts","../node_modules/kdbush/index.js","../src/cluster-tile-index.ts","../src/tile.ts","../src/transform.ts","../src/tile-index.ts","../src/geojsonvt.ts","../src/geojson-to-tile.ts"],"sourcesContent":["/**\n * calculate simplification data using optimized Douglas-Peucker algorithm\n * @param coords - flat array of coordinates\n * @param first - index of the first coordinate in the segment\n * @param last - index of the last coordinate in the segment\n * @param sqTolerance - square tolerance value\n */\nexport function simplify(coords: number[], first: number, last: number, sqTolerance: number) {\n let maxSqDist = sqTolerance;\n const mid = first + ((last - first) >> 1);\n let minPosToMid = last - first;\n let index;\n\n const ax = coords[first];\n const ay = coords[first + 1];\n const bx = coords[last];\n const by = coords[last + 1];\n\n for (let i = first + 3; i < last; i += 3) {\n const d = getSqSegDist(coords[i], coords[i + 1], ax, ay, bx, by);\n\n if (d > maxSqDist) {\n index = i;\n maxSqDist = d;\n continue;\n }\n\n if (d === maxSqDist) {\n // a workaround to ensure we choose a pivot close to the middle of the list,\n // reducing recursion depth, for certain degenerate inputs\n // https://github.com/mapbox/geojson-vt/issues/104\n const posToMid = Math.abs(i - mid);\n if (posToMid < minPosToMid) {\n index = i;\n minPosToMid = posToMid;\n }\n }\n }\n\n if (maxSqDist > sqTolerance) {\n if (index - first > 3) simplify(coords, first, index, sqTolerance);\n coords[index + 2] = maxSqDist;\n if (last - index > 3) simplify(coords, index, last, sqTolerance);\n }\n}\n\n/**\n * Claculates the square distance from a point to a segment\n * @param px - x coordinate of the point\n * @param py - y coordinate of the point\n * @param x - x coordinate of the first segment endpoint\n * @param y - y coordinate of the first segment endpoint\n * @param bx - x coordinate of the second segment endpoint\n * @param by - y coordinate of the second segment endpoint\n * @returns square distance from a point to a segment\n */\nfunction getSqSegDist(px: number, py: number, x: number, y: number, bx: number, by: number): number {\n let dx = bx - x;\n let dy = by - y;\n\n if (dx !== 0 || dy !== 0) {\n const t = ((px - x) * dx + (py - y) * dy) / (dx * dx + dy * dy);\n\n if (t > 1) {\n x = bx;\n y = by;\n\n } else if (t > 0) {\n x += dx * t;\n y += dy * t;\n }\n }\n\n dx = px - x;\n dy = py - y;\n\n return dx * dx + dy * dy;\n}\n","import type { GeoJSONVTInternalFeature, GeoJSONVTInternalLineStringFeature, GeoJSONVTInternalMultiLineStringFeature, GeoJSONVTInternalMultiPointFeature, GeoJSONVTInternalMultiPolygonFeature, GeoJSONVTInternalPointFeature, GeoJSONVTInternalPolygonFeature, SliceArray, SliceFixedArray } from \"./definitions\";\n\ntype FeatureTypeMap = {\n Point: GeoJSONVTInternalPointFeature[\"geometry\"];\n MultiPoint: GeoJSONVTInternalMultiPointFeature[\"geometry\"];\n LineString: GeoJSONVTInternalLineStringFeature[\"geometry\"];\n MultiLineString: GeoJSONVTInternalMultiLineStringFeature[\"geometry\"];\n Polygon: GeoJSONVTInternalPolygonFeature[\"geometry\"];\n MultiPolygon: GeoJSONVTInternalMultiPolygonFeature[\"geometry\"];\n};\n\n/**\n * \n * @param id - the feature's ID\n * @param type - the feature's type\n * @param geom - the feature's geometry\n * @param tags - the feature's properties\n * @returns the created feature\n */\nexport function createFeature(id: number | string | undefined, type: T, geom: FeatureTypeMap[T], tags: GeoJSON.GeoJsonProperties): GeoJSONVTInternalFeature {\n // This is mostly for TypeScript type narrowing\n const data = { type, geom } as { [K in GeoJSONVTInternalFeature[\"type\"]]: { type: K, geom: FeatureTypeMap[K] } }[GeoJSONVTInternalFeature[\"type\"]];\n\n const feature = {\n id: id == null ? null : id,\n type: data.type,\n geometry: data.geom,\n tags,\n minX: Infinity,\n minY: Infinity,\n maxX: -Infinity,\n maxY: -Infinity\n } as GeoJSONVTInternalFeature;\n\n switch (data.type) {\n case 'Point':\n case 'MultiPoint':\n calcLineBBox(feature, data.geom);\n break;\n\n case 'LineString':\n calcLineBBox(feature, data.geom.points);\n break;\n\n case 'Polygon':\n // the outer ring (ie [0]) contains all inner rings\n calcLineBBox(feature, data.geom[0].points);\n break;\n\n case 'MultiLineString':\n for (const line of data.geom) {\n calcLineBBox(feature, line.points);\n }\n break;\n\n case 'MultiPolygon':\n for (const polygon of data.geom) {\n // the outer ring (ie [0]) contains all inner rings\n calcLineBBox(feature, polygon[0].points);\n }\n break;\n }\n\n return feature;\n}\n\nexport function optimizeLineMemory(line: SliceArray) {\n const lineImmutable = line as SliceFixedArray;\n if (line.points.length > 64) {\n lineImmutable.points = new Float64Array(line.points);\n }\n}\n\nfunction calcLineBBox(feature: GeoJSONVTInternalFeature, geom: number[] | Float64Array) {\n for (let i = 0; i < geom.length; i += 3) {\n feature.minX = Math.min(feature.minX, geom[i]);\n feature.minY = Math.min(feature.minY, geom[i + 1]);\n feature.maxX = Math.max(feature.maxX, geom[i]);\n feature.maxY = Math.max(feature.maxY, geom[i + 1]);\n }\n}\n","\nimport {simplify} from './simplify';\nimport {createFeature, optimizeLineMemory} from './feature';\nimport type {GeoJSONVTInternalFeature, GeoJSONVTOptions, SliceArray} from './definitions';\n\nconst MAX_GEOMETRY_COLLECTION_DEPTH = 1024;\n\n/**\n * converts GeoJSON to internal source features (an intermediate projected JSON vector format with simplification data)\n * @param data\n * @param options\n * @returns\n */\nexport function convertToInternal(data: GeoJSON.GeoJSON, options: GeoJSONVTOptions): GeoJSONVTInternalFeature[] {\n const features: GeoJSONVTInternalFeature[] = [];\n\n switch (data.type) {\n case 'FeatureCollection':\n for (let i = 0; i < data.features.length; i++) {\n featureToInternal(features, data.features[i], options, i);\n }\n break;\n case 'Feature':\n featureToInternal(features, data, options);\n break;\n default:\n featureToInternal(features, {type: \"Feature\" as const, geometry: data, properties: undefined}, options);\n }\n\n return features;\n}\n\nfunction featureToInternal(features: GeoJSONVTInternalFeature[], geojson: GeoJSON.Feature, options: GeoJSONVTOptions, index?: number, depth = 0) {\n if (!geojson.geometry) return;\n\n if (depth > MAX_GEOMETRY_COLLECTION_DEPTH) {\n throw new Error('GeometryCollection nesting exceeds supported depth: ' + MAX_GEOMETRY_COLLECTION_DEPTH);\n }\n\n if (geojson.geometry.type === 'GeometryCollection') {\n convertGeometryCollection(features, geojson, geojson.geometry, options, index, depth + 1);\n return;\n }\n\n const coords = geojson.geometry.coordinates;\n if (!coords?.length) return;\n\n const id = getFeatureId(geojson, options, index);\n const tolerance = Math.pow(options.tolerance / ((1 << options.maxZoom) * options.extent), 2);\n\n switch (geojson.geometry.type) {\n case 'Point':\n convertPointFeature(features, id, geojson.geometry, geojson.properties);\n return;\n\n case 'MultiPoint':\n convertMultiPointFeature(features, id, geojson.geometry, geojson.properties);\n return;\n\n case 'LineString':\n convertLineStringFeature(features, id, geojson.geometry, tolerance, geojson.properties);\n return;\n\n case 'MultiLineString':\n convertMultiLineStringFeature(features, id, geojson.geometry, tolerance, options, geojson.properties);\n return;\n\n case 'Polygon':\n convertPolygonFeature(features, id, geojson.geometry, tolerance, geojson.properties);\n return;\n\n case 'MultiPolygon':\n convertMultiPolygonFeature(features, id, geojson.geometry, tolerance, geojson.properties);\n return;\n\n default:\n throw new Error('Input data is not a valid GeoJSON object.');\n }\n}\n\nfunction getFeatureId(geojson: GeoJSON.Feature, options: GeoJSONVTOptions, index?: number): number | string | undefined {\n if (options.promoteId) {\n return geojson.properties?.[options.promoteId];\n }\n if (options.generateId) {\n return index || 0;\n }\n return geojson.id;\n}\n\nfunction convertGeometryCollection(features: GeoJSONVTInternalFeature[], geojson: GeoJSON.Feature, geometry: GeoJSON.GeometryCollection, options: GeoJSONVTOptions, index?: number, depth = 0) {\n for (const geom of geometry.geometries) {\n featureToInternal(features, {\n id: geojson.id,\n type: 'Feature',\n geometry: geom,\n properties: geojson.properties\n }, options, index, depth);\n }\n}\n\nfunction convertPointFeature(features: GeoJSONVTInternalFeature[], id: number | string | undefined, geom: GeoJSON.Point, properties: GeoJSON.GeoJsonProperties) {\n const out: number[] = [];\n out.push(projectX(geom.coordinates[0]), projectY(geom.coordinates[1]), 0);\n features.push(createFeature(id, 'Point', out, properties));\n}\n\nfunction convertMultiPointFeature(features: GeoJSONVTInternalFeature[], id: number | string | undefined, geom: GeoJSON.MultiPoint, properties: GeoJSON.GeoJsonProperties) {\n const out: number[] = [];\n for (const coords of geom.coordinates) {\n out.push(projectX(coords[0]), projectY(coords[1]), 0);\n }\n features.push(createFeature(id, 'MultiPoint', out, properties));\n}\n\nfunction convertLineStringFeature(features: GeoJSONVTInternalFeature[], id: number | string | undefined, geom: GeoJSON.LineString, tolerance: number, properties: GeoJSON.GeoJsonProperties) {\n const out: SliceArray = {points: []};\n convertLine(geom.coordinates, out, tolerance, false);\n features.push(createFeature(id, 'LineString', out, properties));\n}\n\nfunction convertMultiLineStringFeature(features: GeoJSONVTInternalFeature[], id: number | string | undefined, geom: GeoJSON.MultiLineString, tolerance: number, options: GeoJSONVTOptions, properties: GeoJSON.GeoJsonProperties) {\n if (options.lineMetrics) {\n // explode into linestrings to be able to track metrics\n for (const line of geom.coordinates) {\n const out: SliceArray = {points: []};\n convertLine(line, out, tolerance, false);\n features.push(createFeature(id, 'LineString', out, properties));\n }\n } else {\n const out: SliceArray[] = [];\n convertLines(geom.coordinates, out, tolerance, false);\n features.push(createFeature(id, 'MultiLineString', out, properties));\n }\n}\n\nfunction convertPolygonFeature(features: GeoJSONVTInternalFeature[], id: number | string | undefined, geom: GeoJSON.Polygon, tolerance: number, properties: GeoJSON.GeoJsonProperties) {\n const out: SliceArray[] = [];\n convertLines(geom.coordinates, out, tolerance, true);\n features.push(createFeature(id, 'Polygon', out, properties));\n}\n\nfunction convertMultiPolygonFeature(features: GeoJSONVTInternalFeature[], id: number | string | undefined, geom: GeoJSON.MultiPolygon, tolerance: number, properties: GeoJSON.GeoJsonProperties) {\n const out: SliceArray[][] = [];\n for (const polygon of geom.coordinates) {\n const polygonOut: SliceArray[] = [];\n convertLines(polygon, polygonOut, tolerance, true);\n out.push(polygonOut);\n }\n features.push(createFeature(id, 'MultiPolygon', out, properties));\n}\n\nfunction convertLine(ring: GeoJSON.Position[], out: SliceArray, tolerance: number, isPolygon: boolean) {\n let x0, y0;\n let size = 0;\n\n for (let j = 0; j < ring.length; j++) {\n const x = projectX(ring[j][0]);\n const y = projectY(ring[j][1]);\n\n out.points.push(x, y, 0);\n\n if (j > 0) {\n if (isPolygon) {\n size += (x0 * y - x * y0) / 2; // area\n } else {\n size += Math.sqrt(Math.pow(x - x0, 2) + Math.pow(y - y0, 2)); // length\n }\n }\n x0 = x;\n y0 = y;\n }\n\n const last = out.points.length - 3;\n out.points[2] = 1;\n if (tolerance > 0) simplify(out.points, 0, last, tolerance);\n out.points[last + 2] = 1;\n\n optimizeLineMemory(out);\n out.size = Math.abs(size);\n out.start = 0;\n out.end = out.size;\n}\n\nfunction convertLines(rings: GeoJSON.Position[][], out: SliceArray[], tolerance: number, isPolygon: boolean) {\n for (let i = 0; i < rings.length; i++) {\n const geom: SliceArray = {points: []};\n convertLine(rings[i], geom, tolerance, isPolygon);\n out.push(geom);\n }\n}\n\n/**\n * Convert longitude to spherical mercator in [0..1] range\n */\nexport function projectX(x: number) {\n return x / 360 + 0.5;\n}\n\n/**\n * Convert latitude to spherical mercator in [0..1] range\n */\nexport function projectY(y: number) {\n const sin = Math.sin(y * Math.PI / 180);\n const y2 = 0.5 - 0.25 * Math.log((1 + sin) / (1 - sin)) / Math.PI;\n return y2 < 0 ? 0 : y2 > 1 ? 1 : y2;\n}\n","import type {GeoJSONVTInternalFeature} from './definitions';\n\n/**\n * Converts internal source features back to GeoJSON format.\n */\nexport function convertToGeoJSON(source: GeoJSONVTInternalFeature[]): GeoJSON.GeoJSON {\n const geojson: GeoJSON.GeoJSON = {\n type: 'FeatureCollection',\n features: source.map(feature => featureToGeoJSON(feature))\n };\n\n return geojson;\n}\n\n/**\n * Converts a single internal feature to GeoJSON format.\n */\nexport function featureToGeoJSON(feature: GeoJSONVTInternalFeature): GeoJSON.Feature {\n const geojsonFeature: GeoJSON.Feature = {\n type: 'Feature',\n geometry: geometryToGeoJSON(feature),\n properties: feature.tags\n };\n if (feature.id != null) {\n geojsonFeature.id = feature.id;\n }\n\n return geojsonFeature;\n}\n\n/**\n * Converts a single internal feature geometry to GeoJSON format.\n */\nfunction geometryToGeoJSON(feature: GeoJSONVTInternalFeature): GeoJSON.Geometry {\n const {type, geometry} = feature;\n\n switch (type) {\n case 'Point':\n return {\n type: type,\n coordinates: unprojectPoint(geometry[0], geometry[1])\n };\n case 'MultiPoint':\n return {\n type: type,\n coordinates: unprojectPoints(geometry)\n };\n case 'LineString':\n return {\n type: type,\n coordinates: unprojectPoints(geometry.points)\n };\n case 'MultiLineString':\n case 'Polygon':\n return {\n type: type,\n coordinates: geometry.map(ring => unprojectPoints(ring.points))\n };\n case 'MultiPolygon':\n return {\n type: type,\n coordinates: geometry.map(polygon =>\n polygon.map(ring => unprojectPoints(ring.points))\n )\n };\n }\n}\n\nexport function unprojectPoints(coords: number[] | Float64Array): GeoJSON.Position[] {\n const result: GeoJSON.Position[] = [];\n\n for (let i = 0; i < coords.length; i += 3) {\n result.push(unprojectPoint(coords[i], coords[i + 1]));\n }\n\n return result;\n}\n\nfunction unprojectPoint(x: number, y: number): GeoJSON.Position {\n return [unprojectX(x), unprojectY(y)];\n}\n\n/**\n * Convert spherical mercator in [0..1] range to longitude\n */\nexport function unprojectX(x: number): number {\n return (x - 0.5) * 360;\n}\n\n/**\n * Convert spherical mercator in [0..1] range to latitude\n */\nexport function unprojectY(y: number): number {\n const y2 = (180 - y * 360) * Math.PI / 180;\n return 360 * Math.atan(Math.exp(y2)) / Math.PI - 90;\n}\n","\nimport {createFeature, optimizeLineMemory} from './feature';\nimport type { GeoJSONVTInternalFeature, GeoJSONVTInternalLineStringFeature, GeoJSONVTInternalMultiLineStringFeature, GeoJSONVTInternalMultiPointFeature, GeoJSONVTInternalMultiPolygonFeature, GeoJSONVTInternalPointFeature, GeoJSONVTInternalPolygonFeature, GeoJSONVTOptions, SliceArray, SliceFixedArray } from './definitions';\n\nexport const enum AxisType {\n X = 0,\n Y = 1\n}\n\n/** \n * clip features between two vertical or horizontal axis-parallel lines:\n * | |\n * ___|___ | /\n * / | \\____|____/\n * | |\n *\n * @param features - the features to clip\n * @param scale - the scale to divide start and end inputs\n * @param start - the start of the clip range\n * @param end - the end of the clip range\n * @param axis - which axis to clip against\n * @param minAll - the minimum for all features in the relevant axis\n * @param maxAll - the maximum for all features in the relevant axis\n */\nexport function clip(features: GeoJSONVTInternalFeature[], scale: number, start: number, end: number, axis: AxisType, minAll: number, maxAll: number, options: GeoJSONVTOptions): GeoJSONVTInternalFeature[] | null {\n start /= scale;\n end /= scale;\n\n if (minAll >= start && maxAll < end) { // trivial accept\n return features;\n }\n\n if (maxAll < start || minAll >= end) { // trivial reject\n return null;\n }\n\n const clipped: GeoJSONVTInternalFeature[] = [];\n\n for (const feature of features) {\n const min = axis === AxisType.X ? feature.minX : feature.minY;\n const max = axis === AxisType.X ? feature.maxX : feature.maxY;\n\n if (min >= start && max < end) { // trivial accept\n clipped.push(feature);\n continue;\n }\n\n if (max < start || min >= end) { // trivial reject\n continue;\n }\n\n switch (feature.type) {\n case 'Point':\n case 'MultiPoint': {\n clipPointFeature(feature, clipped, start, end, axis);\n continue;\n }\n\n case 'LineString': {\n clipLineStringFeature(feature, clipped, start, end, axis, options);\n continue;\n }\n\n case 'MultiLineString': {\n clipMultiLineStringFeature(feature, clipped, start, end, axis);\n continue;\n }\n\n case 'Polygon': {\n clipPolygonFeature(feature, clipped, start, end, axis);\n continue;\n }\n\n case 'MultiPolygon': {\n clipMultiPolygonFeature(feature, clipped, start, end, axis);\n continue;\n }\n }\n }\n\n if (!clipped.length) return null;\n\n return clipped;\n}\n\nfunction clipPointFeature(feature: GeoJSONVTInternalPointFeature | GeoJSONVTInternalMultiPointFeature, clipped: GeoJSONVTInternalFeature[], start: number, end: number, axis: AxisType) {\n const geom: number[] = [];\n\n clipPoints(feature.geometry, geom, start, end, axis);\n if (!geom.length) return;\n\n const type = geom.length === 3 ? 'Point' : 'MultiPoint';\n clipped.push(createFeature(feature.id, type, geom, feature.tags));\n}\n\nfunction clipLineStringFeature(feature: GeoJSONVTInternalLineStringFeature, clipped: GeoJSONVTInternalFeature[], start: number, end: number, axis: AxisType, options: GeoJSONVTOptions) {\n const geom: SliceArray[] = [];\n\n clipLine(feature.geometry, geom, start, end, axis, false, options.lineMetrics);\n if (!geom.length) return;\n\n if (options.lineMetrics) {\n for (const line of geom) {\n clipped.push(createFeature(feature.id, 'LineString', line, feature.tags));\n }\n return;\n }\n\n if (geom.length > 1) {\n clipped.push(createFeature(feature.id, 'MultiLineString', geom, feature.tags));\n return;\n }\n\n clipped.push(createFeature(feature.id, 'LineString', geom[0], feature.tags));\n}\n\nfunction clipMultiLineStringFeature(feature: GeoJSONVTInternalMultiLineStringFeature, clipped: GeoJSONVTInternalFeature[], start: number, end: number, axis: AxisType) {\n const geom: SliceArray[] = [];\n\n clipLines(feature.geometry, geom, start, end, axis, false);\n if (!geom.length) return;\n\n if (geom.length === 1) {\n clipped.push(createFeature(feature.id, 'LineString', geom[0], feature.tags));\n return;\n }\n\n clipped.push(createFeature(feature.id,'MultiLineString', geom, feature.tags));\n}\n\nfunction clipPolygonFeature(feature: GeoJSONVTInternalPolygonFeature, clipped: GeoJSONVTInternalFeature[], start: number, end: number, axis: AxisType) {\n const geom: SliceArray[] = [];\n\n clipLines(feature.geometry, geom, start, end, axis, true);\n if (!geom.length) return;\n\n clipped.push(createFeature(feature.id, 'Polygon', geom, feature.tags));\n}\n\nfunction clipMultiPolygonFeature(feature: GeoJSONVTInternalMultiPolygonFeature, clipped: GeoJSONVTInternalFeature[], start: number, end: number, axis: AxisType) {\n const geom: SliceArray[][] = [];\n\n for (const polygon of feature.geometry) {\n const newPolygon: SliceArray[] = [];\n\n clipLines(polygon, newPolygon, start, end, axis, true);\n if (!newPolygon.length) continue;\n\n geom.push(newPolygon);\n }\n if (!geom.length) return;\n\n clipped.push(createFeature(feature.id, 'MultiPolygon', geom, feature.tags));\n}\n\nfunction clipPoints(geom: number[], newGeom: number[], start: number, end: number, axis: AxisType) {\n for (let i = 0; i < geom.length; i += 3) {\n const a = geom[i + axis];\n\n if (a >= start && a <= end) {\n addPoint(newGeom, geom[i], geom[i + 1], geom[i + 2]);\n }\n }\n}\n\nfunction clipLine(geom: SliceFixedArray, newGeom: SliceArray[], start: number, end: number, axis: AxisType, isPolygon: boolean, trackMetrics: boolean) {\n\n let slice = newSlice(geom);\n const intersect = axis === AxisType.X ? intersectX : intersectY;\n let len = geom.start;\n let segLen, t;\n\n for (let i = 0; i < geom.points.length - 3; i += 3) {\n const ax = geom.points[i];\n const ay = geom.points[i + 1];\n const az = geom.points[i + 2];\n const bx = geom.points[i + 3];\n const by = geom.points[i + 4];\n const a = axis === AxisType.X ? ax : ay;\n const b = axis === AxisType.X ? bx : by;\n let exited = false;\n\n if (trackMetrics) segLen = Math.sqrt(Math.pow(ax - bx, 2) + Math.pow(ay - by, 2));\n\n if (a < start) {\n // ---|--> | (line enters the clip region from the left)\n if (b > start) {\n t = intersect(slice, ax, ay, bx, by, start);\n if (trackMetrics) slice.start = len + segLen * t;\n }\n } else if (a > end) {\n // | <--|--- (line enters the clip region from the right)\n if (b < end) {\n t = intersect(slice, ax, ay, bx, by, end);\n if (trackMetrics) slice.start = len + segLen * t;\n }\n } else {\n addPoint(slice.points, ax, ay, az);\n }\n\n if (b < start && a >= start) {\n // <--|--- | or <--|-----|--- (line exits the clip region on the left)\n t = intersect(slice, ax, ay, bx, by, start);\n exited = true;\n }\n\n if (b > end && a <= end) {\n // | ---|--> or ---|-----|--> (line exits the clip region on the right)\n t = intersect(slice, ax, ay, bx, by, end);\n exited = true;\n }\n\n if (!isPolygon && exited) {\n if (trackMetrics) slice.end = len + segLen * t;\n newGeom.push(slice);\n slice = newSlice(geom);\n }\n\n if (trackMetrics) len += segLen;\n }\n\n // add the last point\n let last = geom.points.length - 3;\n const ax = geom.points[last];\n const ay = geom.points[last + 1];\n const az = geom.points[last + 2];\n const a = axis === AxisType.X ? ax : ay;\n if (a >= start && a <= end) addPoint(slice.points, ax, ay, az);\n\n // close the polygon if its endpoints are not the same after clipping\n last = slice.points.length - 3;\n if (isPolygon && last >= 3 && (slice.points[last] !== slice.points[0] || slice.points[last + 1] !== slice.points[1])) {\n addPoint(slice.points, slice.points[0], slice.points[1], slice.points[2]);\n }\n\n // add the final slice\n if (slice.points.length) {\n optimizeLineMemory(slice);\n newGeom.push(slice);\n }\n}\n\nfunction newSlice(line: SliceFixedArray): SliceArray {\n return {\n points: [],\n size: line.size,\n start: line.start,\n end: line.end\n };\n}\n\nfunction clipLines(geom: SliceFixedArray[], newGeom: SliceArray[], start: number, end: number, axis: AxisType, isPolygon: boolean) {\n for (const line of geom) {\n clipLine(line, newGeom, start, end, axis, isPolygon, false);\n }\n}\n\nfunction addPoint(out: number[], x: number, y: number, z: number) {\n out.push(x, y, z);\n}\n\nfunction intersectX(out: SliceArray, ax: number, ay: number, bx: number, by: number, x: number) {\n const t = (x - ax) / (bx - ax);\n addPoint(out.points, x, ay + (by - ay) * t, 1);\n return t;\n}\n\nfunction intersectY(out: SliceArray, ax: number, ay: number, bx: number, by: number, y: number) {\n const t = (y - ay) / (by - ay);\n addPoint(out.points, ax + (bx - ax) * t, y, 1);\n return t;\n}\n","\nimport {AxisType, clip} from './clip';\nimport type { GeoJSONVTInternalFeature, GeoJSONVTOptions, SliceArray, SliceFixedArray } from './definitions';\nimport {createFeature, optimizeLineMemory} from './feature';\n\nexport function wrap(features: GeoJSONVTInternalFeature[], options: GeoJSONVTOptions): GeoJSONVTInternalFeature[] {\n const buffer = options.buffer / options.extent;\n let merged = features;\n\n const left = clip(features, 1, -1 - buffer, buffer, AxisType.X, -1, 2, options); // left world copy\n const right = clip(features, 1, 1 - buffer, 2 + buffer, AxisType.X, -1, 2, options); // right world copy\n\n if (!left && !right) return merged;\n\n merged = clip(features, 1, -buffer, 1 + buffer, AxisType.X, -1, 2, options) || []; // center world copy\n\n if (left) merged = shiftFeatureCoords(left, 1).concat(merged); // merge left into center\n if (right) merged = merged.concat(shiftFeatureCoords(right, -1)); // merge right into center\n\n return merged;\n}\n\nfunction shiftFeatureCoords(features: GeoJSONVTInternalFeature[], offset: number): GeoJSONVTInternalFeature[] {\n const newFeatures = [];\n\n for (const feature of features) {\n switch (feature.type) {\n case 'Point':\n case 'MultiPoint': {\n const newGeometry = shiftPointCoords(feature.geometry, offset);\n\n newFeatures.push(createFeature(feature.id, feature.type, newGeometry, feature.tags));\n continue;\n }\n\n case 'LineString': {\n const newGeometry = shiftLineCoords(feature.geometry, offset);\n\n newFeatures.push(createFeature(feature.id, feature.type, newGeometry, feature.tags));\n continue;\n }\n\n case 'MultiLineString':\n case 'Polygon': {\n const newGeometry: SliceFixedArray[] = [];\n for (const line of feature.geometry) {\n newGeometry.push(shiftLineCoords(line, offset));\n }\n\n newFeatures.push(createFeature(feature.id, feature.type, newGeometry, feature.tags));\n continue;\n }\n\n case 'MultiPolygon': {\n const newGeometry: SliceFixedArray[][] = [];\n for (const polygon of feature.geometry) {\n const newPolygon: SliceFixedArray[] = [];\n for (const line of polygon) {\n newPolygon.push(shiftLineCoords(line, offset));\n }\n newGeometry.push(newPolygon);\n }\n\n newFeatures.push(createFeature(feature.id, feature.type, newGeometry, feature.tags));\n continue;\n }\n }\n }\n\n return newFeatures;\n}\n\nfunction shiftPointCoords(coords: number[], offset: number): number[] {\n const newCoords: number[] = [];\n\n for (let i = 0; i < coords.length; i += 3) {\n newCoords.push(coords[i] + offset, coords[i + 1], coords[i + 2]);\n }\n\n return newCoords;\n}\n\nfunction shiftLineCoords(line: SliceArray | SliceFixedArray, offset: number): SliceFixedArray {\n const newLine: SliceArray = {\n points: [],\n size: line.size\n };\n\n if (line.start !== undefined) {\n newLine.start = line.start;\n newLine.end = line.end;\n }\n\n for (let i = 0; i < line.points.length; i += 3) {\n newLine.points.push(line.points[i] + offset, line.points[i + 1], line.points[i + 2]);\n }\n\n optimizeLineMemory(newLine);\n\n return newLine;\n}\n","import {convertToInternal} from './convert';\nimport {wrap} from './wrap';\nimport type { GeoJSONVTInternalFeature, GeoJSONVTOptions } from './definitions';\n\nexport type GeoJSONVTSourceDiff = {\n /**\n * If true, clear all existing features\n */\n removeAll?: boolean;\n /**\n * Array of feature IDs to remove\n */\n remove?: (string | number)[];\n /**\n * Array of GeoJSON features to add\n */\n add?: GeoJSON.Feature[];\n /**\n * Array of per-feature updates\n */\n update?: GeoJSONVTFeatureDiff[];\n};\n\nexport type GeoJSONVTFeatureDiff = {\n /**\n * ID of the feature being updated\n */\n id: string | number;\n /**\n * Optional new geometry\n */\n newGeometry?: GeoJSON.Geometry;\n /**\n * Remove all properties if true\n */\n removeAllProperties?: boolean;\n /**\n * Specific properties to delete\n */\n removeProperties?: string[];\n /**\n * Properties to add or update\n */\n addOrUpdateProperties?: {\n key: string;\n value: unknown;\n }[];\n};\n\nexport type ApplySourceDiffResult = {\n /**\n * The features affected by this update, which should be used to invalidate tiles\n */\n affected: GeoJSONVTInternalFeature[];\n /**\n * The updated source data, which should replace the existing source data in the index\n */\n source: GeoJSONVTInternalFeature[];\n};\n\ntype HashedGeoJSONVTSourceDiff = {\n removeAll?: boolean | undefined;\n remove: Set;\n add: Map;\n update: Map;\n};\n\n/**\n * Applies a GeoJSON Source Diff to an existing set of simplified features\n * @param source \n * @param dataDiff \n * @param options \n * @returns \n */\nexport function applySourceDiff(source: GeoJSONVTInternalFeature[], dataDiff: GeoJSONVTSourceDiff, options: GeoJSONVTOptions): ApplySourceDiffResult {\n // convert diff to sets/maps for o(1) lookups\n const diff = diffToHashed(dataDiff, options);\n\n // collection for features that will be affected by this update and used to invalidate tiles\n let affected: GeoJSONVTInternalFeature[] = [];\n\n if (diff.removeAll) {\n affected = source;\n source = [];\n }\n\n if (diff.remove.size || diff.add.size) {\n const removeFeatures = [];\n\n // Collect features to remove (explicit removals + replacements via add)\n for (const feature of source) {\n if (diff.remove.has(feature.id) || diff.add.has(feature.id)) {\n removeFeatures.push(feature);\n }\n }\n\n if (removeFeatures.length) {\n affected = affected.concat(removeFeatures);\n const removeIds = new Set(removeFeatures.map(f => f.id));\n source = source.filter(f => !removeIds.has(f.id));\n }\n\n if (diff.add.size) {\n let addFeatures = convertToInternal({type: 'FeatureCollection', features: Array.from(diff.add.values())}, options);\n addFeatures = wrap(addFeatures, options);\n affected = affected.concat(addFeatures);\n source = source.concat(addFeatures);\n }\n }\n\n if (diff.update.size) {\n // Features can be duplicated across the antimeridian (wrap) in a single tile, so must update all instances with the same id\n const oldFeaturesMap = new Map();\n let keepFeatures: GeoJSONVTInternalFeature[] = [];\n for (const feature of source) {\n if (diff.update.has(feature.id)) {\n oldFeaturesMap.set(feature.id, [...(oldFeaturesMap.get(feature.id) || []), feature]);\n } else {\n keepFeatures.push(feature);\n }\n }\n for (const [id, update] of diff.update) {\n const oldFeatures = oldFeaturesMap.get(id); \n if (!oldFeatures || oldFeatures.length === 0) continue;\n const updatedFeatures = getUpdatedFeatures(oldFeatures, update, options);\n\n affected = affected.concat(oldFeatures, updatedFeatures);\n keepFeatures = keepFeatures.concat(updatedFeatures);\n }\n source = keepFeatures;\n }\n\n return {affected, source};\n}\n\n/**\n * Gets updated simplified feature(s) based on a diff update object.\n * @param vtFeatures - the original features\n * @param update - the update object to apply\n * @param options - the options to use for the wrap method\n * @returns Updated features. If geometry is updated, returns new feature(s) converted from geojson and wrapped. If only properties are updated, returns feature(s) with tags updated.\n */\nfunction getUpdatedFeatures(vtFeatures: GeoJSONVTInternalFeature[], update: GeoJSONVTFeatureDiff, options: GeoJSONVTOptions): GeoJSONVTInternalFeature[] {\n const changeGeometry = !!update.newGeometry;\n const changeProps =\n update.removeAllProperties ||\n update.removeProperties?.length > 0 ||\n update.addOrUpdateProperties?.length > 0;\n\n // if geometry changed, need to create a new geojson feature and convert to internal format\n if (changeGeometry) {\n const vtFeature = vtFeatures[0];\n const geojsonFeature = {\n type: 'Feature' as const,\n id: vtFeature.id,\n geometry: update.newGeometry,\n properties: changeProps ? applyPropertyUpdates(vtFeature.tags, update) : vtFeature.tags\n };\n\n let features = convertToInternal({type: 'FeatureCollection', features: [geojsonFeature]}, options);\n features = wrap(features, options);\n return features;\n }\n\n if (changeProps) {\n const updated = [];\n for (const vtFeature of vtFeatures) {\n const feature = {...vtFeature};\n feature.tags = applyPropertyUpdates(feature.tags, update);\n updated.push(feature);\n }\n return updated;\n }\n\n return vtFeatures;\n}\n\n/**\n * helper to apply property updates from a diff update object to a properties object\n */\nfunction applyPropertyUpdates(tags: GeoJSON.GeoJsonProperties, update: GeoJSONVTFeatureDiff): GeoJSON.GeoJsonProperties {\n if (update.removeAllProperties) {\n return {};\n }\n\n const properties = {...tags || {}};\n\n if (update.removeProperties) {\n for (const key of update.removeProperties) {\n delete properties[key];\n }\n }\n\n if (update.addOrUpdateProperties) {\n for (const {key, value} of update.addOrUpdateProperties) {\n properties[key] = value;\n }\n }\n\n return properties;\n}\n\n/**\n * Convert a GeoJSON Source Diff to an idempotent hashed representation using Sets and Maps\n */\nexport function diffToHashed(diff: GeoJSONVTSourceDiff, options: GeoJSONVTOptions): HashedGeoJSONVTSourceDiff {\n if (!diff) return {\n remove: new Set(),\n add: new Map(),\n update: new Map()\n };\n\n const hashed: HashedGeoJSONVTSourceDiff = {\n removeAll: diff.removeAll,\n remove: new Set(diff.remove || []),\n add: new Map(diff.add?.map(feature => [options.promoteId ? feature.properties[options.promoteId] : feature.id, feature])),\n update: new Map(diff.update?.map(update => [update.id, update]))\n };\n\n return hashed;\n}\n","\nconst ARRAY_TYPES = [\n Int8Array, Uint8Array, Uint8ClampedArray, Int16Array, Uint16Array,\n Int32Array, Uint32Array, Float32Array, Float64Array\n];\n\n/** @typedef {Int8ArrayConstructor | Uint8ArrayConstructor | Uint8ClampedArrayConstructor | Int16ArrayConstructor | Uint16ArrayConstructor | Int32ArrayConstructor | Uint32ArrayConstructor | Float32ArrayConstructor | Float64ArrayConstructor} TypedArrayConstructor */\n/** @typedef {Int8Array | Uint8Array | Uint8ClampedArray | Int16Array | Uint16Array | Int32Array | Uint32Array | Float32Array | Float64Array} TypedArray */\n\nconst VERSION = 1; // serialized format version\nconst HEADER_SIZE = 8;\n\n// Shared scratch stack for iterative DFS in range/within. Sized for the worst case:\n// 3 ints per frame * (treeHeight + 1), with treeHeight ≤ ceil(log2(2^32 / 3)) ≈ 31.\nconst STACK = new Uint32Array(96);\n\nexport default class KDBush {\n\n /**\n * Creates an index from raw `ArrayBuffer` data.\n * @param {ArrayBufferLike} data\n */\n static from(data) {\n // @ts-expect-error duck typing array buffers\n if (!data || data.byteLength === undefined || data.buffer) {\n throw new Error('Data must be an instance of ArrayBuffer or SharedArrayBuffer.');\n }\n const [magic, versionAndType] = new Uint8Array(data, 0, 2);\n if (magic !== 0xdb) {\n throw new Error('Data does not appear to be in a KDBush format.');\n }\n const version = versionAndType >> 4;\n if (version !== VERSION) {\n throw new Error(`Got v${version} data when expected v${VERSION}.`);\n }\n const ArrayType = ARRAY_TYPES[versionAndType & 0x0f];\n if (!ArrayType) {\n throw new Error('Unrecognized array type.');\n }\n const [nodeSize] = new Uint16Array(data, 2, 1);\n const [numItems] = new Uint32Array(data, 4, 1);\n\n return new KDBush(numItems, nodeSize, ArrayType, undefined, data);\n }\n\n /**\n * Creates an index that will hold a given number of items.\n * @param {number} numItems\n * @param {number} [nodeSize=64] Size of the KD-tree node (64 by default).\n * @param {TypedArrayConstructor} [ArrayType=Float64Array] The array type used for coordinates storage (`Float64Array` by default).\n * @param {ArrayBufferConstructor | SharedArrayBufferConstructor} [ArrayBufferType=ArrayBuffer] The array buffer type used for storage (`ArrayBuffer` by default).\n * @param {ArrayBufferLike} [data] (For internal use only)\n */\n constructor(numItems, nodeSize = 64, ArrayType = Float64Array, ArrayBufferType = ArrayBuffer, data) {\n if (isNaN(numItems) || numItems < 0) throw new Error(`Unexpected numItems value: ${numItems}.`);\n\n this.numItems = +numItems;\n this.nodeSize = Math.min(Math.max(+nodeSize, 2), 65535);\n this.ArrayType = ArrayType;\n this.IndexArrayType = numItems < 65536 ? Uint16Array : Uint32Array;\n\n const arrayTypeIndex = ARRAY_TYPES.indexOf(this.ArrayType);\n const coordsByteSize = numItems * 2 * this.ArrayType.BYTES_PER_ELEMENT;\n const idsByteSize = numItems * this.IndexArrayType.BYTES_PER_ELEMENT;\n const padCoords = (8 - idsByteSize % 8) % 8;\n\n if (arrayTypeIndex < 0) {\n throw new Error(`Unexpected typed array class: ${ArrayType}.`);\n }\n\n if (data) { // reconstruct an index from a buffer\n this.data = data;\n // @ts-expect-error TS can't handle SharedArrayBuffer overloads\n this.ids = new this.IndexArrayType(data, HEADER_SIZE, numItems);\n // @ts-expect-error TS can't handle SharedArrayBuffer overloads\n this.coords = new ArrayType(data, HEADER_SIZE + idsByteSize + padCoords, numItems * 2);\n this._pos = numItems * 2;\n this._finished = true;\n\n } else { // initialize a new index\n const data = this.data = new ArrayBufferType(HEADER_SIZE + coordsByteSize + idsByteSize + padCoords);\n // @ts-expect-error TS can't handle SharedArrayBuffer overloads\n this.ids = new this.IndexArrayType(data, HEADER_SIZE, numItems);\n // @ts-expect-error TS can't handle SharedArrayBuffer overloads\n this.coords = new ArrayType(data, HEADER_SIZE + idsByteSize + padCoords, numItems * 2);\n this._pos = 0;\n this._finished = false;\n\n // set header\n new Uint8Array(data, 0, 2).set([0xdb, (VERSION << 4) + arrayTypeIndex]);\n new Uint16Array(data, 2, 1)[0] = nodeSize;\n new Uint32Array(data, 4, 1)[0] = numItems;\n }\n }\n\n /**\n * Add a point to the index.\n * @param {number} x\n * @param {number} y\n * @returns {number} An incremental index associated with the added item (starting from `0`).\n */\n add(x, y) {\n const index = this._pos >> 1;\n this.ids[index] = index;\n this.coords[this._pos++] = x;\n this.coords[this._pos++] = y;\n return index;\n }\n\n /**\n * Perform indexing of the added points.\n */\n finish() {\n const numAdded = this._pos >> 1;\n if (numAdded !== this.numItems) {\n throw new Error(`Added ${numAdded} items when expected ${this.numItems}.`);\n }\n // kd-sort both arrays for efficient search\n sort(this.ids, this.coords, this.nodeSize, 0, this.numItems - 1, 0);\n\n this._finished = true;\n return this;\n }\n\n /**\n * Search the index for items within a given bounding box.\n * @param {number} minX\n * @param {number} minY\n * @param {number} maxX\n * @param {number} maxY\n * @returns {number[]} An array of indices correponding to the found items.\n */\n range(minX, minY, maxX, maxY) {\n if (!this._finished) throw new Error('Data not yet indexed - call index.finish().');\n\n const {ids, coords, nodeSize} = this;\n STACK[0] = 0;\n STACK[1] = ids.length - 1;\n STACK[2] = 0;\n let sp = 3;\n const result = [];\n\n // recursively search for items in range in the kd-sorted arrays\n while (sp > 0) {\n const axis = STACK[--sp];\n const right = STACK[--sp];\n const left = STACK[--sp];\n\n // if we reached \"tree node\", search linearly\n if (right - left <= nodeSize) {\n for (let i = left; i <= right; i++) {\n const x = coords[2 * i];\n const y = coords[2 * i + 1];\n if (x >= minX && x <= maxX && y >= minY && y <= maxY) result.push(ids[i]);\n }\n continue;\n }\n\n // otherwise find the middle index\n const m = (left + right) >> 1;\n\n // include the middle item if it's in range\n const x = coords[2 * m];\n const y = coords[2 * m + 1];\n if (x >= minX && x <= maxX && y >= minY && y <= maxY) result.push(ids[m]);\n\n // queue search in halves that intersect the query\n if (axis === 0 ? minX <= x : minY <= y) {\n STACK[sp++] = left;\n STACK[sp++] = m - 1;\n STACK[sp++] = 1 - axis;\n }\n if (axis === 0 ? maxX >= x : maxY >= y) {\n STACK[sp++] = m + 1;\n STACK[sp++] = right;\n STACK[sp++] = 1 - axis;\n }\n }\n\n return result;\n }\n\n /**\n * Search the index for items within a given radius.\n * @param {number} qx\n * @param {number} qy\n * @param {number} r Query radius.\n * @returns {number[]} An array of indices correponding to the found items.\n */\n within(qx, qy, r) {\n const result = /** @type {number[]} */ ([]);\n this.withinInto(qx, qy, r, result);\n return result;\n }\n\n /**\n * Search the index for items within a given radius, writing matching ids into `out`\n * via indexed assignment (`out[i] = id`). Accepts any indexed-writable container —\n * a typed array sized to the expected upper bound (allocation-free, fast) or a plain\n * `Array` (which will grow as needed). Returns the number of matches written.\n * @param {number} qx\n * @param {number} qy\n * @param {number} r Query radius.\n * @param {number[] | TypedArray} out Container to write matching ids into.\n * @returns {number} The number of matches written to `out`.\n */\n withinInto(qx, qy, r, out) {\n if (!this._finished) throw new Error('Data not yet indexed - call index.finish().');\n\n const {ids, coords, nodeSize} = this;\n STACK[0] = 0;\n STACK[1] = ids.length - 1;\n STACK[2] = 0;\n let sp = 3;\n let count = 0;\n const r2 = r * r;\n\n // recursively search for items within radius in the kd-sorted arrays\n while (sp > 0) {\n const axis = STACK[--sp];\n const right = STACK[--sp];\n const left = STACK[--sp];\n\n // if we reached \"tree node\", search linearly\n if (right - left <= nodeSize) {\n for (let i = left; i <= right; i++) {\n if (sqDist(coords[2 * i], coords[2 * i + 1], qx, qy) <= r2) out[count++] = ids[i];\n }\n continue;\n }\n\n // otherwise find the middle index\n const m = (left + right) >> 1;\n\n // include the middle item if it's in range\n const x = coords[2 * m];\n const y = coords[2 * m + 1];\n if (sqDist(x, y, qx, qy) <= r2) out[count++] = ids[m];\n\n // queue search in halves that intersect the query\n if (axis === 0 ? qx - r <= x : qy - r <= y) {\n STACK[sp++] = left;\n STACK[sp++] = m - 1;\n STACK[sp++] = 1 - axis;\n }\n if (axis === 0 ? qx + r >= x : qy + r >= y) {\n STACK[sp++] = m + 1;\n STACK[sp++] = right;\n STACK[sp++] = 1 - axis;\n }\n }\n\n return count;\n }\n}\n\n/**\n * @param {Uint16Array | Uint32Array} ids\n * @param {TypedArray} coords\n * @param {number} nodeSize\n * @param {number} left\n * @param {number} right\n * @param {number} axis\n */\nfunction sort(ids, coords, nodeSize, left, right, axis) {\n if (right - left <= nodeSize) return;\n\n const m = (left + right) >> 1; // middle index\n\n // sort ids and coords around the middle index so that the halves lie\n // either left/right or top/bottom correspondingly (taking turns)\n select(ids, coords, m, left, right, axis);\n\n // recursively kd-sort first half and second half on the opposite axis\n sort(ids, coords, nodeSize, left, m - 1, 1 - axis);\n sort(ids, coords, nodeSize, m + 1, right, 1 - axis);\n}\n\n/**\n * Custom Floyd-Rivest selection algorithm: sort ids and coords so that\n * [left..k-1] items are smaller than k-th item (on either x or y axis)\n * @param {Uint16Array | Uint32Array} ids\n * @param {TypedArray} coords\n * @param {number} k\n * @param {number} left\n * @param {number} right\n * @param {number} axis\n */\nfunction select(ids, coords, k, left, right, axis) {\n\n while (right > left) {\n if (right - left > 600) {\n const n = right - left + 1;\n const m = k - left + 1;\n const z = Math.log(n);\n const s = 0.5 * Math.exp(2 * z / 3);\n const sd = 0.5 * Math.sqrt(z * s * (n - s) / n) * (m - n / 2 < 0 ? -1 : 1);\n const newLeft = Math.max(left, Math.floor(k - m * s / n + sd));\n const newRight = Math.min(right, Math.floor(k + (n - m) * s / n + sd));\n select(ids, coords, k, newLeft, newRight, axis);\n }\n\n const t = coords[2 * k + axis];\n let i = left;\n let j = right;\n\n swapItem(ids, coords, left, k);\n if (coords[2 * right + axis] > t) swapItem(ids, coords, left, right);\n\n while (i < j) {\n swapItem(ids, coords, i, j);\n i++;\n j--;\n while (coords[2 * i + axis] < t) i++;\n while (coords[2 * j + axis] > t) j--;\n }\n\n if (coords[2 * left + axis] === t) swapItem(ids, coords, left, j);\n else {\n j++;\n swapItem(ids, coords, j, right);\n }\n\n if (j <= k) left = j + 1;\n if (k <= j) right = j - 1;\n }\n}\n\n/**\n * @param {Uint16Array | Uint32Array} ids\n * @param {TypedArray} coords\n * @param {number} i\n * @param {number} j\n */\nfunction swapItem(ids, coords, i, j) {\n swap(ids, i, j);\n swap(coords, 2 * i, 2 * j);\n swap(coords, 2 * i + 1, 2 * j + 1);\n}\n\n/**\n * @param {TypedArray} arr\n * @param {number} i\n * @param {number} j\n */\nfunction swap(arr, i, j) {\n const tmp = arr[i];\n arr[i] = arr[j];\n arr[j] = tmp;\n}\n\n/**\n * @param {number} ax\n * @param {number} ay\n * @param {number} bx\n * @param {number} by\n */\nfunction sqDist(ax, ay, bx, by) {\n const dx = ax - bx;\n const dy = ay - by;\n return dx * dx + dy * dy;\n}\n","import KDBush from 'kdbush';\nimport {projectX, projectY} from './convert';\nimport {unprojectX, unprojectY, featureToGeoJSON} from './deconvert';\nimport type {ClusterFeature, ClusterOrPointFeature, ClusterProperties, GeoJSONVTTileIndex, GeoJSONVTFeature, GeoJSONVTInternalFeature, GeoJSONVTInternalPointFeature, GeoJSONVTOptions, GeoJSONVTTile, SuperclusterOptions} from './definitions';\n\ntype ClusterFeatureInternal = GeoJSONVTInternalPointFeature & {\n tags: ClusterProperties;\n};\n\ntype ClusterOrPointFeatureInternal = ClusterFeatureInternal | GeoJSONVTInternalPointFeature;\n\n/** @internal */\nexport type KDBushWithData = KDBush & {\n flatData: number[];\n};\n\nexport const defaultClusterOptions: Required = {\n minZoom: 0,\n maxZoom: 16,\n minPoints: 2,\n radius: 40,\n extent: 512,\n nodeSize: 64,\n log: false,\n generateId: false,\n reduce: null,\n map: (props) => props as Record\n};\n\nconst OFFSET_ZOOM = 2;\nconst OFFSET_ID = 3;\nconst OFFSET_PARENT = 4;\nconst OFFSET_NUM = 5;\nconst OFFSET_PROP = 6;\n\n/**\n * This class allow clustering of geojson points.\n */\nexport class ClusterTileIndex implements GeoJSONVTTileIndex {\n options: Required;\n trees: KDBushWithData[];\n stride: number;\n clusterProps: Record[];\n points: GeoJSONVTInternalPointFeature[];\n\n constructor(options?: SuperclusterOptions) {\n this.options = Object.assign(Object.create(defaultClusterOptions), options) as Required;\n this.trees = new Array(this.options.maxZoom + 1);\n this.stride = this.options.reduce ? 7 : 6;\n this.clusterProps = [];\n this.points = [];\n }\n\n /**\n * Loads GeoJSON point features and builds the internal clustering index.\n * @param points - GeoJSON point features to cluster.\n */\n load(points: GeoJSON.Feature[]): void {\n const features: GeoJSONVTInternalPointFeature[] = [];\n \n // Convert GeoJSON point features to GeoJSONVT internal point features\n for (const point of points) {\n if (!point.geometry) {\n continue;\n }\n\n const [lng, lat] = point.geometry.coordinates;\n const [x, y] = [projectX(lng), projectY(lat)];\n \n const feature: GeoJSONVTInternalPointFeature = {\n id: point.id,\n type: 'Point',\n geometry: [x, y],\n tags: point.properties\n };\n \n features.push(feature);\n }\n \n this.createIndex(features);\n }\n\n /**\n * @internal\n * Loads internal GeoJSONVT point features from a data source and builds the clustering index.\n * @param features - {@link GeoJSONVTInternalFeature} data source features to filter and cluster.\n */\n initialize(features: GeoJSONVTInternalFeature[]): void {\n const points: GeoJSONVTInternalPointFeature[] = [];\n\n for (const feature of features) {\n if (feature.type !== 'Point') continue;\n points.push(feature);\n }\n\n this.createIndex(points);\n }\n\n /**\n * @internal\n * Updates the cluster data by rebuilding.\n * @param features \n */\n updateIndex(features: GeoJSONVTInternalFeature[], _affected: GeoJSONVTInternalFeature[], options: GeoJSONVTOptions) {\n this.options = Object.assign(Object.create(defaultClusterOptions), options.clusterOptions) as Required;\n this.initialize(features);\n }\n\n private createIndex(points: GeoJSONVTInternalPointFeature[]): void {\n const {log, minZoom, maxZoom} = this.options;\n\n if (log) console.time('total time');\n\n const timerId = `prepare ${points.length} points`;\n if (log) console.time(timerId);\n\n this.points = points;\n\n // generate a cluster object for each point and index input points into a KD-tree\n const data: number[] = [];\n\n for (let i = 0; i < points.length; i++) {\n const p = points[i];\n if (!p?.geometry) continue;\n\n let [x, y] = p.geometry;\n x = Math.fround(x);\n y = Math.fround(y);\n\n // store internal point/cluster data in flat numeric arrays for performance\n data.push(\n x, y, // projected point coordinates\n Infinity, // the last zoom the point was processed at\n i, // index of the source feature in the original input array\n -1, // parent cluster id\n 1 // number of points in a cluster\n );\n if (this.options.reduce) data.push(0); // noop\n }\n let tree = this.trees[maxZoom + 1] = this.createTree(data);\n\n if (log) console.timeEnd(timerId);\n\n // cluster points on max zoom, then cluster the results on previous zoom, etc.;\n // results in a cluster hierarchy across zoom levels\n for (let z = maxZoom; z >= minZoom; z--) {\n const now = Date.now();\n\n // create a new set of clusters for the zoom and index them with a KD-tree\n tree = this.trees[z] = this.createTree(this.cluster(tree, z));\n\n if (log) console.log('z%d: %d clusters in %dms', z, tree.numItems, Date.now() - now);\n }\n\n if (log) console.timeEnd('total time');\n }\n\n /**\n * Returns clusters and/or points within a bounding box at a given zoom level.\n * @param bbox - Bounding box in `[westLng, southLat, eastLng, northLat]` order.\n * @param zoom - Zoom level to query.\n */\n public getClusters(bbox: [number, number, number, number], zoom: number): ClusterOrPointFeature[] {\n const clusterInternal = this.getClustersInternal(bbox, zoom);\n return clusterInternal.map((f) => featureToGeoJSON(f) as ClusterOrPointFeature);\n }\n\n private getClustersInternal(bbox: [number, number, number, number], zoom: number): ClusterOrPointFeatureInternal[] {\n let minLng = ((bbox[0] + 180) % 360 + 360) % 360 - 180;\n const minLat = Math.max(-90, Math.min(90, bbox[1]));\n let maxLng = bbox[2] === 180 ? 180 : ((bbox[2] + 180) % 360 + 360) % 360 - 180;\n const maxLat = Math.max(-90, Math.min(90, bbox[3]));\n\n if (bbox[2] - bbox[0] >= 360) {\n minLng = -180;\n maxLng = 180;\n } else if (minLng > maxLng) {\n const easternHem = this.getClustersInternal([minLng, minLat, 180, maxLat], zoom);\n const westernHem = this.getClustersInternal([-180, minLat, maxLng, maxLat], zoom);\n return easternHem.concat(westernHem);\n }\n\n const tree = this.trees[this.limitZoom(zoom)];\n const ids = tree.range(projectX(minLng), projectY(maxLat), projectX(maxLng), projectY(minLat));\n const data = tree.flatData;\n const clusters: ClusterOrPointFeatureInternal[] = [];\n for (const id of ids) {\n const k = this.stride * id;\n clusters.push(data[k + OFFSET_NUM] > 1 ? getClusterFeature(data, k, this.clusterProps) : this.points[data[k + OFFSET_ID]]);\n }\n return clusters;\n }\n\n /**\n * Returns the immediate children (clusters or points) of a cluster as GeoJSON.\n * @param clusterId - The target cluster id.\n */\n getChildren(clusterId: number): ClusterOrPointFeature[] {\n const originId = this.getOriginId(clusterId);\n const originZoom = this.getOriginZoom(clusterId);\n const clusterError = new Error('No cluster with the specified id: ' + clusterId);\n\n const tree = this.trees[originZoom];\n if (!tree) throw clusterError;\n\n const data = tree.flatData;\n if (originId * this.stride >= data.length) throw clusterError;\n\n const r = this.options.radius / (this.options.extent * Math.pow(2, originZoom - 1));\n const x = data[originId * this.stride];\n const y = data[originId * this.stride + 1];\n const ids = tree.within(x, y, r);\n const children: ClusterOrPointFeature[] = [];\n for (const id of ids) {\n const k = id * this.stride;\n if (data[k + OFFSET_PARENT] === clusterId) {\n children.push(data[k + OFFSET_NUM] > 1 ? getClusterGeoJSON(data, k, this.clusterProps) : featureToGeoJSON(this.points[data[k + OFFSET_ID]]) as GeoJSON.Feature);\n }\n }\n\n if (children.length === 0) throw clusterError;\n\n return children;\n }\n\n /**\n * Returns leaf point features under a cluster, paginated by `limit` and `offset`.\n * @param clusterId - The target cluster id.\n * @param limit - Maximum number of points to return (defaults to `10`).\n * @param offset - Number of points to skip before collecting results (defaults to `0`).\n */\n getLeaves(clusterId: number, limit?: number, offset?: number): GeoJSON.Feature[] {\n limit = limit || 10;\n offset = offset || 0;\n\n const leaves: GeoJSON.Feature[] = [];\n this.appendLeaves(leaves, clusterId, limit, offset, 0);\n\n return leaves;\n }\n\n /**\n * Generates a vector-tile-like representation of a single tile.\n * @param z - Tile zoom.\n * @param x - Tile x coordinate.\n * @param y - Tile y coordinate.\n */\n getTile(z: number, x: number, y: number): GeoJSONVTTile | null {\n const tree = this.trees[this.limitZoom(z)];\n if (!tree) {\n return null;\n }\n const z2 = Math.pow(2, z);\n const {extent, radius} = this.options;\n const p = radius / extent;\n const top = (y - p) / z2;\n const bottom = (y + 1 + p) / z2;\n\n const tile: GeoJSONVTTile = {\n transformed: true,\n features: [],\n source: null,\n x: x,\n y: y,\n z: z\n };\n\n this.addTileFeatures(\n tree.range((x - p) / z2, top, (x + 1 + p) / z2, bottom),\n tree.flatData, x, y, z2, tile);\n\n if (x === 0) {\n this.addTileFeatures(\n tree.range(1 - p / z2, top, 1, bottom),\n tree.flatData, z2, y, z2, tile);\n }\n if (x === z2 - 1) {\n this.addTileFeatures(\n tree.range(0, top, p / z2, bottom),\n tree.flatData, -1, y, z2, tile);\n }\n\n return tile;\n }\n\n /**\n * Returns the zoom level at which a cluster expands into multiple children.\n * @param clusterId - The target cluster id.\n */\n getClusterExpansionZoom(clusterId: number): number {\n return this.getOriginZoom(clusterId);\n }\n\n private appendLeaves(result: GeoJSON.Feature[], clusterId: number, limit: number, offset: number, skipped: number): number {\n const children = this.getChildren(clusterId);\n\n for (const child of children) {\n const props = child.properties as ClusterProperties | null;\n\n if (props?.cluster) {\n if (skipped + props.point_count <= offset) {\n // skip the whole cluster\n skipped += props.point_count;\n } else {\n // enter the cluster\n skipped = this.appendLeaves(result, props.cluster_id, limit, offset, skipped);\n // exit the cluster\n }\n } else if (skipped < offset) {\n // skip a single point\n skipped++;\n } else {\n // add a single point\n result.push(child as GeoJSON.Feature);\n }\n if (result.length === limit) break;\n }\n\n return skipped;\n }\n\n private createTree(data: number[]): KDBushWithData {\n const tree = new KDBush(data.length / this.stride | 0, this.options.nodeSize, Float32Array) as unknown as KDBushWithData;\n for (let i = 0; i < data.length; i += this.stride) tree.add(data[i], data[i + 1]);\n tree.finish();\n tree.flatData = data;\n tree.data = null; // clear original data to free memory as it isn't used later on.\n return tree;\n }\n\n private addTileFeatures(ids: number[], data: number[], x: number, y: number, z2: number, tile: GeoJSONVTTile): void {\n for (const i of ids) {\n const k = i * this.stride;\n const isCluster = data[k + OFFSET_NUM] > 1;\n\n let tags: GeoJSON.GeoJsonProperties | ClusterProperties;\n let px: number;\n let py: number;\n if (isCluster) {\n tags = getClusterProperties(data, k, this.clusterProps);\n px = data[k];\n py = data[k + 1];\n } else {\n const p = this.points[data[k + OFFSET_ID]];\n tags = p.tags;\n [px, py] = p.geometry;\n }\n\n const f: GeoJSONVTFeature = {\n type: 1,\n geometry: [[\n Math.round(this.options.extent * (px * z2 - x)),\n Math.round(this.options.extent * (py * z2 - y))\n ]],\n tags\n };\n\n // assign id\n let id: number | string | undefined;\n if (isCluster || this.options.generateId) {\n // optionally generate id for points\n id = data[k + OFFSET_ID];\n } else {\n // keep id if already assigned\n id = this.points[data[k + OFFSET_ID]].id as number | string | undefined;\n }\n\n if (id !== undefined) f.id = id;\n\n tile.features.push(f);\n }\n }\n\n private limitZoom(z: number): number {\n return Math.max(this.options.minZoom, Math.min(Math.floor(+z), this.options.maxZoom + 1));\n }\n\n private cluster(tree: KDBushWithData, zoom: number): number[] {\n const {radius, extent, reduce, minPoints} = this.options;\n const r = radius / (extent * Math.pow(2, zoom));\n const data = tree.flatData;\n const nextData: number[] = [];\n const stride = this.stride;\n\n // loop through each point\n for (let i = 0; i < data.length; i += stride) {\n // if we've already visited the point at this zoom level, skip it\n if (data[i + OFFSET_ZOOM] <= zoom) continue;\n data[i + OFFSET_ZOOM] = zoom;\n\n // find all nearby points\n const x = data[i];\n const y = data[i + 1];\n const neighborIds = tree.within(data[i], data[i + 1], r);\n\n const numPointsOrigin = data[i + OFFSET_NUM];\n let numPoints = numPointsOrigin;\n\n // count the number of points in a potential cluster\n for (const neighborId of neighborIds) {\n const k = neighborId * stride;\n // filter out neighbors that are already processed\n if (data[k + OFFSET_ZOOM] > zoom) numPoints += data[k + OFFSET_NUM];\n }\n\n // if there were neighbors to merge, and there are enough points to form a cluster\n if (numPoints > numPointsOrigin && numPoints >= minPoints) {\n let wx = x * numPointsOrigin;\n let wy = y * numPointsOrigin;\n\n let clusterProperties: Record | undefined;\n let clusterPropIndex = -1;\n\n // encode both zoom and point index on which the cluster originated -- offset by total length of features\n const id = ((i / stride | 0) << 5) + (zoom + 1) + this.points.length;\n\n for (const neighborId of neighborIds) {\n const k = neighborId * stride;\n\n if (data[k + OFFSET_ZOOM] <= zoom) continue;\n data[k + OFFSET_ZOOM] = zoom; // save the zoom (so it doesn't get processed twice)\n\n const numPoints2 = data[k + OFFSET_NUM];\n wx += data[k] * numPoints2; // accumulate coordinates for calculating weighted center\n wy += data[k + 1] * numPoints2;\n\n data[k + OFFSET_PARENT] = id;\n\n if (reduce) {\n if (!clusterProperties) {\n clusterProperties = this.map(data, i, true);\n clusterPropIndex = this.clusterProps.length;\n this.clusterProps.push(clusterProperties);\n }\n reduce(clusterProperties, this.map(data, k));\n }\n }\n\n data[i + OFFSET_PARENT] = id;\n nextData.push(wx / numPoints, wy / numPoints, Infinity, id, -1, numPoints);\n if (reduce) nextData.push(clusterPropIndex);\n\n } else { // left points as unclustered\n for (let j = 0; j < stride; j++) nextData.push(data[i + j]);\n\n if (numPoints > 1) {\n for (const neighborId of neighborIds) {\n const k = neighborId * stride;\n if (data[k + OFFSET_ZOOM] <= zoom) continue;\n data[k + OFFSET_ZOOM] = zoom;\n for (let j = 0; j < stride; j++) nextData.push(data[k + j]);\n }\n }\n }\n }\n\n return nextData;\n }\n\n // get index of the point from which the cluster originated\n private getOriginId(clusterId: number): number {\n return (clusterId - this.points.length) >> 5;\n }\n\n // get zoom of the point from which the cluster originated\n private getOriginZoom(clusterId: number): number {\n return (clusterId - this.points.length) % 32;\n }\n\n private map(data: number[], i: number, clone?: boolean): Record {\n if (data[i + OFFSET_NUM] > 1) {\n const props = this.clusterProps[data[i + OFFSET_PROP]];\n return clone ? Object.assign({}, props) : props;\n }\n const original = this.points[data[i + OFFSET_ID]].tags;\n const result = this.options.map(original);\n return clone && result === original ? Object.assign({}, result) : result;\n }\n}\n\nfunction getClusterFeature(data: number[], i: number, clusterProps: Record[]): ClusterFeatureInternal {\n return {\n id: data[i + OFFSET_ID],\n type: 'Point',\n tags: getClusterProperties(data, i, clusterProps),\n geometry: [data[i], data[i + 1]]\n };\n}\n\nfunction getClusterGeoJSON(data: number[], i: number, clusterProps: Record[]): ClusterFeature {\n return {\n type: 'Feature',\n id: data[i + OFFSET_ID],\n properties: getClusterProperties(data, i, clusterProps),\n geometry: {\n type: 'Point',\n coordinates: [unprojectX(data[i]), unprojectY(data[i + 1])]\n }\n };\n}\n\nfunction getClusterProperties(data: number[], i: number, clusterProps: Record[]): ClusterProperties {\n const count = data[i + OFFSET_NUM];\n const abbrev =\n count >= 10000 ? `${Math.round(count / 1000) }k` :\n count >= 1000 ? `${Math.round(count / 100) / 10 }k` : count;\n const propIndex = data[i + OFFSET_PROP];\n const properties = propIndex === -1 ? {} : Object.assign({}, clusterProps[propIndex]);\n\n return Object.assign(properties, {\n cluster: true as const,\n cluster_id: data[i + OFFSET_ID],\n point_count: count,\n point_count_abbreviated: abbrev\n });\n}\n","import type { GeoJSONVTInternalFeature, GeoJSONVTInternalLineStringFeature, GeoJSONVTInternalMultiLineStringFeature, GeoJSONVTInternalMultiPointFeature, GeoJSONVTInternalMultiPolygonFeature, GeoJSONVTInternalPointFeature, GeoJSONVTInternalPolygonFeature, GeoJSONVTInternalTile, GeoJSONVTInternalTileFeature, GeoJSONVTOptions, SliceFixedArray } from \"./definitions\";\n\nexport const GEOJSONVT_CLIP_START = 'geojsonvt_clip_start';\nexport const GEOJSONVT_CLIP_END = 'geojsonvt_clip_end';\n\n/**\n * Creates a tile object from the given features\n * @param features - the features to include in the tile\n * @param z\n * @param tx\n * @param ty\n * @param options - the options object\n * @returns the created tile\n */\nexport function createTile(features: GeoJSONVTInternalFeature[], z: number, tx: number, ty: number, options: GeoJSONVTOptions): GeoJSONVTInternalTile {\n const tolerance = z === options.maxZoom ? 0 : options.tolerance / ((1 << z) * options.extent);\n\n const tile = {\n transformed: false,\n features: [] as GeoJSONVTInternalTileFeature[],\n source: null as GeoJSONVTInternalFeature[],\n x: tx,\n y: ty,\n z: z,\n minX: 2,\n minY: 1,\n maxX: -1,\n maxY: 0,\n numPoints: 0,\n numSimplified: 0,\n numFeatures: features.length\n };\n\n for (const feature of features) {\n addFeature(tile, feature, tolerance, options);\n }\n\n return tile;\n}\n\nfunction addFeature(tile: GeoJSONVTInternalTile, feature: GeoJSONVTInternalFeature, tolerance: number, options: GeoJSONVTOptions) {\n tile.minX = Math.min(tile.minX, feature.minX);\n tile.minY = Math.min(tile.minY, feature.minY);\n tile.maxX = Math.max(tile.maxX, feature.maxX);\n tile.maxY = Math.max(tile.maxY, feature.maxY);\n\n switch (feature.type) {\n case 'Point':\n case 'MultiPoint': \n addPointsTileFeature(tile, feature);\n return;\n case 'LineString':\n addLineTileFeautre(tile, feature, tolerance, options);\n return;\n case 'MultiLineString':\n case 'Polygon':\n addLinesTileFeature(tile, feature, tolerance);\n return;\n case 'MultiPolygon': \n addMultiPolygonTileFeature(tile, feature, tolerance);\n return;\n }\n}\n\nfunction addPointsTileFeature(tile: GeoJSONVTInternalTile, feature: GeoJSONVTInternalPointFeature | GeoJSONVTInternalMultiPointFeature) {\n const geometry: number[] = [];\n for (let i = 0; i < feature.geometry.length; i += 3) {\n geometry.push(feature.geometry[i] , feature.geometry[i + 1]);\n tile.numPoints++;\n tile.numSimplified++;\n }\n if (!geometry.length) return;\n const tileFeature: GeoJSONVTInternalTileFeature = {\n type: 1,\n tags: feature.tags || null,\n geometry: geometry\n };\n if (feature.id !== null) {\n tileFeature.id = feature.id;\n }\n tile.features.push(tileFeature);\n}\n\nfunction addLineTileFeautre(tile: GeoJSONVTInternalTile, feature: GeoJSONVTInternalLineStringFeature, tolerance: number, options: GeoJSONVTOptions) {\n const geometry: number[][] = [];\n addLine(geometry, feature.geometry, tile, tolerance, false, false);\n if (!geometry.length) return;\n let tags = feature.tags || null;\n if (options.lineMetrics) {\n tags = {};\n for (const key in feature.tags) tags[key] = feature.tags[key];\n tags[GEOJSONVT_CLIP_START] = feature.geometry.start / feature.geometry.size;\n tags[GEOJSONVT_CLIP_END] = feature.geometry.end / feature.geometry.size;\n }\n const tileFeature: GeoJSONVTInternalTileFeature = {\n type: 2,\n tags: tags,\n geometry: geometry\n }\n if (feature.id !== null) {\n tileFeature.id = feature.id;\n }\n tile.features.push(tileFeature);\n}\n\nfunction addLinesTileFeature(tile: GeoJSONVTInternalTile, feature: GeoJSONVTInternalPolygonFeature | GeoJSONVTInternalMultiLineStringFeature, tolerance: number) {\n const geometry: number[][] = [];\n for (let i = 0; i < feature.geometry.length; i++) {\n addLine(geometry, feature.geometry[i], tile, tolerance, feature.type === 'Polygon', i === 0);\n }\n if (!geometry.length) return;\n const tileFeature: GeoJSONVTInternalTileFeature = {\n type: feature.type === 'Polygon' ? 3 : 2,\n tags: feature.tags || null,\n geometry: geometry\n }\n if (feature.id !== null) {\n tileFeature.id = feature.id;\n }\n tile.features.push(tileFeature);\n}\n\nfunction addMultiPolygonTileFeature(tile: GeoJSONVTInternalTile, feature: GeoJSONVTInternalMultiPolygonFeature, tolerance: number) {\n const geometry: number[][] = [];\n for (let k = 0; k < feature.geometry.length; k++) {\n const polygon = feature.geometry[k];\n for (let i = 0; i < polygon.length; i++) {\n addLine(geometry, polygon[i], tile, tolerance, true, i === 0);\n }\n }\n if (!geometry.length) return;\n const tileFeature: GeoJSONVTInternalTileFeature = {\n type: 3,\n tags: feature.tags || null,\n geometry: geometry\n }\n if (feature.id !== null) {\n tileFeature.id = feature.id;\n }\n tile.features.push(tileFeature);\n}\n\nfunction addLine(result: number[][], geom: SliceFixedArray, tile: GeoJSONVTInternalTile, tolerance: number, isPolygon: boolean, isOuter: boolean) {\n const sqTolerance = tolerance * tolerance;\n\n if (tolerance > 0 && (geom.size < (isPolygon ? sqTolerance : tolerance))) {\n tile.numPoints += geom.points.length / 3;\n return;\n }\n\n const ring = [];\n\n for (let i = 0; i < geom.points.length; i += 3) {\n if (tolerance === 0 || geom.points[i + 2] > sqTolerance) {\n tile.numSimplified++;\n ring.push(geom.points[i], geom.points[i + 1]);\n }\n tile.numPoints++;\n }\n\n if (isPolygon) rewind(ring, isOuter);\n\n result.push(ring);\n}\n\nfunction rewind(ring: number[], clockwise: boolean) {\n let area = 0;\n\n for (let i = 0, len = ring.length, j = len - 2; i < len; j = i, i += 2) {\n area += (ring[i] - ring[j]) * (ring[i + 1] + ring[j + 1]);\n }\n\n if (area > 0 !== clockwise) return;\n\n for (let i = 0, len = ring.length; i < len / 2; i += 2) {\n const x = ring[i];\n const y = ring[i + 1];\n\n ring[i] = ring[len - 2 - i];\n ring[i + 1] = ring[len - 1 - i];\n ring[len - 2 - i] = x;\n ring[len - 1 - i] = y;\n }\n}\n","import type { GeoJSONVTFeatureNonPoint, GeoJSONVTFeaturePoint, GeoJSONVTInternalTile, GeoJSONVTInternalTileFeatureNonPoint, GeoJSONVTInternalTileFeaturePoint, GeoJSONVTTile } from \"./definitions\";\n\n/**\n * Transforms the coordinates of each feature in the given tile from\n * mercator-projected space into (extent x extent) tile space.\n * @param tile - the tile to transform, this gets modified in place\n * @param extent - the tile extent (usually 4096)\n * @returns the transformed tile\n */\nexport function transformTile(tile: GeoJSONVTInternalTile, extent: number): GeoJSONVTTile {\n if (tile.transformed) {\n return tile as GeoJSONVTTile;\n }\n\n const z2 = 1 << tile.z;\n const tx = tile.x;\n const ty = tile.y;\n\n for (const feature of tile.features) {\n if (feature.type === 1) {\n transformPointFeature(feature, extent, z2, tx, ty);\n } else {\n transformNonPointFeature(feature, extent, z2, tx, ty);\n } \n }\n tile.transformed = true;\n\n return tile as GeoJSONVTTile;\n}\n\n/**\n * Transforms a single point feature from mercator-projected space into (extent x extent) tile space.\n */\nfunction transformPointFeature(feature: GeoJSONVTInternalTileFeaturePoint, extent: number, z2: number, tx: number, ty: number): GeoJSONVTFeaturePoint {\n const transformed = feature as unknown as GeoJSONVTFeaturePoint;\n\n const geometry = feature.geometry;\n const point: GeoJSONVTFeaturePoint[\"geometry\"] = [];\n for (let i = 0; i < geometry.length; i += 2) {\n point.push(transformPoint(geometry[i], geometry[i + 1], extent, z2, tx, ty));\n }\n transformed.geometry = point;\n\n return transformed;\n}\n\n/**\n * Transforms a single non-point feature from mercator-projected space into (extent x extent) tile space.\n */\nfunction transformNonPointFeature(feature: GeoJSONVTInternalTileFeatureNonPoint, extent: number, z2: number, tx: number, ty: number): GeoJSONVTFeatureNonPoint {\n const transformed = feature as unknown as GeoJSONVTFeatureNonPoint;\n\n const geometry = feature.geometry;\n const nonPoint: GeoJSONVTFeatureNonPoint[\"geometry\"] = [];\n for (const geom of geometry) {\n const ring: GeoJSONVTFeaturePoint[\"geometry\"] = [];\n for (let i = 0; i < geom.length; i += 2) {\n ring.push(transformPoint(geom[i], geom[i + 1], extent, z2, tx, ty));\n }\n nonPoint.push(ring);\n }\n transformed.geometry = nonPoint;\n\n return transformed;\n}\n\nfunction transformPoint(x: number, y: number, extent: number, z2: number, tx: number, ty: number): [number, number] {\n return [\n Math.round(extent * (x * z2 - tx)),\n Math.round(extent * (y * z2 - ty))\n ];\n}\n","import { AxisType, clip } from \"./clip\";\nimport { createTile } from \"./tile\";\nimport { transformTile } from \"./transform\";\nimport type { GeoJSONVTInternalFeature, GeoJSONVTOptions, ClusterOrPointFeature, GeoJSONVTTileIndex, GeoJSONVTInternalTile, GeoJSONVTTile } from \"./definitions\";\n\nexport class TileIndex implements GeoJSONVTTileIndex {\n\n private tileCoords: {z: number, x: number, y: number, id: number}[];\n private total: number = 0;\n\n /** @internal */\n public tiles: {[key: string]: GeoJSONVTInternalTile};\n /** @internal */\n public stats: {[key: string]: number} = {};\n \n\n constructor(private options: GeoJSONVTOptions) {\n this.tiles = {};\n this.tileCoords = [];\n this.stats = {};\n this.total = 0;\n }\n\n initialize(features: GeoJSONVTInternalFeature[]): void {\n // start slicing from the top tile down\n this.splitTile(features, 0, 0, 0);\n\n if (this.options.debug) {\n if (features.length) console.log('features: %d, points: %d', this.tiles[0].numFeatures, this.tiles[0].numPoints);\n console.timeEnd('generate tiles');\n console.log('tiles generated:', this.total, JSON.stringify(this.stats));\n }\n }\n\n /** {@inheritdoc} */\n updateIndex(source: GeoJSONVTInternalFeature[], affected: GeoJSONVTInternalFeature[], options: GeoJSONVTOptions): void {\n if (options.debug > 1) {\n console.log('invalidating tiles');\n console.time('invalidating');\n }\n\n this.invalidateTiles(affected);\n\n if (options.debug > 1) console.timeEnd('invalidating');\n\n // re-generate root tile with updated feature set\n const [z, x, y] = [0, 0, 0];\n const rootTile = createTile(source, z, x, y, options);\n rootTile.source = source;\n\n // update tile index with new root tile - ready for getTile calls\n const id = toID(z, x, y);\n this.tiles[id] = rootTile;\n this.tileCoords.push({z, x, y, id});\n\n if (options.debug) {\n const key = `z${z}`;\n this.stats[key] = (this.stats[key] || 0) + 1;\n this.total++;\n }\n }\n\n /** {@inheritdoc} */\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n getClusterExpansionZoom(_clusterId: number): number | null {\n return null;\n }\n\n /** {@inheritdoc} */\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n getChildren(_clusterId: number): ClusterOrPointFeature[] | null {\n return null;\n }\n\n /** {@inheritdoc} */\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n getLeaves(_clusterId: number, _limit?: number, _offset?: number): GeoJSON.Feature[] | null {\n return null;\n }\n\n /** {@inheritdoc} */\n getTile(z: number, x: number, y: number): GeoJSONVTTile | null {\n const {extent, debug} = this.options;\n \n const z2 = 1 << z;\n x = (x + z2) & (z2 - 1); // wrap tile x coordinate\n\n const id = toID(z, x, y);\n if (this.tiles[id]) {\n return transformTile(this.tiles[id], extent);\n }\n\n if (debug > 1) console.log('drilling down to z%d-%d-%d', z, x, y);\n\n let z0 = z;\n let x0 = x;\n let y0 = y;\n let parent;\n\n while (!parent && z0 > 0) {\n z0--;\n x0 = x0 >> 1;\n y0 = y0 >> 1;\n parent = this.tiles[toID(z0, x0, y0)];\n }\n\n if (!parent?.source) return null;\n\n // if we found a parent tile containing the original geometry, we can drill down from it\n if (debug > 1) {\n console.log('found parent tile z%d-%d-%d', z0, x0, y0);\n console.time('drilling down');\n }\n this.splitTile(parent.source, z0, x0, y0, z, x, y);\n if (debug > 1) console.timeEnd('drilling down');\n\n if (!this.tiles[id]) return null;\n\n return transformTile(this.tiles[id], extent);\n }\n\n /**\n * splits features from a parent tile to sub-tiles.\n * z, x, and y are the coordinates of the parent tile\n * cz, cx, and cy are the coordinates of the target tile\n * \n * If no target tile is specified, splitting stops when we reach the maximum\n * zoom or the number of points is low as specified in the options.\n * @internal\n * @param features - features to split\n * @param z - tile zoom level\n * @param x - tile x coordinate\n * @param y - tile y coordinate\n * @param cz - target tile zoom level\n * @param cx - target tile x coordinate\n * @param cy - target tile y coordinate\n */\n private splitTile(features: GeoJSONVTInternalFeature[], z: number, x: number, y: number, cz?: number, cx?: number, cy?: number) {\n\n const stack = [features, z, x, y];\n const options = this.options;\n const debug = options.debug;\n\n // avoid recursion by using a processing queue\n while (stack.length) {\n y = stack.pop() as number;\n x = stack.pop() as number;\n z = stack.pop() as number;\n features = stack.pop() as GeoJSONVTInternalFeature[];\n\n const z2 = 1 << z;\n const id = toID(z, x, y);\n let tile = this.tiles[id];\n\n if (!tile) {\n if (debug > 1) console.time('creation');\n\n tile = this.tiles[id] = createTile(features, z, x, y, options);\n this.tileCoords.push({z, x, y, id});\n\n if (debug) {\n if (debug > 1) {\n console.log('tile z%d-%d-%d (features: %d, points: %d, simplified: %d)',\n z, x, y, tile.numFeatures, tile.numPoints, tile.numSimplified);\n console.timeEnd('creation');\n }\n const key = `z${z}`;\n this.stats[key] = (this.stats[key] || 0) + 1;\n this.total++;\n }\n }\n\n // save reference to original geometry in tile so that we can drill down later if we stop now\n tile.source = features;\n\n // if it's the first-pass tiling\n if (cz == null) {\n // stop tiling if we reached max zoom, or if the tile is too simple\n if (z === options.indexMaxZoom || tile.numPoints <= options.indexMaxPoints) continue;\n // if a drilldown to a specific tile\n } else if (z === options.maxZoom || z === cz) {\n // stop tiling if we reached base zoom or our target tile zoom\n continue;\n } else if (cz != null) {\n // stop tiling if it's not an ancestor of the target tile\n const zoomSteps = cz - z;\n if (x !== cx >> zoomSteps || y !== cy >> zoomSteps) continue;\n }\n\n // if we slice further down, no need to keep source geometry\n tile.source = null;\n\n if (!features.length) continue;\n\n if (debug > 1) console.time('clipping');\n\n // values we'll use for clipping\n const k1 = 0.5 * options.buffer / options.extent;\n const k2 = 0.5 - k1;\n const k3 = 0.5 + k1;\n const k4 = 1 + k1;\n\n let tl = null;\n let bl = null;\n let tr = null;\n let br = null;\n\n const left = clip(features, z2, x - k1, x + k3, AxisType.X, tile.minX, tile.maxX, options);\n const right = clip(features, z2, x + k2, x + k4, AxisType.X, tile.minX, tile.maxX, options);\n\n if (left) {\n tl = clip(left, z2, y - k1, y + k3, AxisType.Y, tile.minY, tile.maxY, options);\n bl = clip(left, z2, y + k2, y + k4, AxisType.Y, tile.minY, tile.maxY, options);\n }\n\n if (right) {\n tr = clip(right, z2, y - k1, y + k3, AxisType.Y, tile.minY, tile.maxY, options);\n br = clip(right, z2, y + k2, y + k4, AxisType.Y, tile.minY, tile.maxY, options);\n }\n\n if (debug > 1) console.timeEnd('clipping');\n\n stack.push(tl || [], z + 1, x * 2, y * 2);\n stack.push(bl || [], z + 1, x * 2, y * 2 + 1);\n stack.push(tr || [], z + 1, x * 2 + 1, y * 2);\n stack.push(br || [], z + 1, x * 2 + 1, y * 2 + 1);\n }\n }\n\n /**\n * Invalidates (removes) tiles affected by the provided features\n * @internal\n * @param features \n */\n private invalidateTiles(features: GeoJSONVTInternalFeature[]) {\n if (!features.length) return;\n const options = this.options;\n const {debug} = options;\n\n // calculate bounding box of all features for trivial reject\n let minX = Infinity;\n let maxX = -Infinity;\n let minY = Infinity;\n let maxY = -Infinity;\n\n for (const feature of features) {\n minX = Math.min(minX, feature.minX);\n maxX = Math.max(maxX, feature.maxX);\n minY = Math.min(minY, feature.minY);\n maxY = Math.max(maxY, feature.maxY);\n }\n\n // tile buffer clipping value - not halved as in splitTile above because checking against tile's own extent\n const k1 = options.buffer / options.extent;\n\n // track removed tile ids for o(1) lookup\n const removedLookup = new Set();\n\n // iterate through existing tiles and remove ones that are affected by features\n for (const id in this.tiles) {\n const tile = this.tiles[id];\n\n // calculate tile bounds including buffer\n const z2 = 1 << tile.z;\n const tileMinX = (tile.x - k1) / z2;\n const tileMaxX = (tile.x + 1 + k1) / z2;\n const tileMinY = (tile.y - k1) / z2;\n const tileMaxY = (tile.y + 1 + k1) / z2;\n\n // trivial reject if feature bounds don't intersect tile\n if (maxX < tileMinX || minX >= tileMaxX ||\n maxY < tileMinY || minY >= tileMaxY) {\n continue;\n }\n\n // check if any feature intersects with the tile\n let intersects = false;\n for (const feature of features) {\n if (feature.maxX >= tileMinX && feature.minX < tileMaxX &&\n feature.maxY >= tileMinY && feature.minY < tileMaxY) {\n intersects = true;\n break;\n }\n }\n if (!intersects) continue;\n\n if (debug) {\n if (debug > 1) {\n console.log('invalidate tile z%d-%d-%d (features: %d, points: %d, simplified: %d)',\n tile.z, tile.x, tile.y, tile.numFeatures, tile.numPoints, tile.numSimplified);\n }\n const key = `z${tile.z}`;\n this.stats[key] = (this.stats[key] || 0) - 1;\n this.total--;\n }\n\n delete this.tiles[id];\n removedLookup.add(id);\n }\n\n // remove tile coords that are no longer in the index\n if (removedLookup.size) {\n this.tileCoords = this.tileCoords.filter(c => !removedLookup.has(c.id));\n }\n }\n}\n\nfunction toID(z: number, x: number, y: number): number {\n return (((1 << z) * y + x) * 32) + z;\n}","import {convertToInternal} from './convert';\nimport {convertToGeoJSON, featureToGeoJSON} from './deconvert';\nimport {wrap} from './wrap';\nimport {applySourceDiff, type GeoJSONVTSourceDiff} from './difference';\nimport {ClusterTileIndex, defaultClusterOptions} from './cluster-tile-index';\nimport {TileIndex} from './tile-index';\nimport type {ClusterOrPointFeature, GeoJSONVTTileIndex, GeoJSONVTInternalFeature, GeoJSONVTOptions, GeoJSONVTTile, SuperclusterOptions} from './definitions';\n\nexport const defaultOptions: GeoJSONVTOptions = {\n maxZoom: 14,\n indexMaxZoom: 5,\n indexMaxPoints: 100000,\n tolerance: 3,\n extent: 4096,\n buffer: 64,\n lineMetrics: false,\n promoteId: null,\n generateId: false,\n updateable: false,\n cluster: false,\n clusterOptions: defaultClusterOptions,\n debug: 0\n};\n\n/**\n * Main class for creating and managing a vector tile index from GeoJSON data.\n */\nexport class GeoJSONVT {\n private options: GeoJSONVTOptions;\n \n private source?: GeoJSONVTInternalFeature[];\n private tileIndex: GeoJSONVTTileIndex;\n\n constructor(data: GeoJSON.GeoJSON, options?: GeoJSONVTOptions) {\n options = this.options = Object.assign({}, defaultOptions, options);\n\n const debug = options.debug;\n\n if (debug) console.time('preprocess data');\n\n if (options.maxZoom < 0 || options.maxZoom > 24) throw new Error('maxZoom should be in the 0-24 range');\n if (options.promoteId && options.generateId) throw new Error('promoteId and generateId cannot be used together.');\n\n // projects and adds simplification info\n let features = convertToInternal(data, options);\n\n if (debug) {\n console.timeEnd('preprocess data');\n console.log('index: maxZoom: %d, maxPoints: %d', options.indexMaxZoom, options.indexMaxPoints);\n console.time('generate tiles');\n }\n\n // wraps features (ie extreme west and extreme east)\n features = wrap(features, options);\n\n // for updateable indexes, store a copy of the original simplified features\n if (options.updateable) {\n this.source = features;\n }\n\n this.initializeIndex(features, options);\n }\n\n private initializeIndex(features: GeoJSONVTInternalFeature[], options: GeoJSONVTOptions) {\n this.tileIndex = options.cluster ? new ClusterTileIndex(options.clusterOptions) : new TileIndex(options);\n if (!features.length) return;\n this.tileIndex.initialize(features);\n }\n\n /**\n * Given z, x, and y tile coordinates, returns the corresponding tile with geometries in tile coordinates, much like MVT data is stored.\n * @param z - tile zoom level\n * @param x - tile x coordinate\n * @param y - tile y coordinate\n * @returns the transformed tile or null if not found\n */\n getTile(z: number | string, x: number | string, y: number | string): GeoJSONVTTile | null {\n z = +z;\n x = +x;\n y = +y;\n\n if (z < 0 || z > 24) return null;\n\n return this.tileIndex.getTile(z, x, y);\n }\n\n /**\n * Updates the source data feature set using a {@link GeoJSONVTSourceDiff}\n * @param diff - the source diff object\n */\n updateData(diff: GeoJSONVTSourceDiff, filter?: (feature: GeoJSON.Feature) => boolean) {\n const options = this.options;\n\n if (!options.updateable) throw new Error('to update tile geojson `updateable` option must be set to true');\n\n // apply diff and collect affected features and updated source that will be used to invalidate tiles\n let {affected, source} = applySourceDiff(this.source, diff, options);\n\n if (filter) {\n ({affected, source} = this.filterUpdate(source, affected, filter));\n }\n\n // nothing has changed\n if (!affected.length) return;\n\n // update source with new simplified feature set\n this.source = source;\n\n this.tileIndex.updateIndex(source, affected, options);\n }\n\n /**\n * Filter an update using a predicate function. Returns the affected and updated source features.\n */\n private filterUpdate(source: GeoJSONVTInternalFeature[], affected: GeoJSONVTInternalFeature[], predicate: (feature: GeoJSON.Feature) => boolean) {\n const removeIds = new Set();\n\n for (const feature of source) {\n if (feature.id == undefined) continue;\n if (predicate(featureToGeoJSON(feature))) continue;\n affected.push(feature);\n removeIds.add(feature.id);\n }\n source = source.filter(feature => !removeIds.has(feature.id));\n\n return {affected, source};\n }\n\n /**\n * Returns source data as GeoJSON - only available when `updateable` option is set to true.\n */\n getData(): GeoJSON.GeoJSON {\n if (!this.options.updateable) throw new Error('to retrieve data the `updateable` option must be set to true');\n return convertToGeoJSON(this.source);\n }\n \n /**\n * Update supercluster options and regenerate the index.\n * @param cluster - whether to enable clustering\n * @param clusterOptions - {@link SuperclusterOptions}\n */\n updateClusterOptions(cluster: boolean, clusterOptions: SuperclusterOptions) {\n const wasCluster = this.options.cluster;\n this.options.cluster = cluster;\n this.options.clusterOptions = clusterOptions;\n\n if (wasCluster == cluster) {\n this.tileIndex.updateIndex(this.source, [], this.options);\n return; \n }\n\n this.initializeIndex(this.source, this.options);\n }\n\n /**\n * Returns the zoom level at which a cluster expands into multiple children.\n * @param clusterId - The target cluster id.\n * @returns the expansion zoom or null in case of non-clustered source\n */\n getClusterExpansionZoom(clusterId: number): number | null {\n return this.tileIndex.getClusterExpansionZoom(clusterId);\n }\n\n /**\n * Returns the immediate children (clusters or points) of a cluster as GeoJSON.\n * @param clusterId - The target cluster id.\n * @returns the immediate children or null in case of non-clustered source\n */\n getClusterChildren(clusterId: number): ClusterOrPointFeature[] | null {\n return this.tileIndex.getChildren(clusterId);\n }\n\n /**\n * Returns leaf point features under a cluster, paginated by `limit` and `offset`.\n * @param clusterId - The target cluster id.\n * @param limit - Maximum number of points to return (defaults to `10`).\n * @param offset - Number of points to skip before collecting results (defaults to `0`).\n * @returns leaf point features under a cluster or null in case of non-clustered source\n */\n getClusterLeaves(clusterId: number, limit: number, offset: number): GeoJSON.Feature[] | null {\n return this.tileIndex.getLeaves(clusterId, limit, offset);\n }\n}\n","import {AxisType, clip} from './clip';\nimport {convertToInternal} from './convert';\nimport {defaultOptions} from './geojsonvt';\nimport {createTile} from './tile';\nimport {transformTile} from './transform';\nimport {wrap} from './wrap';\nimport type {GeoJSONToTileOptions, GeoJSONVTTile} from './definitions';\n\n/**\n * Converts GeoJSON data directly to a single vector tile without building a tile index.\n *\n * Unlike the {@link GeoJSONVT} class which builds a hierarchical tile index for efficient\n * repeated tile access, this function generates a single tile on-demand. This is useful when:\n * - You only need one specific tile and don't need to query multiple tiles\n * - The source data is already spatially filtered to the tile's bounding box\n * - You want to avoid the overhead of building a full tile index\n *\n * @example\n * ```ts\n * import {geoJSONToTile} from '@maplibre/geojson-vt';\n *\n * const geojson = {\n * type: 'FeatureCollection',\n * features: [{\n * type: 'Feature',\n * geometry: { type: 'Point', coordinates: [-77.03, 38.90] },\n * properties: { name: 'Washington, D.C.' }\n * }]\n * };\n *\n * const tile = geoJSONToTile(geojson, 10, 292, 391, { extent: 4096 });\n * ```\n *\n * @param data - GeoJSON data (Feature, FeatureCollection, or Geometry)\n * @param z - Tile zoom level\n * @param x - Tile x coordinate\n * @param y - Tile y coordinate\n * @param options - Optional configuration for tile generation\n * @returns The generated tile with geometries in tile coordinates, or null if no features\n */\n\nexport function geoJSONToTile(data: GeoJSON.GeoJSON, z: number, x: number, y: number, options: GeoJSONToTileOptions = {}): GeoJSONVTTile {\n options = {...defaultOptions, ...options};\n const {wrap: shouldWrap = false, clip: shouldClip = false} = options;\n\n let features = convertToInternal(data, options);\n if (shouldWrap) {\n features = wrap(features, options);\n }\n if (shouldClip || options.lineMetrics) {\n const pow2 = 1 << z;\n const buffer = options.buffer / options.extent;\n const left = clip(features, pow2, (x - buffer), (x + 1 + buffer), AxisType.X, -1, 2, options);\n features = clip(left || [], pow2, (y - buffer), (y + 1 + buffer), AxisType.Y, -1, 2, options);\n }\n\n return transformTile(createTile(features ?? [], z, x, y, options), options.extent);\n}\n"],"x_google_ignoreList":[7],"mappings":";;;;;;;;AAOA,SAAgB,SAAS,QAAk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