From 76eedd816aeb57b2ab3e551a8b36f6008a4268b3 Mon Sep 17 00:00:00 2001 From: Erkie Date: Mon, 3 Oct 2016 14:24:53 +0200 Subject: [PATCH] Create typings for ngeohash (#11634) --- ngeohash/ngeohash-tests.ts | 10 ++++++++++ ngeohash/ngeohash.d.ts | 32 ++++++++++++++++++++++++++++++++ 2 files changed, 42 insertions(+) create mode 100644 ngeohash/ngeohash-tests.ts create mode 100644 ngeohash/ngeohash.d.ts diff --git a/ngeohash/ngeohash-tests.ts b/ngeohash/ngeohash-tests.ts new file mode 100644 index 0000000000..0ff987802e --- /dev/null +++ b/ngeohash/ngeohash-tests.ts @@ -0,0 +1,10 @@ +/// + +import geohash = require('ngeohash'); + +console.log(geohash.encode(37.8324, 112.5584)); +// prints ww8p1r4t8 + +var latlon = geohash.decode('ww8p1r4t8'); +console.log(latlon.latitude); +console.log(latlon.longitude); diff --git a/ngeohash/ngeohash.d.ts b/ngeohash/ngeohash.d.ts new file mode 100644 index 0000000000..25c8f29e5b --- /dev/null +++ b/ngeohash/ngeohash.d.ts @@ -0,0 +1,32 @@ +// Type definitions for ngeohash v0.6.0 +// Project: https://github.com/sunng87/node-geohash +// Definitions by: Erik Rothoff Andersson +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped/ + +declare namespace ngeohash { + interface GeographicPoint { + latitude: number; + longitude: number; + } + + type GeographicBoundingBox = [number, number, number, number]; + type NSEW = [number, number]; + + function encode(latitude: number, longitude: number, precision?: number): string; + function decode(hashstring: string): GeographicPoint; + function decode_bbox(hashstring: string): GeographicBoundingBox; + function bboxes(minlat: number, minlon: number, maxlat: number, maxlon: number, precision?: number): Array; + function neighbor(hashstring: string, direction: NSEW): string; + function neighbors(hashstring: string): Array; + + function encode_int(latitude: number, longitude: number, bitDepth?: number): number; + function decode_int(hashinteger: number, bitDepth?: number): GeographicPoint; + function decode_bbox_int(hashinteger: number, bitDepth?: number): GeographicBoundingBox; + function bboxes_int(minlat: number, minlon: number, maxlat: number, maxlon: number, bitDepth?: number): number; + function neighbor_int(hashinteger: number, direction: NSEW, bitDepth?: number): number; + function neighbors_int(hashinteger: number, bitDepth?: number): number; +} + +declare module "ngeohash" { + export = ngeohash; +}