pulse-ai-utils
Version:
Utility functions and helpers for AI-powered applications
36 lines (35 loc) • 1.13 kB
TypeScript
import { Firestore } from '@google-cloud/firestore';
export interface GeohashQueryResult {
id: string;
distance: number;
data: any;
}
export declare class GeohashFirestoreQuery {
private geohashService;
constructor();
/**
* Perform efficient geohash-based query on Firestore
*/
queryByRadius(db: Firestore, collection: string, centerLat: number, centerLng: number, radius: number, filters?: Record<string, any>): Promise<GeohashQueryResult[]>;
/**
* Execute a single range query
*/
private executeRangeQuery;
/**
* Deduplicate results and filter by exact radius
*/
private deduplicateAndFilter;
/**
* Calculate distance between two points
*/
private haversineDistance;
/**
* Progressive radius search - start small and expand if needed
*/
progressiveRadiusSearch(db: Firestore, collection: string, centerLat: number, centerLng: number, options?: {
initialRadius?: number;
maxRadius?: number;
minResults?: number;
filters?: Record<string, any>;
}): Promise<GeohashQueryResult[]>;
}