diff --git a/frontend/src/components/Layout/Start/Prediction/EditableGeoJSON.js b/frontend/src/components/Layout/Start/Prediction/EditableGeoJSON.js index 358a807c..bc696287 100644 --- a/frontend/src/components/Layout/Start/Prediction/EditableGeoJSON.js +++ b/frontend/src/components/Layout/Start/Prediction/EditableGeoJSON.js @@ -96,6 +96,7 @@ const EditableGeoJSON = ({ trainingId, sourceImagery, refestchFeeedback, + onAcceptFeature, }) => { const onPMCreate = (event) => { console.log("Created"); @@ -258,6 +259,7 @@ const EditableGeoJSON = ({ .querySelector("#rightButton") .addEventListener("click", () => { feature.properties.action = "ACCEPT"; + onAcceptFeature(feature); console.log("popup layer ", layer); // handle submitting feedback mutateSubmitFeedback(layer); diff --git a/frontend/src/components/Layout/Start/Prediction/Prediction.js b/frontend/src/components/Layout/Start/Prediction/Prediction.js index 0716def0..9ee65547 100644 --- a/frontend/src/components/Layout/Start/Prediction/Prediction.js +++ b/frontend/src/components/Layout/Start/Prediction/Prediction.js @@ -85,6 +85,7 @@ const Prediction = () => { const [skewTolerance, setSkewTolerance] = useState(15); const [tolerance, setTolerance] = useState(0.3); const [areaThreshold, setAreaThreshold] = useState(4); + const [acceptedFeatures, setAcceptedFeatures] = useState([]); const fetchData = async () => { setLoading(true); try { @@ -235,6 +236,23 @@ const Prediction = () => { URL.revokeObjectURL(url); }; + const downloadAcceptedFeatures = () => { + if (acceptedFeatures.length === 0) { + return; + } + + const content = JSON.stringify(acceptedFeatures); + const blob = new Blob([content], { type: "application/json" }); + const url = URL.createObjectURL(blob); + + const link = document.createElement("a"); + link.href = url; + link.download = "accepted_predictions.geojson"; + link.click(); + + URL.revokeObjectURL(url); + }; + const { mutate: callPredict, data: returnedpredictions, @@ -297,6 +315,10 @@ const Prediction = () => { return updatedPredictions; }); + const handleAcceptFeature = (feature) => { + setAcceptedFeatures((prev) => [...prev, feature]); + }; + const handleSubmitFeedback = async () => { setFeedbackLoading(true); console.log(predictions.features.length); @@ -565,6 +587,7 @@ const Prediction = () => { refestchFeeedback={() => { refetchFeedback(); }} + onAcceptFeature={handleAcceptFeature} /> )} @@ -813,8 +836,20 @@ const Prediction = () => { size="small" sx={{ mt: 1 }} > - Download as Geojson + Download All Features as Geojson + + {acceptedFeatures.length > 0 && ( + + Download Accepted Features as Geojson + + )} )}