import { type Result } from '@mappedin/safe-types/result'; import type { Feature, Polygon } from '../types/geojson.js'; /** * Computes the `[longitude, latitude]` center of a polygon feature (used for the * `center` of spaces, obstructions, and areas). Return an `err` for geometry * that cannot be centered so the converter can leave `center` undefined. * * Supply a custom implementation via {@link CenterStrategy} to fully control how * centers are computed. */ export type CenterCalculator = (feature: Feature) => Result<[number, number], Error>; /** * Selects how polygon centers are computed during v3 → v2 conversion. * * - `'center-of-mass'` (default): the area-weighted centroid, matching turf's * `centerOfMass` — the algorithm Maker uses when it generates MVFv2 natively. * Reproduces the `space.center` of native MVFv2 bundles, is a single O(n) pass * (no measurable conversion overhead), and falls back to `polylabel` only when * the centroid lands outside a concave shape. * - `'visual-center'`: the pole of inaccessibility via `polylabel` — the interior * point furthest from any edge. Stays deep inside concave shapes but costs * ~20× more per polygon and does not match native MVFv2 centers. * - a {@link CenterCalculator}: a fully custom implementation. */ export type CenterStrategy = 'center-of-mass' | 'visual-center' | CenterCalculator; /** * `'center-of-mass'` strategy: the area-weighted centroid (turf `centerOfMass`), * with a `polylabel` fallback when the centroid lands outside a concave polygon. * This is the default {@link CenterStrategy} and reproduces the `space.center` * values of natively generated Maker MVFv2 bundles. * * @param f - The polygon feature to center. * @returns The `[longitude, latitude]` center, or an error for invalid geometry. */ export declare const centerOfMass: CenterCalculator; /** * `'visual-center'` strategy: the pole of inaccessibility via `polylabel`. This * is the interior point furthest from any edge, so it stays inside concave * shapes and is not skewed by dense runs of vertices along one edge. Opt in via * {@link CenterStrategy} when you want the most visually centered point rather * than parity with native MVFv2 centers. * * @param f - The polygon feature to center. * @returns The `[longitude, latitude]` center, or an error for invalid geometry. */ export declare const labelCenter: CenterCalculator; /** * Resolves a {@link CenterStrategy} to the {@link CenterCalculator} that * implements it. A function strategy is returned as-is. * * @param strategy - The strategy to resolve. * @default 'center-of-mass' * @returns The center calculator for the strategy. */ export declare const resolveCenterCalculator: (strategy?: CenterStrategy) => CenterCalculator; //# sourceMappingURL=geoCenter.d.ts.map