From b2c3a5c233fd4c773fc41c29a99d0d6a6775079b Mon Sep 17 00:00:00 2001 From: Omran NAJJAR Date: Thu, 5 Oct 2023 14:37:29 +0200 Subject: [PATCH 1/5] selectign multiple features to push to JOSM --- .../components/Layout/Feedback/Feedback.js | 2 +- .../Start/Prediction/EditableGeoJSON.js | 24 +++++++++++++++---- .../Layout/Start/Prediction/Prediction.js | 21 +++++++++------- frontend/src/index.css | 4 ++-- 4 files changed, 36 insertions(+), 15 deletions(-) diff --git a/frontend/src/components/Layout/Feedback/Feedback.js b/frontend/src/components/Layout/Feedback/Feedback.js index cfa19794..14c852b2 100644 --- a/frontend/src/components/Layout/Feedback/Feedback.js +++ b/frontend/src/components/Layout/Feedback/Feedback.js @@ -176,7 +176,7 @@ const Feedback = (props) => { function getFeatureStyle(feature) { return { - color: "green", + color: "blue", weight: 3, }; } diff --git a/frontend/src/components/Layout/Start/Prediction/EditableGeoJSON.js b/frontend/src/components/Layout/Start/Prediction/EditableGeoJSON.js index 805403bc..08733337 100644 --- a/frontend/src/components/Layout/Start/Prediction/EditableGeoJSON.js +++ b/frontend/src/components/Layout/Start/Prediction/EditableGeoJSON.js @@ -66,8 +66,12 @@ function tile2boundingbox(xtile, ytile, zoom) { // } function getFeatureStyle(feature) { - let color = "red"; - if (feature.properties.action !== "INITIAL") { + let color = ""; + if (feature.properties.action === "ACCEPT") { + color = "blue"; + } else if (feature.properties.action === "INITIAL") { + color = "red"; + } else if (feature.properties.action === "JOSM") { color = "green"; } @@ -240,8 +244,9 @@ const EditableGeoJSON = ({ This feedback will be presented on the model (id: ${modelId}, training id: ${trainingId}) for improvements

Comments: -
- +
+ + `; const popup = L.popup() @@ -258,6 +263,17 @@ const EditableGeoJSON = ({ mutateSubmitFeedback(layer); popup.close(); }); + + popupElement + .querySelector("#josmButton") + .addEventListener("click", () => { + feature.properties.action = "JOSM"; + // console.log("popup layer ", layer); + // handle submitting feedback + // mutateSubmitFeedback(layer); + + popup.close(); + }); } }); }; diff --git a/frontend/src/components/Layout/Start/Prediction/Prediction.js b/frontend/src/components/Layout/Start/Prediction/Prediction.js index 1d8f8074..ce7f068c 100644 --- a/frontend/src/components/Layout/Start/Prediction/Prediction.js +++ b/frontend/src/components/Layout/Start/Prediction/Prediction.js @@ -328,22 +328,27 @@ const Prediction = () => { async function openWithJosm() { setJosmLoading(true); + setError(""); if (!predictions) { setError("No predictions available"); return; } + console.log("predictions for JOSM", predictions); // Remove the "id", action , duplicate and intersect propertiesproperties from each feature in the "features" array const postprocessed_predictions = { ...predictions, - features: predictions.features.map((feature) => { - const { id, action, duplicate, intersect, ...newProps } = - feature.properties; - return { - ...feature, - properties: newProps, - }; - }), + features: predictions.features + .filter((f) => f.properties.action === "JOSM") + .map((feature) => { + const { id, action, duplicate, intersect, ...newProps } = + feature.properties; + // if (action === "JOSM") + return { + ...feature, + properties: newProps, + }; + }), }; try { diff --git a/frontend/src/index.css b/frontend/src/index.css index 20c2a1bc..fba2efac 100644 --- a/frontend/src/index.css +++ b/frontend/src/index.css @@ -79,7 +79,7 @@ code { .feedback-button { - background-color: #4caf50; + background-color: #f44336; margin-top: 2px; color: #fff; border: none; @@ -92,7 +92,7 @@ code { } .feedback-button:last-child { - background-color: #f44336; + background-color: #4caf50; margin-left:2px; } From 4e6e2a2acd2409a8b5bb99b92c0d0b225813e591 Mon Sep 17 00:00:00 2001 From: Omran NAJJAR Date: Thu, 5 Oct 2023 14:42:08 +0200 Subject: [PATCH 2/5] model training in minutes --- .../src/components/Layout/AIModels/AIModelEditor/Trainings.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/frontend/src/components/Layout/AIModels/AIModelEditor/Trainings.js b/frontend/src/components/Layout/AIModels/AIModelEditor/Trainings.js index 3ddb602e..9617695d 100644 --- a/frontend/src/components/Layout/AIModels/AIModelEditor/Trainings.js +++ b/frontend/src/components/Layout/AIModels/AIModelEditor/Trainings.js @@ -109,13 +109,13 @@ const TrainingsList = (props) => { }, { field: "timeSpan", - headerName: "Time (hrs)", + headerName: "Time (mins)", minWidth: 40, flex: 1, valueGetter: (params) => { // console.log("params",params) if (params.row.status === "FINISHED") - return timeSpan(params.row.started_at, params.row.finished_at); + return timeSpan(params.row.started_at, params.row.finished_at) * 60; }, }, { From 59627a665bdbd5e2516d421055bd8eb8181fc4aa Mon Sep 17 00:00:00 2001 From: Omran NAJJAR Date: Thu, 5 Oct 2023 14:53:59 +0200 Subject: [PATCH 3/5] support hours and minutes --- .../Layout/AIModels/AIModelEditor/Trainings.js | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/frontend/src/components/Layout/AIModels/AIModelEditor/Trainings.js b/frontend/src/components/Layout/AIModels/AIModelEditor/Trainings.js index 9617695d..5b3a4cf7 100644 --- a/frontend/src/components/Layout/AIModels/AIModelEditor/Trainings.js +++ b/frontend/src/components/Layout/AIModels/AIModelEditor/Trainings.js @@ -109,13 +109,17 @@ const TrainingsList = (props) => { }, { field: "timeSpan", - headerName: "Time (mins)", + headerName: "Time", minWidth: 40, flex: 1, valueGetter: (params) => { // console.log("params",params) - if (params.row.status === "FINISHED") - return timeSpan(params.row.started_at, params.row.finished_at) * 60; + if (params.row.status === "FINISHED") { + const time = + timeSpan(params.row.started_at, params.row.finished_at) * 1; + if (time < 1) return `${(time * 60).toFixed(1)} mins`; + else return `${time.toFixed(1)} hr(s)`; + } }, }, { From c2cc77ea758062cac4c026703821a3ccb66d5e20 Mon Sep 17 00:00:00 2001 From: Omran NAJJAR Date: Mon, 9 Oct 2023 10:46:14 +0200 Subject: [PATCH 4/5] re render after accepotign a feature --- .../src/components/Layout/Start/Prediction/EditableGeoJSON.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/frontend/src/components/Layout/Start/Prediction/EditableGeoJSON.js b/frontend/src/components/Layout/Start/Prediction/EditableGeoJSON.js index 08733337..358a807c 100644 --- a/frontend/src/components/Layout/Start/Prediction/EditableGeoJSON.js +++ b/frontend/src/components/Layout/Start/Prediction/EditableGeoJSON.js @@ -133,7 +133,7 @@ const EditableGeoJSON = ({ mapref.removeLayer(createdLayer); }; const { accessToken } = useContext(AuthContext); - + const [render, setRender] = useState(Math.random()); const submitFeedback = async (layer) => { try { // console.log("layer", layer); @@ -271,7 +271,7 @@ const EditableGeoJSON = ({ // console.log("popup layer ", layer); // handle submitting feedback // mutateSubmitFeedback(layer); - + setRender(Math.random()); popup.close(); }); } From 35e654f6d1867fe7759d8ce7eb05742ad0be1d1a Mon Sep 17 00:00:00 2001 From: Omran NAJJAR Date: Thu, 26 Oct 2023 13:21:21 +0200 Subject: [PATCH 5/5] reactangle only --- .../components/Layout/TrainingDS/DatasetEditor/DatasetMap.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frontend/src/components/Layout/TrainingDS/DatasetEditor/DatasetMap.js b/frontend/src/components/Layout/TrainingDS/DatasetEditor/DatasetMap.js index 19804fde..59cbe4a5 100644 --- a/frontend/src/components/Layout/TrainingDS/DatasetEditor/DatasetMap.js +++ b/frontend/src/components/Layout/TrainingDS/DatasetEditor/DatasetMap.js @@ -694,7 +694,7 @@ const DatasetMap = (props) => { onDrawStop={_onEditStop} draw={{ polyline: false, - polygon: true, + polygon: false, rectangle: true, circle: false, circlemarker: false,