Create declaration file for Polyline

This commit is contained in:
Arseniy Maximov
2015-06-23 17:45:29 +03:00
parent 2d0a04f068
commit 2d07596b6f
2 changed files with 38 additions and 0 deletions

View File

@@ -0,0 +1,16 @@
/// <reference path="./polyline.d.ts" />
// returns an array of lat, lon pairs
polyline.decode('_p~iF~ps|U_ulLnnqC_mqNvxq`@');
// returns a string-encoded polyline
polyline.encode([[38.5, -120.2], [40.7, -120.95], [43.252, -126.453]]);
// returns a string-encoded polyline from a GeoJSON LineString
polyline.fromGeoJSON({ "type": "Feature",
"geometry": {
"type": "LineString",
"coordinates": [[-120.2, 38.5], [-120.95, 40.7], [-126.453, 43.252]]
},
"properties": {}
});

22
polyline/polyline.d.ts vendored Normal file
View File

@@ -0,0 +1,22 @@
// Type definitions for Polyline 0.1.0
// Project: https://github.com/mapbox/polyline
// Definitions by: Arseniy Maximov <https://github.com/Kern0>
// Definitions: https://github.com/borisyankov/DefinitelyTyped
/// <reference path="../geojson/geojson.d.ts" />
interface NumberArray {
[index: number]: number;
}
interface Polyline {
decode(string: string, precision?: number): NumberArray[];
encode(coordinate: NumberArray[], precision?: number): string;
fromGeoJSON(geojson: GeoJSON.GeoJsonObject, precision?: number): string;
}
declare var polyline: Polyline;
declare module "polyline" {
export = polyline;
}