/
geo.types.ts
63 lines (52 loc) · 1.53 KB
/
geo.types.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
import { GeometryCollection, MultiPolygon, Polygon, Topology } from 'topojson-specification';
import { TerritoryLevel } from './queries/geo.query';
interface RawCity {
name: string;
lat: number;
lng: number;
population: number;
}
interface RawCountry {
name: string;
cities: Record<string, RawCity>;
geometry: Polygon | MultiPolygon | null;
}
interface RawSubcontinent {
name: string;
countries: Record<string, RawCountry>;
}
interface RawContinent {
name: string;
subcontinents: Record<string, RawSubcontinent>;
}
export interface RawWorld {
continents: Record<string, RawContinent>;
topology: Topology<{ land: GeometryCollection }>;
}
export interface City extends RawCity {
countryId: string;
subcontinentId: string;
continentId: string;
}
export interface Country extends RawCountry {
subcontinentId: string;
continentId: string;
cities: Record<string, City>;
}
export interface Subcontinent extends RawSubcontinent {
continentId: string;
countries: Record<string, Country>;
geometry: MultiPolygon | null;
}
export interface Continent extends RawContinent {
subcontinents: Record<string, Subcontinent>;
geometry: MultiPolygon | null;
}
export type TerritoryObject = Continent | Subcontinent | Country | City;
export interface World {
[TerritoryLevel.CONTINENT]: Record<string, Continent>;
[TerritoryLevel.SUBCONTINENT]: Record<string, Subcontinent>;
[TerritoryLevel.COUNTRY]: Record<string, Country>;
[TerritoryLevel.CITY]: Record<string, City>;
topology: Topology<{ land: GeometryCollection }>;
}