From fcc0e2ef35abd1072a448a937abd6b1921d7cbe9 Mon Sep 17 00:00:00 2001 From: Denis Date: Mon, 25 Sep 2017 19:08:54 -0400 Subject: [PATCH] Set default export to Polylabel (#19869) --- types/polylabel/index.d.ts | 38 +++++++++--------------------- types/polylabel/polylabel-tests.ts | 12 +++++----- types/polylabel/tslint.json | 3 +++ 3 files changed, 20 insertions(+), 33 deletions(-) create mode 100644 types/polylabel/tslint.json diff --git a/types/polylabel/index.d.ts b/types/polylabel/index.d.ts index 1fe6aec3df..b9a16ed265 100644 --- a/types/polylabel/index.d.ts +++ b/types/polylabel/index.d.ts @@ -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 // 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} polygon - Given polygon coordinates in GeoJSON-like format + * @param {number} precision - Precision (1.0 by default) + * @param {boolean} debug - Debugging for Console + * @return {Array} + * @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} polygon - Given polygon coordinates in GeoJSON-like format - * @param {number} precision - Precision (1.0 by default) - * @param {boolean} debug - Debugging for Console - * @return {Array} - * @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; diff --git a/types/polylabel/polylabel-tests.ts b/types/polylabel/polylabel-tests.ts index 51a0bdb79b..1eb57821fd 100644 --- a/types/polylabel/polylabel-tests.ts +++ b/types/polylabel/polylabel-tests.ts @@ -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); diff --git a/types/polylabel/tslint.json b/types/polylabel/tslint.json new file mode 100644 index 0000000000..30a1bdde2e --- /dev/null +++ b/types/polylabel/tslint.json @@ -0,0 +1,3 @@ +{ + "extends": "dtslint/dt.json" +} \ No newline at end of file