Skip to content

Commit

Permalink
black formatted
Browse files Browse the repository at this point in the history
  • Loading branch information
dieuska committed Sep 10, 2024
1 parent b1a575b commit 5f77126
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 19 deletions.
7 changes: 5 additions & 2 deletions brdr/geometry_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -610,6 +610,7 @@ def get_bbox(geometry):
"""
return str(geometry.bounds).strip("()")


def geojson_polygon_to_multipolygon(geojson):
"""
Transforms a geojson: Checks if there are Polygon-features and transforms them into MultiPolygons, so all objects are of type 'MultiPolygon' (or null-geometry).
Expand All @@ -621,6 +622,8 @@ def geojson_polygon_to_multipolygon(geojson):
if f["geometry"] is None:
continue
if f["geometry"]["type"] == "Polygon":
f["geometry"] = {"type": "MultiPolygon",
"coordinates": [f["geometry"]["coordinates"]]}
f["geometry"] = {
"type": "MultiPolygon",
"coordinates": [f["geometry"]["coordinates"]],
}
return geojson
30 changes: 14 additions & 16 deletions brdr/grb.py
Original file line number Diff line number Diff line change
Expand Up @@ -265,6 +265,7 @@ def get_collection_grb_fiscal_parcels(
url, geometry=geometry, partition=partition, limit=limit, crs=crs
)


def evaluate(
actual_aligner,
dict_series,
Expand Down Expand Up @@ -329,16 +330,14 @@ def evaluate(
)
prop_dictionary[0][theme_id]["evaluation"] = Evaluation.NO_PREDICTION_5
continue
#Add all predicted features so they can be manually checked
for dist in dict_predicted_keys[theme_id].keys():
# Add all predicted features so they can be manually checked
for dist in dict_predicted_keys[theme_id].keys():
predicted_resultset = dict_predicted[dist][theme_id]
dict_evaluated_result[dist][theme_id] = predicted_resultset
prop_dictionary[dist][theme_id]["formula"] = json.dumps(
actual_aligner.get_formula(predicted_resultset["result"])
)
prop_dictionary[dist][theme_id][
"evaluation"
] = Evaluation.TO_CHECK_4
prop_dictionary[dist][theme_id]["evaluation"] = Evaluation.TO_CHECK_4

for theme_id, geom in dict_unchanged.items():
result = {"result": geom}
Expand All @@ -349,6 +348,7 @@ def evaluate(
)
return dict_evaluated_result, prop_dictionary


def check_equality(
base_formula, actual_formula, threshold_area=5, threshold_percentage=1
):
Expand All @@ -373,21 +373,19 @@ def check_equality(
elif base_formula["reference_od"] is None or actual_formula["reference_od"] is None:
od_alike = False
elif (
(
abs(
base_formula["reference_od"]["area"]
- actual_formula["reference_od"]["area"]
)
* 100
/ base_formula["reference_od"]["area"]
)
< threshold_percentage
):
abs(
base_formula["reference_od"]["area"]
- actual_formula["reference_od"]["area"]
)
* 100
/ base_formula["reference_od"]["area"]
) < threshold_percentage:
od_alike = True

if (
base_formula["reference_features"].keys()
== actual_formula["reference_features"].keys() and od_alike
== actual_formula["reference_features"].keys()
and od_alike
):
if base_formula["full"] and base_formula["full"]:
return True, Evaluation.EQUALITY_FORMULA_GEOM_1
Expand Down
1 change: 0 additions & 1 deletion examples/example_evaluate.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
from brdr.utils import get_series_geojson_dict



def fid_to_geojson(geojson):
fid = 1
for f in geojson["features"]:
Expand Down

0 comments on commit 5f77126

Please sign in to comment.