feat(platform): add amap reverse geocode for trajectory

This commit is contained in:
lingniu
2026-07-04 21:25:32 +08:00
parent cd932dc097
commit da3a639dd8
8 changed files with 405 additions and 1 deletions

View File

@@ -172,6 +172,31 @@ test('vehicleServiceSummary reads the vehicle service summary endpoint', async (
expect(result.serviceStatuses.find((item) => item.status === 'no_data')?.count).toBe(461);
});
test('reverseGeocode reads the server-side AMap reverse geocode endpoint', async () => {
const fetchMock = vi.spyOn(globalThis, 'fetch').mockResolvedValue({
ok: true,
json: async () => ({
data: {
provider: 'AMap',
longitude: 113.2,
latitude: 23.1,
formattedAddress: '广东省广州市天河区测试路',
province: '广东省',
city: '广州市',
district: '天河区',
adcode: '440106'
},
traceId: 'trace-test',
timestamp: 1783094400000
})
} as Response);
const result = await api.reverseGeocode(new URLSearchParams({ longitude: '113.2', latitude: '23.1' }));
expect(fetchMock).toHaveBeenCalledWith('/api/map/reverse-geocode?longitude=113.2&latitude=23.1', undefined);
expect(result.formattedAddress).toBe('广东省广州市天河区测试路');
});
test('qualityNotificationPlan reads alert rules and priority issues from backend', async () => {
const fetchMock = vi.spyOn(globalThis, 'fetch').mockResolvedValue({
ok: true,

View File

@@ -4,6 +4,7 @@ import type {
DashboardSummary,
HistoryLocationRow,
MileageSummary,
MapReverseGeocode,
OnlineStatisticsSummary,
OnlineVehicleStatusRow,
OpsHealth,
@@ -115,5 +116,6 @@ export const api = {
alertEventSummary: (params = new URLSearchParams()) => request<QualitySummary>(`/api/alert-events/summary?${params.toString()}`),
alertEvents: (params = new URLSearchParams()) => request<Page<QualityIssueRow>>(`/api/alert-events?${params.toString()}`),
alertEventNotificationPlan: (params = new URLSearchParams()) => request<QualityNotificationPlan>(`/api/alert-events/notification-plan?${params.toString()}`),
reverseGeocode: (params = new URLSearchParams()) => request<MapReverseGeocode>(`/api/map/reverse-geocode?${params.toString()}`),
opsHealth: () => request<OpsHealth>('/api/ops/health')
};

View File

@@ -382,6 +382,18 @@ export interface RuntimeInfo {
platformRelease?: string;
}
export interface MapReverseGeocode {
provider: string;
longitude: number;
latitude: number;
formattedAddress: string;
province?: string;
city?: string;
district?: string;
township?: string;
adcode?: string;
}
export interface Page<T> {
items: T[];
total: number;