geocoder-opencagedata
Version:
An OpenCageData geocoder API client that supports caching and is written on typescript
103 lines (102 loc) • 2.41 kB
TypeScript
export interface IGeocoderOptions {
api_key?: string;
api_url?: string;
pace_limit?: number;
cached?: boolean;
}
export interface IGeoQuery {
q: string;
key?: string;
abbrv?: number;
add_request?: number;
bounds?: string;
countrycode?: string;
language?: string;
limit?: number;
min_confidence?: number;
no_annotations?: number;
no_dedupe?: number;
no_record?: number;
pretty?: number;
proximity?: string;
roadinfo?: number;
}
export interface IGeoPoint {
lat: number | void;
lng: number | void;
}
export interface IGeoResponseForwardCoding {
ok: boolean;
documentation: string;
licenses: {
name: string;
url: string;
}[];
rate: {
limit: number;
remaining: number;
reset: number;
};
results: {
annotations?: any;
bounds: {
northeast: IGeoPoint;
southwest: IGeoPoint;
};
components?: any;
confidence: number;
formatted: string;
geometry: IGeoPoint;
}[];
status: {
code: number;
message: string;
};
stay_informed: {
blog: string;
twitter: string;
};
thanks: string;
timestamp: {
created_http: string;
created_unix: number;
};
total_results: number;
}
export interface IGeoResult {
ok: boolean;
geo: IGeoPoint;
}
export declare class Geocoder {
private API_KEY;
private API_URL;
private pace;
private cached;
constructor({ api_key, api_url, pace_limit, cached }?: IGeocoderOptions);
geocode(query: string | IGeoQuery): Promise<GeoResult>;
}
export default Geocoder;
export declare class geocoder extends Geocoder {
}
declare class GeoResult implements IGeoResult {
status: undefined | {
code: number;
message: string;
};
total_results: undefined | number;
results: undefined | {
annotations?: any;
bounds: {
northeast: IGeoPoint;
southwest: IGeoPoint;
};
components?: any;
confidence: number;
formatted: string;
geometry: IGeoPoint;
}[];
constructor(data: any);
get ok(): boolean;
get geo(): IGeoPoint;
get address(): string;
}