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/add measure tool #124

Open
wants to merge 83 commits into
base: main
Choose a base branch
from
Open

Feature/add measure tool #124

wants to merge 83 commits into from

Conversation

LDWiegand
Copy link
Collaborator

@LDWiegand LDWiegand commented Apr 18, 2024

Summary

Added a measure tool for distances and areas

Instructions for local reproduction and review

npm run snowbox

@LDWiegand LDWiegand added the enhancement New feature or request label Apr 18, 2024
@LDWiegand LDWiegand self-assigned this Apr 18, 2024
@warm-coolguy warm-coolguy self-assigned this Apr 18, 2024
@warm-coolguy warm-coolguy requested a review from dopenguin April 18, 2024 08:32
@warm-coolguy warm-coolguy force-pushed the feature/add-measure-tool branch from 4304b17 to 9197c6c Compare April 26, 2024 09:10
@warm-coolguy warm-coolguy force-pushed the feature/add-measure-tool branch from 9197c6c to 17e61c2 Compare April 26, 2024 09:13
@warm-coolguy warm-coolguy marked this pull request as ready for review April 29, 2024 06:30
By adding these two, it is now possible to measure lengths and areas
and not triggering the pins plugin or the directSelect of gfi.
If one wants to use more complex interactions, they may remove the
measure interactions by selecting "No interaction".
This still leaves room open for draw and measure to work together, but
this may be a wanted situation. If not, this can be removed by simply
toggling the respective plugin.
@dopenguin
Copy link
Member

@warm-coolguy I've added the relevant parts that were missing here.
However, I've decided against adding a mechanism in @polar/core and went with the route we've already established between @polar/plugin-pins and @polar/plugin-draw.

Let me know if you've got any questions!

@dopenguin dopenguin self-assigned this Dec 30, 2024
@dopenguin dopenguin removed their request for review December 30, 2024 11:03
@dopenguin
Copy link
Member

dopenguin commented Dec 30, 2024

Also, on another note, I'll tackle the TODOs in packages/plugins/Measure/src/components/Measure.vue soon! - Done 3a0472b

@dopenguin dopenguin self-requested a review as a code owner December 30, 2024 11:13
Copy link
Member

@warm-coolguy warm-coolguy left a comment

Choose a reason for hiding this comment

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

🏓 @dopenguin

After reviewing and summing up my findings I find that an awful lot of my comments is about making this implementation more like Draw. A lot of problems we have here have already been solved in Draw, and all that progress is lost on this re-implementation and would have to be redone samishly. (After all, Draw is the result of a lot of work over a long period of time, and we're on the third-or-so implementation here, learning incrementally.)

This makes me really wonder if Draw could just add, by configuration, another radio box section like pseudo-HTML:

h3. Measurement
  radio. None
  radio. m, m²
  radio. km, km²
  radio. km, ha

When active, lines would show lengths (and maybe length sum), areas lengths and area, and circles area and maybe circumference or diameter or whatever.

What do you think about this?

packages/plugins/Draw/package.json Outdated Show resolved Hide resolved
packages/plugins/Measure/README.md Show resolved Hide resolved
new Style({
stroke: new Stroke({ color: textColor, width: lineWidth / 5 }),
text: new Text({
font: 'bold 14px cursive',
Copy link
Member

Choose a reason for hiding this comment

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

I propose that the font (and, for that, all fields configurable in OL for Text) should be configurable, and don't consider the current defaults to work well.

ewww

I'm having issues reading this due to its fat/self-overlapping nature. While the problem can't be solved in general for all backgrounds, it can be solved better.

Copy link
Member

@dopenguin dopenguin Jan 6, 2025

Choose a reason for hiding this comment

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

Agreed, will add and adjust those!

packages/core/CHANGELOG.md Show resolved Hide resolved
packages/plugins/Gfi/src/store/actions/index.ts Outdated Show resolved Hide resolved
interactions.push(modify)
styleFunc = specialStyle
} else if (mode === 'delete') {
interactions = await dispatch('createDeleteInteraction', drawSource)
Copy link
Member

Choose a reason for hiding this comment

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

There is an effect on the edges that makes it seem like they can be interacted with, but nothing happens on clicks. That's confusing.

Copy link
Member

Choose a reason for hiding this comment

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

Adjusted 8b7258f

interactions.push(draw)
} else if (drawSource.getFeatures().length > 0) {
if (mode === 'edit') {
const modify = getModify(drawSource)
Copy link
Member

Choose a reason for hiding this comment

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

The modify does not yield any effects on the map, making it hard to see whether clicking will be effective. I propose the same effect as used in the Draw plugin should be used.

Copy link
Member

Choose a reason for hiding this comment

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

Will add that!

Comment on lines +35 to +39
if (pointAmount < minimum) {
drawSource.removeFeature(feature)
dispatch('setSelectedFeature', null)
return
}
Copy link
Member

Choose a reason for hiding this comment

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

Deletion in Measure differs to how Deletion in Draw works. Here, only corner points are deleted, and the feature is kept intact as long as possible. In Draw, we just delete whole features that are clicked, which seems to be the more reasonable behaviour to me.

Copy link
Member

Choose a reason for hiding this comment

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

I thought the implementation added was quite neat and left it as is. But I have no strong feelings and will adjust it.

Comment on lines 28 to 32
delete: {
// larger lines and points
lineWidth: 4,
pointWidth: 5,
},
Copy link
Member

Choose a reason for hiding this comment

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

I don't understand why lines should be fatter when starting a deletion albeit being exactly the elements the user is not supposed to interact with.

Copy link
Member

Choose a reason for hiding this comment

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

@dopenguin
Copy link
Member

dopenguin commented Jan 6, 2025

🏓 @dopenguin

After reviewing and summing up my findings I find that an awful lot of my comments is about making this implementation more like Draw. A lot of problems we have here have already been solved in Draw, and all that progress is lost on this re-implementation and would have to be redone samishly. (After all, Draw is the result of a lot of work over a long period of time, and we're on the third-or-so implementation here, learning incrementally.)

This makes me really wonder if Draw could just add, by configuration, another radio box section like pseudo-HTML:

h3. Measurement
  radio. None
  radio. m, m²
  radio. km, km²
  radio. km, ha

When active, lines would show lengths (and maybe length sum), areas lengths and area, and circles area and maybe circumference or diameter or whatever.

What do you think about this?

I thought, so far, that that would be an effort we are not taking right now but in the near future. Maybe we should discuss this before this PR gets merged though.

Edit: Before moving forward, adjusting everything to be like Draw, I agree that we should take a look on how some added things here may be added to Draw now instead of the future. Let's ☎️ about this soon!

@dopenguin dopenguin force-pushed the feature/add-measure-tool branch from 32b7b5c to e2d7079 Compare January 6, 2025 14:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants