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

GSLUX-705: Modify feature geometry #151

Merged
merged 15 commits into from
Sep 27, 2024
Merged

GSLUX-705: Modify feature geometry #151

merged 15 commits into from
Sep 27, 2024

Conversation

tkohr
Copy link
Contributor

@tkohr tkohr commented Sep 11, 2024

JIRA issue

https://jira.camptocamp.com/browse/GSLUX-705

Description

PR to handle modification of feature geometries.

Copy link
Contributor

GitHub Pages links: * Luxembourg-geoportail: https://geoportail-luxembourg.github.io/luxembourg-geoportail/GSLUX-705-modify-feature/

@tkohr tkohr marked this pull request as ready for review September 26, 2024 15:26
Copy link
Contributor

@mki-c2c mki-c2c left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks,

I appreciate a lot the refactoring with moving the draw parts from ol.composable into draw.coposable
But then I am not sre what ol.composable really is. It is rather ol.layer.composable whereas draw.composable would be ol.draw.composable ??

I have a remark on the use of editPoint vs. drawPoint, which might be a bit confusing.

Furthermore I have observed one (minor) bug, but this would not prevent merging in my point of view:

  • if edit mode is active and a feature is deleted, it is only hidden from the map when another item is selectec
  • if the feature is not in edit mode and is deleted, it disappears at once.

if (drawStateActive.value === newState) {
function toggleDrawActiveState(newState: DrawStateActive) {
// allow draw of different geom type after edit, but not same type
if (editStateActive.value?.slice(4) === newState?.slice(4)) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I find this use of string type enums a bit risky.

What if a refactoring changed 'draw' into 'paint' and 'draw' and 'edit' do not have both a 4 Letter prefix.
At firest I thought, the 4 letter offset was shared between draw and edit

I would suggest 2 levels of fix:

  • basic fix: replace slice by editStateActive.value?.replace('edit', '') and newState?.replace('draw', '') => this might be a bit more readable
  • sophisticated fix: create a class with 2 arguments: feature type (point, label, circle, etc.) and feature context (draw, edit, select)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @mki-c2c, I really like your first idea. I just stumbled on a switch case where an object would have caused a long if else chain, so I stuck with your basic fix for now.

:active="drawStateActive === 'drawPoint'"
@click="() => toggleActiveState('drawPoint')"
:active="
drawStateActive === 'drawPoint' || editStateActive === 'editPoint'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe this can be simplified if the feature state has 2 parts, so we only have to check one type

  • feature type
  • feature context (draw, edit, etc.)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indeed, here an object would be more elegant.

this prevents once edited feature geometries to stay editable when another feature geometry should only be editable
@tkohr tkohr force-pushed the GSLUX-705-modify-feature branch from f82feaf to 39a3bfe Compare September 27, 2024 14:07
@tkohr
Copy link
Contributor Author

tkohr commented Sep 27, 2024

Thanks for the review @mki-c2c ! Originally I thought it was a good idea to move all the ol draw and modify stuff to the ol composable, but I had the impression that it made the code much more verbose (just to get the right layer for example) since these functionalities are so closely tight with openlayers due to the interactions. This is why I finally decided to concentrate everything in the draw and edit.composable. Hope this makes sense.

@tkohr tkohr merged commit 5138c33 into main Sep 27, 2024
2 checks passed
@tkohr tkohr deleted the GSLUX-705-modify-feature branch September 27, 2024 16:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants