leaflet-polydraw
Version:
Advanced Leaflet plugin for freehand polygon drawing, with smart merging and powerful editing tools. Compatible with both Leaflet v1.x and v2.x.
85 lines • 3.81 kB
TypeScript
import type { Feature, Polygon, MultiPolygon, Point, LineString, FeatureCollection, Position, Geometry } from 'geojson';
/**
* Coordinate type - array of [longitude, latitude]
*/
export type Coord = [number, number];
/**
* Creates a GeoJSON Point feature
* @param coordinates - [longitude, latitude] coordinate pair
* @param properties - Optional properties object
* @returns GeoJSON Point feature
*/
export declare function point(coordinates: Position, properties?: Record<string, unknown>): Feature<Point>;
/**
* Creates a GeoJSON LineString feature
* @param coordinates - Array of [longitude, latitude] coordinate pairs
* @param properties - Optional properties object
* @returns GeoJSON LineString feature
*/
export declare function lineString(coordinates: Position[], properties?: Record<string, unknown>): Feature<LineString>;
/**
* Creates a GeoJSON Polygon feature
* @param coordinates - Array of linear rings (first is exterior, rest are holes)
* @param properties - Optional properties object
* @returns GeoJSON Polygon feature
*/
export declare function polygon(coordinates: Position[][], properties?: Record<string, unknown>): Feature<Polygon>;
/**
* Creates a GeoJSON MultiPolygon feature
* @param coordinates - Array of polygon coordinate arrays
* @param properties - Optional properties object
* @returns GeoJSON MultiPolygon feature
*/
export declare function multiPolygon(coordinates: Position[][][], properties?: Record<string, unknown>): Feature<MultiPolygon>;
/**
* Creates a GeoJSON FeatureCollection
* @param features - Array of GeoJSON features
* @returns GeoJSON FeatureCollection
*/
export declare function featureCollection<T extends Geometry>(features: Feature<T>[]): FeatureCollection<T>;
/**
* Extracts coordinates from a GeoJSON feature
* Replaces @turf/invariant getCoords function
* @param feature - GeoJSON feature
* @returns Coordinate array(s)
*/
export declare function getCoords(feature: Feature<Polygon | MultiPolygon>): Position[][][];
export declare function bbox(feature: Feature<Geometry>): [number, number, number, number];
/**
* Creates a polygon from a bounding box
* Replaces @turf/bbox-polygon function
* @param bbox - [minX, minY, maxX, maxY] bounding box
* @returns GeoJSON Polygon feature
*/
export declare function bboxPolygon(bboxCoords: [number, number, number, number]): Feature<Polygon>;
/**
* Calculates the distance between two points using the Haversine formula
* Replaces @turf/distance function
* @param from - Starting point [lng, lat] or Point feature
* @param to - Ending point [lng, lat] or Point feature
* @param units - Distance units (default: 'kilometers')
* @returns Distance in specified units
*/
export declare function distance(from: Position | Feature<Point>, to: Position | Feature<Point>, units?: 'kilometers' | 'miles' | 'meters'): number;
/**
* Calculates the midpoint between two points
* Replaces @turf/midpoint function
* @param point1 - First point [lng, lat] or Point feature
* @param point2 - Second point [lng, lat] or Point feature
* @returns Midpoint as Point feature
*/
export declare function midpoint(point1: Position | Feature<Point>, point2: Position | Feature<Point>): Feature<Point>;
/**
* Calculates the area of a polygon using the Shoelace formula
* @param feature - Polygon or MultiPolygon feature
* @returns Area in degrees² (planar). Use @turf/area for meters².
*/
export declare function area(feature: Feature<Polygon | MultiPolygon>): number;
/**
* Calculates the centroid of a polygon
* Replaces @turf/centroid function
* @param feature - Polygon or MultiPolygon feature
* @returns Centroid as Point feature
*/
export declare function centroid(feature: Feature<Polygon | MultiPolygon>): Feature<Point>;
//# sourceMappingURL=geojson-helpers.d.ts.map