-
Notifications
You must be signed in to change notification settings - Fork 21
/
index.ts
128 lines (113 loc) · 2.75 KB
/
index.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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
export type LaneType =
| 'bidirectionnelle'
| 'bilaterale'
| 'voie-bus'
| 'voie-bus-elargie'
| 'velorue'
| 'voie-verte'
| 'bandes-cyclables'
| 'zone-de-rencontre'
| 'aucun'
| 'inconnu';
export type LaneStatus = 'done' | 'wip' | 'planned' | 'tested' | 'postponed' | 'unknown' | 'variante' | 'variante-postponed';
export type LineStringFeature = {
type: 'Feature';
properties: {
id?: string
line: number;
name: string;
status: LaneStatus;
type: LaneType;
doneAt?: string;
link?: string;
};
geometry: {
type: 'LineString';
coordinates: [number, number][];
};
};
export type PerspectiveFeature = {
type: 'Feature';
properties: {
type: 'perspective';
line: number;
name: string;
imgUrl: string;
};
geometry: {
type: 'Point';
coordinates: [number, number];
};
};
export type CompteurFeature = {
type: 'Feature';
properties: {
type: 'compteur-velo' | 'compteur-voiture';
line?: number;
name: string;
link?: string;
counts: Array<{
month: string;
count: number;
}>;
/**
* z-index like
*/
circleSortKey?: number;
circleRadius?: number;
circleStrokeWidth?: number;
};
geometry: {
type: 'Point';
coordinates: [number, number];
};
};
export type PumpFeature = {
type: 'Feature';
properties: {
type: 'pump',
name: string
}
geometry: {
type: 'Point';
coordinates: [number, number];
};
}
export type DangerFeature = {
type: 'Feature';
properties: {
type: 'danger',
name: string
}
geometry: {
type: 'Point';
coordinates: [number, number];
};
}
type PointFeature = PerspectiveFeature | CompteurFeature | PumpFeature | DangerFeature;
export type Feature = LineStringFeature | PointFeature;
export type Geojson = {
type: string;
features: Feature[];
};
/**
* type helpers
*/
export function isLineStringFeature(feature: Feature): feature is LineStringFeature {
return feature.geometry.type === 'LineString';
}
export function isPointFeature(feature: Feature): feature is PointFeature {
return feature.geometry.type === 'Point';
}
export function isPerspectiveFeature(feature: Feature): feature is PerspectiveFeature {
return isPointFeature(feature) && feature.properties.type === 'perspective';
}
export function isDangerFeature(feature: Feature): feature is PerspectiveFeature {
return isPointFeature(feature) && feature.properties.type === 'danger';
}
export function isPumpFeature(feature: Feature): feature is PumpFeature {
return isPointFeature(feature) && feature.properties.type === 'pump';
}
export function isCompteurFeature(feature: Feature): feature is CompteurFeature {
return isPointFeature(feature) && ['compteur-velo', 'compteur-voiture'].includes(feature.properties.type);
}