leaflet
Version:
JavaScript library for mobile-friendly interactive maps
37 lines (36 loc) • 1.51 kB
TypeScript
import { LatLng } from '../geo/LatLng.js';
import { Point } from './Point.js';
import type { Bounds } from './Bounds.js';
import type { CRS } from '../geo/crs/CRS.js';
import type { LatLngExpression } from '../types.js';
/**
* @import {Bounds} from './Bounds.js'
* @import {CRS} from '../geo/crs/CRS.js'
* @import {LatLngExpression} from '../types.js'
*/
/**
* Various utility functions for polygon geometries.
* @module PolyUtil
*/
/**
* Clips the polygon geometry defined by the given `points` by the given bounds (using the [Sutherland-Hodgman
* algorithm](https://en.wikipedia.org/wiki/Sutherland%E2%80%93Hodgman_algorithm)). Used by Leaflet to only
* show polygon points that are on the screen or near, increasing performance. Note that polygon points needs
* different algorithm for clipping than polyline, so there's a separate method for it.
* @param {Point[]} points
* @param {Bounds} bounds
* @param {boolean} [round]
*/
export declare function clipPolygon(points: Point[], bounds: Bounds, round?: boolean): Point[];
/**
* Returns the center ([centroid](http://en.wikipedia.org/wiki/Centroid))
* of the passed LatLngs (first ring) from a polygon.
* @param {LatLngExpression[]} latlngs
* @param {typeof CRS} crs
*/
export declare function polygonCenter(latlngs: LatLngExpression[], crs: typeof CRS): LatLng;
/**
* Returns the 'center of mass' of the passed LatLngs.
* @param {LatLngExpression[]} coords
*/
export declare function centroid(coords: LatLngExpression[]): LatLng;