Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/josm #178

Merged
merged 5 commits into from
Oct 26, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -109,13 +109,17 @@ const TrainingsList = (props) => {
},
{
field: "timeSpan",
headerName: "Time (hrs)",
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);
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)`;
}
},
},
{
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/components/Layout/Feedback/Feedback.js
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ const Feedback = (props) => {

function getFeatureStyle(feature) {
return {
color: "green",
color: "blue",
weight: 3,
};
}
Expand Down
26 changes: 21 additions & 5 deletions frontend/src/components/Layout/Start/Prediction/EditableGeoJSON.js
Original file line number Diff line number Diff line change
Expand Up @@ -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";
}

Expand Down Expand Up @@ -129,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);
Expand Down Expand Up @@ -240,8 +244,9 @@ const EditableGeoJSON = ({
This feedback will be presented on the model (id: ${modelId}, training id: ${trainingId}) for improvements
</p>
<span>Comments:<span/><input type="text" id="comments" name="comments" />
<br>
<button id="rightButton" class="feedback-button" type="submit">&#128077; Submit</button>
<br/>
<button id="rightButton" class="feedback-button" type="submit">Submit feedback</button>
<button id="josmButton" class="feedback-button" type="submit">&#128077; Accept</button>
</div>
`;
const popup = L.popup()
Expand All @@ -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);
setRender(Math.random());
popup.close();
});
}
});
};
Expand Down
21 changes: 13 additions & 8 deletions frontend/src/components/Layout/Start/Prediction/Prediction.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -694,7 +694,7 @@ const DatasetMap = (props) => {
onDrawStop={_onEditStop}
draw={{
polyline: false,
polygon: true,
polygon: false,
rectangle: true,
circle: false,
circlemarker: false,
Expand Down
4 changes: 2 additions & 2 deletions frontend/src/index.css
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ code {


.feedback-button {
background-color: #4caf50;
background-color: #f44336;
margin-top: 2px;
color: #fff;
border: none;
Expand All @@ -92,7 +92,7 @@ code {
}

.feedback-button:last-child {
background-color: #f44336;
background-color: #4caf50;
margin-left:2px;
}

Expand Down
Loading