diff --git a/data/ventilation_index_zones.geojson.xz b/data/ventilation_index_zones.geojson.xz new file mode 100644 index 0000000..584dd28 Binary files /dev/null and b/data/ventilation_index_zones.geojson.xz differ diff --git a/utils/zones.py b/utils/zones.py index 297321c..7d50e88 100644 --- a/utils/zones.py +++ b/utils/zones.py @@ -1,11 +1,33 @@ +import lzma + from geopandas import read_file, GeoDataFrame +COMPRESSED_FILEPATH = "./data/ventilation_index_zones.geojson.xz" +DECOMPRESSED_FILEPATH = "./tmp/ventilation_index_zones.geojson" + + +def _compress_ventilation_index_zones(): + # Git has a filesize limit of 50MB. The shapefile is 60MB, so it should be + # compressed at rest. + with open(DECOMPRESSED_FILEPATH, "rb") as f_in: + bytes = f_in.read() + with lzma.open(COMPRESSED_FILEPATH, "w") as f_out: + f_out.write(bytes) + + +def _decompress_ventilation_index_zones(): + with lzma.open(COMPRESSED_FILEPATH, "r") as f_in: + bytes = f_in.read() + with open(DECOMPRESSED_FILEPATH, "wb") as f_out: + f_out.write(bytes) + -def get_ventilation_index_zones() -> GeoDataFrame: - ventilation_index_zones: GeoDataFrame = read_file("./data/ventilation_index_zones.geojson") +def read_ventilation_index_zones() -> GeoDataFrame: + _decompress_ventilation_index_zones() + ventilation_index_zones = read_file(DECOMPRESSED_FILEPATH) print(f"loaded {ventilation_index_zones.shape[0]} ventilation index zones.") return ventilation_index_zones if __name__ == "__main__": - get_ventilation_index_zones() + read_ventilation_index_zones()