6
6
from geojson import Feature , FeatureCollection , Point
7
7
8
8
9
- def get_incidents ( ) -> FeatureCollection :
9
+ def get_data ( t ) -> FeatureCollection :
10
10
"""
11
- Get active incidents data from InciWeb.
11
+ Get all incidents data from InciWeb.
12
+
13
+ Passes in 't' parameter used to specify type of data (Wildfire, Prescribed Fire)
14
+ Incident Types
12
15
13
16
Returns GeoJson FeatureCollection.
14
17
"""
@@ -28,19 +31,43 @@ def get_incidents() -> FeatureCollection:
28
31
# Loop through all the placemarks
29
32
feature_list = []
30
33
for d in data :
31
- # Reformat as GeoJSON
32
- x = convert_coords (d ["long_deg" ], d ["long_min" ], d ["long_sec" ])
33
- y = convert_coords (d ["lat_deg" ], d ["lat_min" ], d ["lat_sec" ])
34
- if x > 0 :
35
- x = - x
36
- p = Point ((x , y ))
37
- f = Feature (geometry = p , properties = d )
34
+ # Only type specified
35
+ if d ['type' ] == t :
36
+ # Reformat as GeoJSON
37
+ x = convert_coords (d ["long_deg" ], d ["long_min" ], d ["long_sec" ])
38
+ y = convert_coords (d ["lat_deg" ], d ["lat_min" ], d ["lat_sec" ])
39
+ if x > 0 :
40
+ x = - x
41
+ p = Point ((x , y ))
42
+ f = Feature (geometry = p , properties = d )
43
+ # Add it to the list
44
+ feature_list .append (f )
45
+ else :
46
+ continue
47
+ # Pass it out
48
+ return FeatureCollection (feature_list )
49
+
38
50
39
- # Add it to the list
40
- feature_list .append (f )
51
+ def get_incidents () -> FeatureCollection :
52
+ """
53
+ Get all active wildfire incidents from InciWeb.
54
+ Returns GeoJson FeatureCollection.
55
+ """
56
+ features = get_data ("Wildfire" )
41
57
42
58
# Pass it out
43
- return FeatureCollection (feature_list )
59
+ return features
60
+
61
+
62
+ def get_prescribed_fires () -> FeatureCollection :
63
+ """
64
+ Get all active prescribed fire incidents from InciWeb.
65
+ Returns GeoJson FeatureCollection.
66
+ """
67
+ features = get_data ("Prescribed Fire" )
68
+
69
+ # Pass it out
70
+ return features
44
71
45
72
46
73
def convert_coords (deg : str , min : str , sec : str ) -> float :
0 commit comments