51 lines
1.8 KiB
TypeScript

/**
* Spatial utility functions for geographic calculations.
*/
/**
* Ray-casting algorithm to determine if a point is inside a polygon.
* @param lat Point latitude
* @param lng Point longitude
* @param polygonCoords Array of [lng, lat] coordinate pairs (GeoJSON order)
*/
export declare function isPointInPolygon(lat: number, lng: number, polygonCoords: number[][]): boolean;
/**
* Parse GeoJSON string and extract coordinate arrays for all polygons.
* Supports Polygon and MultiPolygon types.
* Returns array of coordinate rings (outer rings only).
*/
export declare function parseGeoJsonPolygon(geojsonString: string): number[][][];
/**
* Calculate bounding box from an array of [lng, lat] coordinate pairs.
* Returns { minLat, maxLat, minLng, maxLng }.
*/
export declare function calculateBounds(coordinates: number[][]): {
minLat: number;
maxLat: number;
minLng: number;
maxLng: number;
};
/**
* Haversine distance between two lat/lng points in meters.
*/
export declare function haversineDistance(lat1: number, lng1: number, lat2: number, lng2: number): number;
/**
* Calculate the centroid of an array of [lng, lat] coordinate pairs.
* Returns { lat, lng }.
*/
/**
* Calculate a bounding box from a map center point and zoom level.
* Uses Web Mercator tile math to derive the geographic extent visible
* on a map of the given pixel dimensions at the given zoom.
* Default viewport: 1024x768 pixels.
*/
export declare function boundsFromCenterZoom(lat: number, lng: number, zoom: number, widthPx?: number, heightPx?: number): {
minLat: number;
maxLat: number;
minLng: number;
maxLng: number;
};
export declare function calculateCentroid(coordinates: number[][]): {
lat: number;
lng: number;
};
//# sourceMappingURL=spatial.d.ts.map