@mytec: iter2.2 ready for testing
This commit is contained in:
@@ -147,6 +147,64 @@ class ApiService {
|
||||
const data = await response.json();
|
||||
return data.elevation;
|
||||
}
|
||||
|
||||
// === Region / Caching API ===
|
||||
|
||||
async getRegions(): Promise<RegionInfo[]> {
|
||||
const response = await fetch(`${API_BASE}/api/regions/available`);
|
||||
if (!response.ok) throw new Error('Failed to fetch regions');
|
||||
return response.json();
|
||||
}
|
||||
|
||||
async downloadRegion(regionId: string): Promise<{ task_id: string; status: string }> {
|
||||
const response = await fetch(`${API_BASE}/api/regions/download/${regionId}`, {
|
||||
method: 'POST',
|
||||
});
|
||||
if (!response.ok) throw new Error('Failed to start download');
|
||||
return response.json();
|
||||
}
|
||||
|
||||
async getDownloadProgress(taskId: string): Promise<DownloadProgress> {
|
||||
const response = await fetch(`${API_BASE}/api/regions/download/${taskId}/progress`);
|
||||
if (!response.ok) throw new Error('Failed to get progress');
|
||||
return response.json();
|
||||
}
|
||||
|
||||
async getCacheStats(): Promise<CacheStats> {
|
||||
const response = await fetch(`${API_BASE}/api/regions/cache/stats`);
|
||||
if (!response.ok) throw new Error('Failed to get cache stats');
|
||||
return response.json();
|
||||
}
|
||||
}
|
||||
|
||||
// === Region types ===
|
||||
|
||||
export interface RegionInfo {
|
||||
id: string;
|
||||
name: string;
|
||||
bbox: number[];
|
||||
srtm_tiles: number;
|
||||
estimated_size_gb: number;
|
||||
downloaded: boolean;
|
||||
download_progress: number;
|
||||
}
|
||||
|
||||
export interface DownloadProgress {
|
||||
task_id: string;
|
||||
region_id: string;
|
||||
status: string;
|
||||
progress: number;
|
||||
current_step: string;
|
||||
downloaded_mb: number;
|
||||
error?: string;
|
||||
}
|
||||
|
||||
export interface CacheStats {
|
||||
terrain_mb: number;
|
||||
terrain_tiles: number;
|
||||
buildings_mb: number;
|
||||
water_mb: number;
|
||||
vegetation_mb: number;
|
||||
}
|
||||
|
||||
export const api = new ApiService();
|
||||
|
||||
Reference in New Issue
Block a user