Opened 5 years ago
Last modified 7 months ago
#11265 new enhancement
[PATCH] Measure area made of several segments
Reported by: | Owned by: | team | |
---|---|---|---|
Priority: | normal | Milestone: | |
Component: | Plugin measurement | Version: | |
Keywords: | area relation | Cc: | naoliv, GerdP |
Description
We are building relations made of several ways that meet end-to-end. Together these ways make up a single closed loop. It would be very useful if selecting all the ways (or just selecting the relation) would report the total area of the closed loop. Thanks!
Attachments (1)
Change History (6)
Changed 5 years ago by
Attachment: | measure-areas.diff added |
---|
comment:1 Changed 5 years ago by
Here is an initial attempt.
A node called areaStartNode
stores the first node in a possible area. At the end of measuring each way, we check to see if the lastNode
in the way is the same as the areaStartNode
. If so, we've found a closed loop and can add the calculated area to the final area, and areaStartNode
is reset.
If we start a new way and the first node is not the same as the lastNode
from the previous way, then the ways aren't joined; areaStartNode
is reset and wayArea
goes back to zero.
Note that this will only report a correct result when the ways are selected in order. Out of order, and the area will not be detected and the result will be zero. For a single closed area this will be obvious to the user, but if they've selected several areas (some in order, some not) then the error may not be obvious. I'm not sure if this is a serious enough limitation. A refinement could be to try sorting the ways to produce measurable areas every time.
comment:2 Changed 5 years ago by
Okay, so another limitation is that two ways that make an area must be the same way around (i.e. head to tail), or it doesn't detect the area. May need a lot more thinking here.
comment:3 Changed 5 years ago by
Cc: | naoliv added |
---|
comment:4 Changed 7 months ago by
Summary: | Measure area made of several segments → [PATCH] Measure area made of several segments |
---|
comment:5 Changed 7 months ago by
Cc: | GerdP added |
---|
I started to add multipolygon support in [o35047:35048] (I was surprised it was not handled already). The plugin can probably be simplified/optimized by calling more JOSM core geometry functions.
Measure areas made by several adjacent ways