Set default export to Polylabel (#19869)

This commit is contained in:
Denis
2017-09-25 16:08:54 -07:00
committed by Mohamed Hegazy
parent eef993565c
commit fcc0e2ef35
3 changed files with 20 additions and 33 deletions
+11 -27
View File
@@ -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;
+6 -6
View File
@@ -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);
+3
View File
@@ -0,0 +1,3 @@
{
"extends": "dtslint/dt.json"
}