primitive clustering, cache nominatim

This commit is contained in:
Will Freeman
2024-10-29 19:45:30 -06:00
parent fdae715409
commit 0680fcb908
8 changed files with 204 additions and 43 deletions
+16
View File
@@ -1,5 +1,11 @@
import axios from "axios";
export interface Cluster {
id: string;
lat: number;
lon: number;
}
export interface BoundingBoxLiteral {
minLat: number;
maxLat: number;
@@ -20,6 +26,10 @@ export class BoundingBox implements BoundingBoxLiteral {
this.maxLng = maxLng;
}
containsPoint(lat: number, lng: number) {
return lat >= this.minLat && lat <= this.maxLat && lng >= this.minLng && lng <= this.maxLng;
}
updateFromOther(boundingBoxLiteral: BoundingBoxLiteral) {
this.minLat = boundingBoxLiteral.minLat;
this.maxLat = boundingBoxLiteral.maxLat;
@@ -55,6 +65,12 @@ export const getALPRs = async (boundingBox: BoundingBox) => {
return response.data;
}
export const getClusters = async () => {
const s3Url = "https://deflock-clusters.s3.us-east-1.amazonaws.com/alpr_clusters.json";
const response = await apiService.get(s3Url);
return response.data;
}
export const geocodeQuery = async (query: string, currentLocation: any) => {
const encodedQuery = encodeURIComponent(query);
const results = (await apiService.get(`/geocode?query=${encodedQuery}`)).data;