-
-
Notifications
You must be signed in to change notification settings - Fork 57
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
Distance constraint add on frontend #2084
base: development
Are you sure you want to change the base?
Conversation
β¦ween two points
β¦ance between user and entity
β¦ween two points
β¦ance between user and entity
3d81fa2
to
3c9f4c5
Compare
I updated the logic to be: // Check if drawn geometry is within set distance constraints from user
const isDistanceConstaintValid = (): boolean => {
const coordTo = entitiesStore.selectedEntityCoordinate?.coordinate;
const coordFrom = entitiesStore.userLocationCoord;
// Geolocation not enabled, warn user
if (!coordFrom) {
alertStore.setAlert({
message:
'This project has a distance constraint set. Please enable device geolocation for optimal functionality',
variant: 'warning',
});
return false;
}
const entityDistance = distance(coordFrom as Coord, coordTo as Coord, { units: 'kilometers' }) * 1000;
if (entityDistance && entityDistance > projectData?.geo_restrict_distance_meters) {
// Feature is far away from user, warn user
alertStore.setAlert({
message: `The feature must be within ${projectData?.geo_restrict_distance_meters} meters of your location`,
variant: 'warning',
});
if (projectData?.geo_restrict_force_error) {
// Not valid coord, prevent user from continuing
return false;
}
// Valid coord: it's outside of range, but only 'warn' user
return true;
}
// Valid coord
return true;
}; The goal is to:
Hope this makes sense! Please check it works as intended, then merge π |
I didn't test the logic, so perhaps made a mistake. But you make a good point. Anyway, this should happen:
Does that sound right? |
I'm really hesitant to block the user from mapping if they don't have location on (where I imagine this is what the Tokha team want @manjitapandey ?). This would mean if there is a problem with the users geolocation, like they accidentally blocked access and can't work out how to enable access, they can't use FMTM (not ideal if they have been transported to the field and are now stuck and can't do anything) |
Yes the conditions above sounds right. also In such cases, For Tokha projects, field managers and monitoring team will always be available on call to assist mappers in field. For other project this may not be relevant so only warnings and prompt to enable geolocation should work but this case is different. |
Thanks! Let's block the mapping if geolocation is not enabled then @NSUWAL123 π |
Updated logic to:
|
So sorry to be a pain, but for the third option, do we not still want to show a warning? Not a blocking error, but something like: 'The selected feature is far from your current location. Are you sure?' |
Sure! It makes sense |
What type of PR is this? (check all applicable)
Related Issue
Describe this PR
Validate the distance between user location and entity if the distance constraint is
true
.If the distance constant is set to true, the user must enable their device location & must be within the distance constraint set.
Screenshots
Geolocation must be enabled if the distance constant set
Show a message if the user now within the range