@@ -60,15 +60,15 @@ class PDCDataSource(MontyDataSourceV3):
60
60
uuid : str
61
61
hazard_file_path : str
62
62
exposure_detail_file_path : str
63
- geojson_file_path : str
63
+ geojson_path : str
64
64
hazard_data : Union [str , dict ]
65
65
exposure_detail_data : Union [str , dict ]
66
- geojson_data : Union [str , dict ]
67
66
68
67
def __init__ (self , data : PDCDataSourceType ):
69
68
super ().__init__ (data )
70
69
self .source_url = data .source_url
71
70
self .uuid = data .uuid
71
+ self .geojson_path = data .geojson_path
72
72
73
73
def handle_file_data ():
74
74
if os .path .isfile (data .hazard_data .path ):
@@ -81,11 +81,6 @@ def handle_file_data():
81
81
else :
82
82
raise ValueError ("File path does not exist" )
83
83
84
- if os .path .isfile (data .geojson_data .path ):
85
- self .geojson_file_path = data .geojson_data .path
86
- else :
87
- raise ValueError ("File path does not exist" )
88
-
89
84
def handle_memory_data (): ...
90
85
91
86
input_data_type = data .hazard_data .data_type
@@ -109,12 +104,6 @@ def get_exposure_detail_data(self) -> typing.Union[dict, str]:
109
104
self .exposure_detail_data = json .loads (f .read ())
110
105
return self .exposure_detail_data
111
106
112
- def get_geojson_data (self ) -> typing .Union [dict , str ]:
113
- if self .root .geojson_data .data_type == DataType .FILE :
114
- with open (self .geojson_file_path , "r" , encoding = "utf-8" ) as f :
115
- self .geojson_data = json .loads (f .read ())
116
- return self .geojson_data
117
-
118
107
def get_input_data_type (self ) -> DataType :
119
108
return self .root .hazard_data .data_type
120
109
@@ -136,7 +125,7 @@ def __init__(self, pdc_data_src: PDCDataSource, geocoder: MontyGeoCoder):
136
125
self .uuid = pdc_data_src .uuid
137
126
self .hazards_data = pdc_data_src .get_hazard_data ()
138
127
self .exposure_detail = pdc_data_src .get_exposure_detail_data ()
139
- self .geojson_data = pdc_data_src .get_geojson_data ()
128
+ self .geojson_path = pdc_data_src .geojson_path
140
129
141
130
# NOTE Assigning -1 to episode_number incase of failure just to ignore the item formation (see make_items method)
142
131
@@ -210,7 +199,6 @@ def make_source_event_item(self, pdc_hazard_data: HazardEventValidator, pdc_expo
210
199
"start_datetime" : startdate .isoformat (),
211
200
"end_datetime" : enddate .isoformat (),
212
201
"category_id" : pdc_hazard_data .category_ID ,
213
- "geometry_geojson" : self .geojson_data ,
214
202
},
215
203
)
216
204
@@ -233,6 +221,9 @@ def make_source_event_item(self, pdc_hazard_data: HazardEventValidator, pdc_expo
233
221
if monty .country_codes :
234
222
monty .compute_and_set_correlation_id (hazard_profiles = self .hazard_profiles )
235
223
224
+ if self .geojson_path :
225
+ item .add_asset ("Maps" , Asset (href = self .geojson_path , media_type = "geojson" , title = "Polygon" ))
226
+
236
227
if pdc_hazard_data .snc_url :
237
228
item .add_asset ("report" , Asset (href = pdc_hazard_data .snc_url , media_type = "html" , title = "Report" ))
238
229
return item
0 commit comments