{"version":3,"file":"bounds.cjs","names":[],"sources":["../../src/geo/bounds.ts"],"sourcesContent":["import type { Coordinate, GeoBounds } from \"./types\";\n\n/**\n * Compute the axis-aligned bounding box that contains every point. Returns\n * `null` for an empty list (there is nothing to bound).\n *\n * @param points - Coordinates to enclose.\n * @returns The bounds, or `null` when `points` is empty.\n */\nexport function boundingBox(points: readonly Coordinate[]): GeoBounds | null {\n    if (points.length === 0) return null;\n\n    let minLatitude = points[0].latitude;\n    let maxLatitude = points[0].latitude;\n    let minLongitude = points[0].longitude;\n    let maxLongitude = points[0].longitude;\n\n    for (const point of points) {\n        if (point.latitude < minLatitude) minLatitude = point.latitude;\n        if (point.latitude > maxLatitude) maxLatitude = point.latitude;\n        if (point.longitude < minLongitude) minLongitude = point.longitude;\n        if (point.longitude > maxLongitude) maxLongitude = point.longitude;\n    }\n\n    return { minLatitude, maxLatitude, minLongitude, maxLongitude };\n}\n\n/** Geometric center of a bounding box. */\nexport function boundsCenter(bounds: GeoBounds): Coordinate {\n    return {\n        latitude: (bounds.minLatitude + bounds.maxLatitude) / 2,\n        longitude: (bounds.minLongitude + bounds.maxLongitude) / 2,\n    };\n}\n\n/**\n * Grow a bounding box outward by `ratio` of its own span on every side, with a\n * small absolute floor so a single-point (zero-span) box still gets padding.\n * A `ratio` of `0.1` adds 10% margin — handy so a plotted trajectory does not\n * hug the edge of the viewport.\n *\n * @param bounds - The box to expand.\n * @param ratio - Fraction of the span to add per side. Default: `0.1`.\n * @returns A new, larger {@link GeoBounds}.\n */\nexport function expandBounds(bounds: GeoBounds, ratio = 0.1): GeoBounds {\n    const latSpan = bounds.maxLatitude - bounds.minLatitude;\n    const lonSpan = bounds.maxLongitude - bounds.minLongitude;\n    const latPad = latSpan * ratio || 0.001;\n    const lonPad = lonSpan * ratio || 0.001;\n\n    return {\n        minLatitude: bounds.minLatitude - latPad,\n        maxLatitude: bounds.maxLatitude + latPad,\n        minLongitude: bounds.minLongitude - lonPad,\n        maxLongitude: bounds.maxLongitude + lonPad,\n    };\n}\n"],"mappings":"AASA,SAAgB,EAAY,EAAiD,CACzE,GAAI,EAAO,SAAW,EAAG,OAAO,KAEhC,IAAI,EAAc,EAAO,EAAE,CAAC,SACxB,EAAc,EAAO,EAAE,CAAC,SACxB,EAAe,EAAO,EAAE,CAAC,UACzB,EAAe,EAAO,EAAE,CAAC,UAE7B,IAAK,IAAM,KAAS,EACZ,EAAM,SAAW,IAAa,EAAc,EAAM,UAClD,EAAM,SAAW,IAAa,EAAc,EAAM,UAClD,EAAM,UAAY,IAAc,EAAe,EAAM,WACrD,EAAM,UAAY,IAAc,EAAe,EAAM,WAG7D,MAAO,CAAE,cAAa,cAAa,eAAc,cAAa,CAClE,CAGA,SAAgB,EAAa,EAA+B,CACxD,MAAO,CACH,UAAW,EAAO,YAAc,EAAO,aAAe,EACtD,WAAY,EAAO,aAAe,EAAO,cAAgB,CAC7D,CACJ,CAYA,SAAgB,EAAa,EAAmB,EAAQ,GAAgB,CACpE,IAAM,EAAU,EAAO,YAAc,EAAO,YACtC,EAAU,EAAO,aAAe,EAAO,aACvC,EAAS,EAAU,GAAS,KAC5B,EAAS,EAAU,GAAS,KAElC,MAAO,CACH,YAAa,EAAO,YAAc,EAClC,YAAa,EAAO,YAAc,EAClC,aAAc,EAAO,aAAe,EACpC,aAAc,EAAO,aAAe,CACxC,CACJ"}