UNPKG

@expofp/floorplan

Version:

Interactive floor plan library for expos and events

61 lines • 3.14 kB
import { type Box } from '@expofp/geometry'; import { type LngLatBoundsLike, type Map as MaplibreMap } from 'maplibre-gl'; import { type GeoConfig as MaplibreGeoConfig } from '../MaplibreWrapper'; import { type TransformGeoConfig } from './solver'; export interface GeoConfig extends MaplibreGeoConfig { gpsConfig: TransformGeoConfig; } export interface CameraPaddingOptions { top: number; bottom: number; left: number; right: number; } export interface FitMapOptions { duration?: number; /** Breathing room around the rect, in CSS pixels per side. */ padding?: number; /** * Breathing room as a fraction of the canvas per side, overriding `padding` * when set — the form Fit-to-screen speaks, so the legacy renderer and the map * pad a venue fit by the same proportion rather than by the same pixel count. */ paddingPercent?: number | null; } export declare const MAP_BOUNDS_PADDING_FACTOR = 3; export declare const MAP_BOUNDS_MIN_PADDING_DEGREES = 0.02; export declare const INITIAL_FIT_ZOOM_ADJUSTMENT = 0.15; export declare function deriveVenueMapBounds(config: TransformGeoConfig): LngLatBoundsLike | undefined; export declare function getLocalRectGeoBounds(rect: Box, config: TransformGeoConfig): LngLatBoundsLike; /** Viewport a camera has to frame a rect inside, in CSS pixels. */ export interface ViewportPx { width: number; height: number; } /** * The camera that frames a plan-local rect exactly, with the map rotated to the * plan's bearing. * * Deliberately *not* `map.cameraForBounds`. A `LngLatBounds` is north-aligned, * so a rect on a rotated plan can only reach MapLibre as its geographic AABB — * and `cameraForBounds` then fits the AABB's north-west→south-east *diagonal* * re-rotated into the bearing-aligned frame, a box with no relation to the rect * once the bearing is not a multiple of 90°. At a -48.8° bearing a 1159x814 * plan rect reaches the fit as roughly 45x597, so the vertical constraint wins * and the camera lands ~1.27 zoom levels (2.4x) too far out. Rotating the * rect's own four corners before measuring is the whole fix. * * Returns null when the rect, the projection or the viewport can't produce a * camera; callers keep their current framing in that case. */ export declare function cameraForLocalRect(rect: Box, config: TransformGeoConfig, bearing: number, viewport: ViewportPx, padding: CameraPaddingOptions): { center: [number, number]; zoom: number; } | null; export declare function getVisibleRectFitPadding(extraPadding?: number): CameraPaddingOptions; /** Whether a lng/lat projects inside the visible viewport, inset by `padding`. */ export declare function isLngLatInVisibleViewport(map: MaplibreMap, lngLat: [number, number], padding: CameraPaddingOptions): boolean; /** Geographic configuration from fpGeo data; null when unavailable. */ export declare function deriveGeoConfig(): GeoConfig | null; export declare function fitMapToLocalRect(map: MaplibreMap | null, rect: Box | null, geoConfig: GeoConfig | null, options?: FitMapOptions): void; //# sourceMappingURL=geo-config.d.ts.map