mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-10-06 15:57:13 +00:00
Adds typings for latlon-geohash
This commit is contained in:
Vendored
+51
@@ -0,0 +1,51 @@
|
||||
// Type definitions for latlon-geohash 1.1
|
||||
// Project: https://github.com/chrisveness/latlon-geohash
|
||||
// Definitions by: Robert Imig <https://github.com/rimig>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
|
||||
declare module "latlon-geohash" {
|
||||
enum Direction {
|
||||
North = "N",
|
||||
South = "S",
|
||||
East = "E",
|
||||
West = "W",
|
||||
}
|
||||
|
||||
interface Neighbours {
|
||||
n: string;
|
||||
ne: string;
|
||||
e: string;
|
||||
se: string;
|
||||
s: string;
|
||||
sw: string;
|
||||
w: string;
|
||||
nw: string;
|
||||
}
|
||||
|
||||
/*
|
||||
* Encode latitude/longitude point to geohash of given precision (number of characters in resulting geohash).
|
||||
* If precision is not specified, it is inferred from precision of latitude/longitude values.
|
||||
*/
|
||||
function encode(latitude: number, longitude: number, precision?: number): string;
|
||||
|
||||
/*
|
||||
* return { lat, lon } of centre of given geohash, to appropriate precision.
|
||||
*/
|
||||
function decode(geohash: string): number[];
|
||||
|
||||
/*
|
||||
* return { sw, ne } bounds of given geohash.
|
||||
*/
|
||||
function bounds(geohash: string): number[];
|
||||
|
||||
/*
|
||||
* return adjacent cell to given geohash in specified direction (N/S/E/W).
|
||||
*/
|
||||
function adjacent(geohash: string, direction: (Direction | string)): string;
|
||||
|
||||
/*
|
||||
* return all 8 adjacent cells (n/ne/e/se/s/sw/w/nw) to given geohash.
|
||||
*/
|
||||
function neighbours(geohash: string): Neighbours;
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
import * as Geohash from "latlon-geohash";
|
||||
|
||||
// Encoding
|
||||
const atx_geohash: string = Geohash.encode(30.2672, -97.7431);
|
||||
const atx_geohash_p3: string = Geohash.encode(30.2672, -97.7431, 3);
|
||||
|
||||
// Decoding
|
||||
const atx_latlong: number[] = Geohash.decode(atx_geohash);
|
||||
|
||||
// Bounds
|
||||
const atx_bounds: number[] = Geohash.bounds(atx_geohash);
|
||||
|
||||
// Adjacent
|
||||
const atx_adj_cell1: string = Geohash.adjacent(atx_geohash, Geohash.Direction.North);
|
||||
const atx_adj_cell2: string = Geohash.adjacent(atx_geohash, "N");
|
||||
|
||||
// Neighbors
|
||||
const atx_neighbors: Geohash.Neighbours = Geohash.neighbours(atx_geohash);
|
||||
const atx_adj_cell3: string = atx_neighbors.n;
|
||||
@@ -0,0 +1,22 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"lib": [
|
||||
"es6"
|
||||
],
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictNullChecks": true,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": [
|
||||
"../"
|
||||
],
|
||||
"types": [],
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true
|
||||
},
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"latlon-geohash-tests.ts"
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
{ "extends": "dtslint/dt.json" }
|
||||
Reference in New Issue
Block a user