-
Notifications
You must be signed in to change notification settings - Fork 19
feat(#560): edit coordinates for a vertex or feature #606
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
base: main
Are you sure you want to change the base?
Conversation
🦋 Changeset detectedLatest commit: 2bd6a29 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
| mapFeatures?.saveFeature(feature); | ||
| // Refresh selected vertex. | ||
| const vertexIndex = feature.get(SELECTED_VERTEX_INDEX_PROPERTY) as number | undefined; | ||
| events.onVertexSelect(getVertexByIndex(feature, vertexIndex)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This refresh updates the status bar and the advanced panel after a vertex is deleted or updated.
|
Testing finished and recorded evidence |
…vertex # Conflicts: # packages/web-forms/tests/components/common/map/createFeatureCollectionAndProps.test.ts
| const geojson = JSON.parse(text) as FeatureCollection<LineString | Point | Polygon>; | ||
| return geojson?.features?.[0]?.geometry as Geometry | undefined; | ||
| } catch { | ||
| // eslint-disable-next-line no-console -- Skip silently to match createFeatureCollectionAndProps |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The audience is developers, and it is not intended to be tracked in alert systems like Sentry (bc user error, no system error)
| SINGLE_FEATURE_TYPES.TRACE, | ||
| ] as const; | ||
|
|
||
| export interface ModeCapabilities { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There are many question types that use maps. This file provides modes for those question types, and each mode has capabilities.
For edit coordinates, this PR adds 2 new capabilities, can update feature coordinates, and can update vertex coordinates
| if (Number.isFinite(latitude) && Number.isFinite(longitude)) { | ||
| coords.push(latitude, longitude); | ||
|
|
||
| if (Number.isFinite(accuracy)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tried extracting this since it's similar (not the same) as the one in geojson-parsers.ts. But decided to leave it like this because
- It's too small and offers little benefit, and don't want to overmodularize
- This one is used within the OpenLayers scope, while the other is for GeoJSON cases, which cannot be mixed (to prevent accidental inclusion of OL in the main bundle).
| } | ||
| </style> | ||
|
|
||
| <style lang="scss"> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We have a separate task to make the css and html of dialogs more reusable.
| if (location.altitude != null) { | ||
| coords.push(location.altitude); | ||
| } | ||
| const coords = toGeoJsonCoordinateArray( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Below is a refactor since we have new utility functions, not related to the main edit coordinates work.
|
|
||
| const extent = source.getExtent(); | ||
| if (!extent?.length) { | ||
| if (isExtendEmpty(extent)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I discovered this function that is a safer check :) tiny enhancement
| } | ||
|
|
||
| geometry?.setCoordinates(coords); | ||
| geometry?.setCoordinates(coords, COORDINATE_LAYOUT_XYZM); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No issue if the layout of 4 numbers (latitude, longitude, altitude, accuracy) is specified or not, but it's helpful for someone reading the code to know what's expected, so adding it here.
| export type Mode = (typeof MODES)[keyof typeof MODES]; | ||
|
|
||
| // Used when loading a single feature from the map. | ||
| export const SINGLE_FEATURE_TYPES = { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's called "single" because we also support maps with a mix of feature types at the same time (select with the map appearance), but for geopoint, geoshape, and geotrace, we only support one type at a time.
|
@sadiqkhoja This is ready for review. I have included some test videos in the PR description and notes. Let me know if you have any questions or if you'd like a walkthrough session. :) |
sadiqkhoja
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Few observations while trying the demo:
- Long press requires quite a long press, is there a way to reduce the time
- Undo button allows only 1 step back, doesn't it create editing stack?
- The +/- button in Longitude and Latitude textbox are not super useful, would be best to remove them.
- If two vertices are exactly same then how can I select one or other? Maybe next/prev button would be helpful
|
Great feedback @sadiqkhoja! Jumping in with a few comments:
We are fixing these two! Users brought this up as well. So we will be removing the long press entirely and allowing the user to undo all actions.
I don't think I know what you mean here. Do you mean the up/down arrow keys?
Yes, this is an interesting point that I think we will address with this story. |
|
Looking great @latin-panda! A few small design notes:
Fixes to address later:
|
sadiqkhoja
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
still reviewing...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Meta-comment: maybe we should configure LFS for these images.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice suggestion! I've created an issue and will bring it to the team
| for (const coord of geometry.split(';')) { | ||
| const [lat, lon] = coord.trim().split(/\s+/).map(Number); | ||
| export const isNullLocation = (lat: number | null | undefined, lon: number | null | undefined) => { | ||
| return lat === 0 && lon === 0; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
0,0 is a valid location, no?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good question! Hopefully null Island isn't common, but it was decided to leave it out to match JR (ref conversation)
|
@sadiqkhoja Thanks for the nice feedback!
This is under development here: #621
This is under review here: #619
I've removed the controls from the input type number. Tested in Chrome, Firefox and Safari. |
|
@alyblenkin Thanks for the feedback!
Sure, fixed, same as Figma
No right now, we don't even have it in the upload image question type. It would be good to implement it together. I've created a ticket.
It's better to avoid adding links, since they can break easily or change paths, and fixing them will require a release in Web Forms and Central. For now, I've added an icon with a native tooltip that shows this information on hover as a quick solution, but this is only available to desktop users (because of hover). We can explore adding one based on tapping so it's also visible to mobile users, as a separate issue. What do you think?
This is fixed |
|
We discussed all these changes earlier, but I forgot to ask if it's difficult to display the name of the file once uploaded, @latin-panda. We could always create a ticket for it if so. I'm assuming it would be helpful to have confirmation you've uploaded the right file. |




Closes #560
I have verified this PR works in these browsers (latest versions):
What else has been done to verify that this works as intended?
Test case: Errors messages in desktop
Test case: Errors messages in mobile
Test case: Full-screen experience
Test case: readonly map
readonly-map.mp4
Test case: geoshape
test-shape.mp4
Test case: geotrace
test-trace.mp4
Regression test: geopoint with "maps" and "placement-map" appearances
geopoint-regression.mp4
Regression test: select with "map" appearance
select-with-map-regression.mp4
Central smoke test
central-smoke-test.mp4
Bundle size verification
No big difference means OL didn't leak, because OL would inflate the main chunk by 400 or 600.
This branch:
In
mainbranch:Why is this the best possible solution? Were any other approaches considered?
This is an extension of the existent solution:
How does this change affect users? Describe intentional changes to behavior and behavior that could have accidentally been affected by code changes. In other words, what are the regression risks?
Do we need any specific form for testing your changes? If so, please attach one.
What's changed
mapHelpers.tsto perform basic validation and return coordinates based on the expected feature type. This is used to return the correct coordinate format after the user pastes a value or uploads a file.createFeatureCollectionAndProps.tsto geojson-parsers.tsgeojson-parsers.ts