mirror of
https://git.ianrenton.com/ian/spothole.git
synced 2026-09-20 22:37:44 +00:00
39 lines
1.1 KiB
Python
39 lines
1.1 KiB
Python
import json
|
|
import logging
|
|
|
|
import geopandas
|
|
from shapely import prepare
|
|
|
|
from core.data_store import DATA_STORE
|
|
from providers.staticdata.local_file_static_data_provider import (
|
|
LocalFileStaticDataProvider,
|
|
)
|
|
|
|
|
|
class ITUZoneData(LocalFileStaticDataProvider):
|
|
"""Static data provider for ITU zone geodata."""
|
|
|
|
PATH = "datafiles/ituzones.geojson"
|
|
|
|
def __init__(self, provider_config):
|
|
super().__init__("ITU Zone Data", provider_config, self.PATH)
|
|
|
|
def _load_data(self, path):
|
|
try:
|
|
with open(path) as f:
|
|
itu_zone_data = geopandas.GeoDataFrame.from_features(json.load(f)["features"])
|
|
for idx in itu_zone_data.index:
|
|
prepare(itu_zone_data.at[idx, "geometry"])
|
|
|
|
# Bail out if a stop has been requested, i.e. the program is shutting down - no need to prepare the rest
|
|
# of the data in this case
|
|
if self.stop:
|
|
break
|
|
|
|
DATA_STORE.itu_zone_data = itu_zone_data
|
|
return True
|
|
|
|
except Exception:
|
|
logging.exception("Exception when loading ITU zone data.")
|
|
return False
|