mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-12-06 13:11:46 +00:00
Set default export to Polylabel (#19869)
This commit is contained in:
Vendored
+11
-27
@@ -1,34 +1,18 @@
|
||||
// Type definitions for polylabel 1.0.0
|
||||
// Type definitions for polylabel 1.0
|
||||
// Project: https://github.com/mapbox/polylabel
|
||||
// Definitions by: Denis Carriere <https://github.com/DenisCarriere>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
/**
|
||||
* polylabel
|
||||
*
|
||||
* A fast algorithm for finding polygon pole of inaccessibility, the most distant internal point from
|
||||
* the polygon outline (not to be confused with centroid), implemented as a JavaScript library.
|
||||
* Useful for optimal placement of a text label on a polygon.
|
||||
* It's an iterative grid algorithm, inspired by paper by Garcia-Castellanos & Lombardo, 2007.
|
||||
* Unlike the one in the paper, this algorithm:
|
||||
* Polylabel returns the pole of inaccessibility coordinate in [x, y] format.
|
||||
*
|
||||
* - guarantees finding global optimum within the given precision
|
||||
* - is many times faster (10-40x)
|
||||
* @param {Array<number>} polygon - Given polygon coordinates in GeoJSON-like format
|
||||
* @param {number} precision - Precision (1.0 by default)
|
||||
* @param {boolean} debug - Debugging for Console
|
||||
* @return {Array<number>}
|
||||
* @example
|
||||
* var p = polylabel(polygon, 1.0);
|
||||
*/
|
||||
declare module "polylabel" {
|
||||
/**
|
||||
* Polylabel returns the pole of inaccessibility coordinate in [x, y] format.
|
||||
*
|
||||
* @name polylabel
|
||||
* @function
|
||||
* @param {Array<number>} polygon - Given polygon coordinates in GeoJSON-like format
|
||||
* @param {number} precision - Precision (1.0 by default)
|
||||
* @param {boolean} debug - Debugging for Console
|
||||
* @return {Array<number>}
|
||||
* @example
|
||||
* var p = polylabel(polygon, 1.0);
|
||||
*/
|
||||
function polylabel(polygon: number[][][], precision?: number, debug?: boolean): number[];
|
||||
namespace polylabel {}
|
||||
export = polylabel;
|
||||
}
|
||||
declare function polylabel(polygon: number[][][], precision?: number, debug?: boolean): number[];
|
||||
declare namespace polylabel {}
|
||||
export default polylabel;
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import * as polylabel from 'polylabel';
|
||||
import polylabel from 'polylabel';
|
||||
|
||||
const polygon = [[[3116,3071],[3118,3068],[3108,3102],[3751,927]]]
|
||||
polylabel(polygon)
|
||||
polylabel(polygon, 1.0)
|
||||
polylabel(polygon, 1.0, true)
|
||||
polylabel(polygon, 1.0, false)
|
||||
const polygon = [[[3116, 3071], [3118, 3068], [3108, 3102], [3751, 927]]];
|
||||
polylabel(polygon);
|
||||
polylabel(polygon, 1.0);
|
||||
polylabel(polygon, 1.0, true);
|
||||
polylabel(polygon, 1.0, false);
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"extends": "dtslint/dt.json"
|
||||
}
|
||||
Reference in New Issue
Block a user