@@ -174,18 +174,25 @@ def get_airspaces(countries=[]):
174174 _airspaces_mtime = {}
175175 _airspaces = []
176176 for file in files :
177- airspace = etree .parse (os .path .join (MSS_CONFIG_PATH , file ))
177+ fpath = os .path .join (MSS_CONFIG_PATH , file )
178+ airspace = etree .parse (fpath )
178179 airspace = airspace .find ("AIRSPACES" )
179180 for elem in airspace :
180- airspace_data = {
181- "name" : elem .find ("NAME" ).text ,
182- "polygon" : elem .find ("GEOMETRY" ).find ("POLYGON" ).text ,
183- "top" : float (elem .find ("ALTLIMIT_TOP" ).find ("ALT" ).text ),
184- "top_unit" : elem .find ("ALTLIMIT_TOP" ).find ("ALT" ).get ("UNIT" ),
185- "bottom" : float (elem .find ("ALTLIMIT_BOTTOM" ).find ("ALT" ).text ),
186- "bottom_unit" : elem .find ("ALTLIMIT_BOTTOM" ).find ("ALT" ).get ("UNIT" ),
187- "country" : elem .find ("COUNTRY" ).text
188- }
181+ try :
182+ airspace_data = {
183+ "name" : elem .find ("NAME" ).text ,
184+ "polygon" : elem .find ("GEOMETRY" ).find ("POLYGON" ).text ,
185+ "top" : float (elem .find ("ALTLIMIT_TOP" ).find ("ALT" ).text ),
186+ "top_unit" : elem .find ("ALTLIMIT_TOP" ).find ("ALT" ).get ("UNIT" ),
187+ "bottom" : float (elem .find ("ALTLIMIT_BOTTOM" ).find ("ALT" ).text ),
188+ "bottom_unit" : elem .find ("ALTLIMIT_BOTTOM" ).find ("ALT" ).get ("UNIT" ),
189+ "country" : elem .find ("COUNTRY" ).text
190+ }
191+ except TypeError as ex :
192+ logging .debug ("Problem %s in airspaces file %s" , (ex , fpath ))
193+ logging .info ("A few data of %s is ignored because of an incompatible format." , fpath )
194+ continue
195+
189196 # Convert to kilometers
190197 airspace_data ["top" ] /= 3281 if airspace_data ["top_unit" ] == "F" else 32.81
191198 airspace_data ["bottom" ] /= 3281 if airspace_data ["bottom_unit" ] == "F" else 32.81
0 commit comments