diff --git a/backend/core/serializers.py b/backend/core/serializers.py index a1e6fa43..10529599 100644 --- a/backend/core/serializers.py +++ b/backend/core/serializers.py @@ -221,6 +221,7 @@ class PredictionParamSerializer(serializers.Serializer): model_id = serializers.IntegerField(required=True) zoom_level = serializers.IntegerField(required=True) confidence = serializers.IntegerField(required=False) + use_josm_q = serializers.BooleanField(required=False) source = serializers.URLField(required=False) def validate(self, data): diff --git a/backend/core/utils.py b/backend/core/utils.py index 8612258c..fdc3fe32 100644 --- a/backend/core/utils.py +++ b/backend/core/utils.py @@ -119,7 +119,6 @@ def download_image(url, base_path, source_name): response = requests.get(url) image = response.content url = re.sub(r"\.(png|jpeg)$", "", url) - logging.info(url) url_splitted_list = url.split("/") filename = f"{base_path}/{source_name}-{url_splitted_list[-2]}-{url_splitted_list[-1]}-{url_splitted_list[-3]}.png" diff --git a/backend/core/views.py b/backend/core/views.py index eb99d80a..0fcf56d6 100644 --- a/backend/core/views.py +++ b/backend/core/views.py @@ -30,6 +30,7 @@ from hot_fair_utilities import polygonize, predict, vectorize from login.authentication import OsmAuthentication from login.permissions import IsOsmAuthenticated +from orthogonalizer import othogonalize_poly from osmconflator import conflate_geojson from rest_framework import decorators, serializers, status, viewsets from rest_framework.decorators import api_view @@ -374,7 +375,7 @@ def ConflateGeojson(request): conflated_geojson = conflate_geojson(geojson_data, remove_conflated=True) - return Response(conflated_geojson,status = 200) + return Response(conflated_geojson, status=200) @api_view(["GET"]) @@ -501,6 +502,7 @@ def post(self, request, *args, **kwargs): if res_serializer.is_valid(raise_exception=True): deserialized_data = res_serializer.data bbox = deserialized_data["bbox"] + use_josm_q = deserialized_data["use_josm_q"] model_instance = get_object_or_404(Model, id=deserialized_data["model_id"]) if not model_instance.published_training: return Response("Model is not published yet", status=404) @@ -589,6 +591,8 @@ def post(self, request, *args, **kwargs): for feature in geojson_data["features"]: feature["properties"]["building"] = "yes" feature["properties"]["source"] = "fAIr" + if use_josm_q is True: + feature["geometry"] = othogonalize_poly(feature["geometry"]) shutil.rmtree(temp_path) diff --git a/backend/requirements.txt b/backend/requirements.txt index 54ae9966..d6bc29bb 100644 --- a/backend/requirements.txt +++ b/backend/requirements.txt @@ -19,4 +19,5 @@ validators==0.20.0 gpxpy==1.5.0 hot-fair-utilities geojson2osm==0.0.1 -osmconflator==0.0.6 \ No newline at end of file +osmconflator==0.0.6 +orthogonalizer==0.0.4 \ No newline at end of file diff --git a/frontend/src/components/Layout/Start/Prediction/Prediction.js b/frontend/src/components/Layout/Start/Prediction/Prediction.js index 3270432a..57281074 100644 --- a/frontend/src/components/Layout/Start/Prediction/Prediction.js +++ b/frontend/src/components/Layout/Start/Prediction/Prediction.js @@ -4,6 +4,7 @@ import { Button, Grid, Box, + Switch, CircularProgress, Paper, Typography, @@ -56,6 +57,10 @@ const Prediction = () => { const [apiCallInProgress, setApiCallInProgress] = useState(false); const [confidence, setConfidence] = useState(90); + const [use_josm_q, setUse_josm_q] = useState(true); + const handleUseJosmToggle = () => { + setUse_josm_q(!use_josm_q); + }; const [totalPredictionsCount, settotalPredictionsCount] = useState(0); // const [DeletedCount, setDeletedCount] = useState(0); // const [CreatedCount, setCreatedCount] = useState(0); @@ -210,6 +215,7 @@ const Prediction = () => { zoom_level: zoom, source: dataset.source_imagery, confidence: confidence, + use_josm_q: use_josm_q, }; const startTime = new Date().getTime(); // measure start time const res = await axios.post(`/prediction/`, body, { headers }); @@ -498,6 +504,7 @@ const Prediction = () => { + + + Use JOSM Q: + + + Current Zoom: {JSON.stringify(zoom)}