20 lines
685 B
TypeScript
20 lines
685 B
TypeScript
import { type IGeoDataProvider } from '@/application/ports/output/IGeoDataProvider';
|
|
|
|
export class GeoJsonProvider implements IGeoDataProvider {
|
|
async getProvinceGeoJSON(): Promise<any> {
|
|
const response = await fetch('/assets/geo/china.json');
|
|
if (!response.ok) {
|
|
throw new Error(`Failed to load province GeoJSON: ${response.statusText}`);
|
|
}
|
|
return response.json();
|
|
}
|
|
|
|
async getCityGeoJSON(province: string): Promise<any> {
|
|
const response = await fetch(`/assets/geo/province/${province}.json`);
|
|
if (!response.ok) {
|
|
throw new Error(`Failed to load city GeoJSON for ${province}: ${response.statusText}`);
|
|
}
|
|
return response.json();
|
|
}
|
|
}
|