forked from DefinitelyTyped/DefinitelyTyped
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request DefinitelyTyped#10921 from DenisCarriere/master
Implemented polylabel definition
- Loading branch information
Showing
2 changed files
with
43 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
/// <reference path="./polylabel.d.ts" /> | ||
/// <reference path="../node/node.d.ts" /> | ||
import polylabel = require('polylabel'); | ||
|
||
const polygon = [[[3116,3071],[3118,3068],[3108,3102],[3751,927]]] | ||
let p: number[] | ||
p = polylabel(polygon) | ||
p = polylabel(polygon, 1.0) | ||
p = polylabel(polygon, 1.0, true) | ||
p = polylabel(polygon, 1.0, false) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
// Type definitions for polylabel 1.0.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: | ||
* | ||
* - guarantees finding global optimum within the given precision | ||
* - is many times faster (10-40x) | ||
*/ | ||
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[]; | ||
export = polylabel; | ||
} |