Skip to content

Commit

Permalink
Black code
Browse files Browse the repository at this point in the history
  • Loading branch information
emi420 committed Jan 29, 2025
1 parent 42589bf commit 533caec
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 22 deletions.
18 changes: 13 additions & 5 deletions src/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -1945,12 +1945,20 @@ def add_resource(self, resource_meta):
if resource_meta.get("stats_html"):
dataset_customviz = self.dataset.get("customviz")
if not dataset_customviz:
dataset_customviz = [{"name": resource_meta["name"], "url": resource_meta["stats_html"]}]
dataset_customviz = [
{
"name": resource_meta["name"],
"url": resource_meta["stats_html"],
}
]
else:
dataset_customviz.append({"name": resource_meta["name"], "url": resource_meta["stats_html"]})
self.dataset.update(
{"customviz": dataset_customviz}
)
dataset_customviz.append(
{
"name": resource_meta["name"],
"url": resource_meta["stats_html"],
}
)
self.dataset.update({"customviz": dataset_customviz})

def upload_dataset(self, dump_config_to_s3=False):
"""
Expand Down
1 change: 1 addition & 0 deletions src/post_processing/geojson_stats.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from geojson_stats.stats import Stats
from geojson_stats.html import Html


class GeoJSONStats(Stats):
"""Used for collecting stats while processing GeoJSON files"""

Expand Down
26 changes: 9 additions & 17 deletions src/post_processing/processor.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,23 +5,14 @@
import pathlib

CATEGORIES_CONFIG = {
"roads": {
"tag": "highway", "length": True, "area": False
},
"buildings": {
"tag": "building", "length": False, "area": True
},
"waterways": {
"tag": "waterway", "length": True, "area": False
},
"railways": {
"tag": "railway", "length": True, "area": False
},
"default": {
"tag": None, "length": False, "area": False
},
"roads": {"tag": "highway", "length": True, "area": False},
"buildings": {"tag": "building", "length": False, "area": True},
"waterways": {"tag": "waterway", "length": True, "area": False},
"railways": {"tag": "railway", "length": True, "area": False},
"default": {"tag": None, "length": False, "area": False},
}


class PostProcessor:
"""Used for post-process GeoJSON files"""

Expand Down Expand Up @@ -62,7 +53,6 @@ def custom(
self.geoJSONStats.config.area = category_config["area"]

if self.options["include_stats"]:

path_input = os.path.join(export_format_path, f"{export_filename}.geojson")
path_output = os.path.join(
export_format_path, f"{export_filename}-post.geojson"
Expand Down Expand Up @@ -111,7 +101,9 @@ def custom(
project_root,
"{tpl}_tpl.html".format(tpl=tpl),
)
geojson_stats_html = self.geoJSONStats.html(tpl_path, {"title": f"{export_filename}.geojson"}).build()
geojson_stats_html = self.geoJSONStats.html(
tpl_path, {"title": f"{export_filename}.geojson"}
).build()
upload_html_path = os.path.join(file_export_path, "stats-summary.html")
with open(upload_html_path, "w") as f:
f.write(geojson_stats_html)
Expand Down

0 comments on commit 533caec

Please sign in to comment.