From 2d07596b6f407239307f1292b4a2c63abfda653e Mon Sep 17 00:00:00 2001 From: Arseniy Maximov Date: Tue, 23 Jun 2015 17:45:29 +0300 Subject: [PATCH] Create declaration file for Polyline --- polyline/polyline-tests.ts | 16 ++++++++++++++++ polyline/polyline.d.ts | 22 ++++++++++++++++++++++ 2 files changed, 38 insertions(+) create mode 100644 polyline/polyline-tests.ts create mode 100644 polyline/polyline.d.ts diff --git a/polyline/polyline-tests.ts b/polyline/polyline-tests.ts new file mode 100644 index 0000000000..888d15f91a --- /dev/null +++ b/polyline/polyline-tests.ts @@ -0,0 +1,16 @@ +/// + +// 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": {} +}); \ No newline at end of file diff --git a/polyline/polyline.d.ts b/polyline/polyline.d.ts new file mode 100644 index 0000000000..5663fac491 --- /dev/null +++ b/polyline/polyline.d.ts @@ -0,0 +1,22 @@ +// Type definitions for Polyline 0.1.0 +// Project: https://github.com/mapbox/polyline +// Definitions by: Arseniy Maximov +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +/// + +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; +} \ No newline at end of file