-
-
Notifications
You must be signed in to change notification settings - Fork 58
/
index.d.ts
97 lines (88 loc) · 2.4 KB
/
index.d.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
/**
* @fileoverview Local reverse geocoder based on GeoNames data.
* @author Thomas Steiner (tomac@google.com)
* @license Apache 2.0
*
* @param {(PointsEntry|PointsEntry[])} points One single or an array of
* latitude/longitude pairs
* @param {integer} maxResults The maximum number of results to return
* @callback callback The callback function with the results
*
* @returns {AddressObject[]} An array of GeoNames-based geocode results
*
* @example
* // With just one point
* const point = { latitude: 42.083333, longitude: 3.1 };
* geocoder.lookUp(point, 1, function(err, res) {
* console.log(JSON.stringify(res, null, 2));
* });
*
* // In batch mode with many points
* const points = [
* { latitude: 42.083333, longitude: 3.1 },
* { latitude: 48.466667, longitude: 9.133333 }
* ];
* geocoder.lookUp(points, 1, function(err, res) {
* console.log(JSON.stringify(res, null, 2));
* });
*/
/**
* The callback function with the results
*/
export type callback = () => AddressObject[];
export interface InitLoadOptions {
admin1?: boolean;
admin2?: boolean;
admin3And4?: boolean;
alternateNames?: boolean;
}
export interface InitOptions {
dumpDirectory?: string;
load?: InitLoadOptions;
citiesFileOverride?: string;
countries?: string[];
}
export interface PointsEntry {
latitude: number | string;
longitude: number | string;
}
export interface AdminCodeObject {
name: string,
asciiName: string,
geoNameId: string,
}
export interface AddressObject {
geoNameId: string;
name: string;
asciiName: string;
alternateNames?: string;
latitude: string;
longitude: string;
featureClass: string;
featureCode: string;
countryCode: string;
cc2?: string;
admin1Code: AdminCodeObject;
admin2Code?: AdminCodeObject;
admin3Code?: AdminCodeObject;
admin4Code?: AdminCodeObject;
population: string;
elevation?: string;
dem: string;
timezone: string;
modificationDate?: string;
distance: number;
}
export type lookUpCallback =
| ((error: Error) => void)
| ((error: null, addresses: Array<Array<AddressObject>>) => void);
declare const _default: {
init: (options?: InitOptions, callback?: () => void) => void;
lookUp(points: PointsEntry | PointsEntry[], callback: lookUpCallback): void;
lookUp(
points: PointsEntry | PointsEntry[],
maxResults: number,
callback: lookUpCallback
): void;
};
export default _default;