pulse-ai-utils
Version:
Utility functions and helpers for AI-powered applications
48 lines (47 loc) • 1.28 kB
TypeScript
export interface GeohashSearchOptions {
radius: number;
limit?: number;
type?: string;
precision?: number;
}
export declare class GeohashService {
private readonly DEFAULT_PRECISION;
/**
* Generate geohash for coordinates
*/
generateGeohash(lat: number, lng: number, precision?: number): string;
/**
* Get neighboring geohashes for a given geohash
* This is crucial for boundary searches
*/
getNeighbors(hash: string): string[];
/**
* Calculate geohash search ranges for a radius query
* This minimizes the number of queries needed
*/
getSearchRanges(lat: number, lng: number, radius: number): Array<[string, string]>;
/**
* Get optimal geohash precision for given radius
*/
private getOptimalPrecision;
/**
* Get all geohash cells that overlap with search radius
*/
private getSearchHashes;
/**
* Convert set of geohashes to efficient query ranges
*/
private hashesToRanges;
/**
* Check if two geohashes are consecutive
*/
private areConsecutive;
/**
* Calculate distance between two points
*/
private haversineDistance;
/**
* Get cell size for precision level
*/
private getCellSize;
}