feat: add vehicle and hydrogen heatmaps
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
This commit is contained in:
34
src/modules/vehicle-heatmap/api.ts
Normal file
34
src/modules/vehicle-heatmap/api.ts
Normal file
@@ -0,0 +1,34 @@
|
||||
import { fetchJson } from '../../auth/api-client';
|
||||
import type { AmapConfig, HeatmapMeta, HeatmapMetric, HeatmapResponse, NearbyResponse } from './types';
|
||||
|
||||
export function fetchAmapConfig(signal?: AbortSignal) {
|
||||
return fetchJson<AmapConfig>('/api/vehicle-heatmap/config', { signal });
|
||||
}
|
||||
|
||||
export function fetchHeatmapMeta(signal?: AbortSignal) {
|
||||
return fetchJson<HeatmapMeta>('/api/vehicle-heatmap/meta', { signal });
|
||||
}
|
||||
|
||||
export function fetchHeatmapPoints(
|
||||
params: { startDate: string; endDate: string; query: string; batchModel: string; metric: HeatmapMetric },
|
||||
signal?: AbortSignal,
|
||||
) {
|
||||
const search = new URLSearchParams(params);
|
||||
return fetchJson<HeatmapResponse>(`/api/vehicle-heatmap/points?${search}`, { signal });
|
||||
}
|
||||
|
||||
export function fetchNearbyVehicles(
|
||||
params: { lng: number; lat: number; startDate: string; endDate: string; query: string; batchModel: string },
|
||||
signal?: AbortSignal,
|
||||
) {
|
||||
const search = new URLSearchParams({
|
||||
lng: String(params.lng),
|
||||
lat: String(params.lat),
|
||||
startDate: params.startDate,
|
||||
endDate: params.endDate,
|
||||
query: params.query,
|
||||
batchModel: params.batchModel,
|
||||
radiusKm: '50',
|
||||
});
|
||||
return fetchJson<NearbyResponse>(`/api/vehicle-heatmap/nearby?${search}`, { signal });
|
||||
}
|
||||
Reference in New Issue
Block a user