GeoLeaf Core API - v3.0.0
    Preparing search index...
    CacheCalculator: {
        defaults: {
            maxTilesPerZoom: number;
            maxTotalTiles: number;
            avgTileSize: number;
            boundsMargin: number;
            webMercatorMaxLat: number;
        };
        getTileCoordsForBounds(
            bounds: Bounds | null | undefined,
            zoom: number,
            config?: TileConfig,
        ): TileCoord[];
        latLngToTile(lat: number, lng: number, zoom: number): TileCoord;
        buildTileUrl(template: string, x: number, y: number, zoom: number): string;
        calculateProfileBounds(
            _profile: unknown,
            resources: ResourceWithSize[],
        ): Promise<Bounds | null>;
        extractCoordinates(
            geometry: {
                type?: string;
                coordinates?: unknown[];
                geometries?: unknown[];
            },
        ): number[][];
        expandBounds(bounds: Bounds | null, coords: number[][]): Bounds | null;
        estimateTileSize(tileCount: number, avgSize?: number): number;
        calculateResourcesSize(resources: ResourceWithSize[]): number;
        formatBytes(bytes: number, decimals?: number): string;
        estimateDownloadTime(bytes: number, speedMbps?: number): number;
        formatDuration(seconds: number): string;
        enumerateTiles(
            layerConfig: LayerConfigWithBounds,
            _profileId: string,
        ): Promise<
            { url: string; type: string; x: number; y: number; z: number }[],
        >;
    } = ...

    CacheCalculator Pure calculation logic for cache operations Extracted from cache-manager.js (Phase 5)

    Type Declaration

    • defaults: {
          maxTilesPerZoom: number;
          maxTotalTiles: number;
          avgTileSize: number;
          boundsMargin: number;
          webMercatorMaxLat: number;
      }
    • getTileCoordsForBounds: function
    • latLngToTile: function
      • Convert lat/lng to tile coordinates (Web Mercator projection)

        Delegates to tile-math.js. defaults.webMercatorMaxLat is forwarded explicitly so that mutating it on this object stays effective.

        Parameters

        • lat: number

          Latitude

        • lng: number

          Longitude

        • zoom: number

          Zoom level

        Returns TileCoord

        Tile coordinates

    • buildTileUrl: function
      • Build tile URL from template

        Parameters

        • template: string

          URL template with {x}, {y}, {z} placeholders

        • x: number

          Tile X coordinate

        • y: number

          Tile Y coordinate

        • zoom: number

          Zoom level

        Returns string

        Complete tile URL

    • calculateProfileBounds: function
      • Calculate bounds from layer geometries

        ⚠️ resource.url is not trusted: the enumerated resource list is fed, among others, by StyleResolver from a REMOTE TileJSON, so a hostile document can put an arbitrary URL in it. Each entry is scheme-guarded before it is fetched; a refused one is skipped like any unreadable layer, so one poisoned entry cannot blind the whole bounds computation (CAPACITÉS B.10).

        Parameters

        • _profile: unknown

          Unused. Kept in the signature so the four calculate* members share one call shape; bounds come from resources alone.

        • resources: ResourceWithSize[]

          The enumerated resources; only type: "layer" entries contribute.

        Returns Promise<Bounds | null>

        Bounds { north, south, east, west }, or null if no layer was readable.

    • extractCoordinates: function
      • Extract all coordinates from a geometry

        Parameters

        • geometry: { type?: string; coordinates?: unknown[]; geometries?: unknown[] }

          GeoJSON geometry object

        Returns number[][]

        Array of [lng, lat] coordinates

    • expandBounds: function
    • estimateTileSize: function
      • Estimate total size of tiles

        Parameters

        • tileCount: number

          Number of tiles

        • OptionalavgSize: number

          Average size per tile in bytes

        Returns number

        Estimated size in bytes

    • calculateResourcesSize: function
      • Calculate total size of resources

        Parameters

        • resources: ResourceWithSize[]

          Array of resource objects with size property

        Returns number

        Total size in bytes

    • formatBytes: function
      • Format bytes to human-readable string

        Parameters

        • bytes: number

          Size in bytes

        • Optionaldecimals: number = 2

          Number of decimal places

        Returns string

        Formatted string (e.g., "1.23 MB")

    • estimateDownloadTime: function
      • Estimate download time based on size and connection speed

        Parameters

        • bytes: number

          Size in bytes

        • OptionalspeedMbps: number = 10

          Connection speed in Mbps

        Returns number

        Estimated time in seconds

    • formatDuration: function
      • Format time duration to human-readable string

        Parameters

        • seconds: number

          Duration in seconds

        Returns string

        Formatted string (e.g., "2h 30m 15s")

    • enumerateTiles: function
      • Enumerate all tile URLs for a layer or basemap

        Parameters

        • layerConfig: LayerConfigWithBounds

          Layer or basemap configuration; supplies the bounds and zoom range.

        • _profileId: string

          Unused, kept for call-shape compatibility with the sibling members.

        Returns Promise<{ url: string; type: string; x: number; y: number; z: number }[]>

        One entry per tile, { url, type: "tile", x, y, z }.