Opened 5 years ago

Last modified 7 months ago

#11265 new enhancement

[PATCH] Measure area made of several segments

Reported by: me@… Owned by: team
Priority: normal Milestone:
Component: Plugin measurement Version:
Keywords: area relation Cc: naoliv, GerdP


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)

measure-areas.diff (3.3 KB) - added by me@… 5 years ago.
Measure areas made by several adjacent ways

Download all attachments as: .zip

Change History (6)

Changed 5 years ago by me@…

Attachment: measure-areas.diff added

Measure areas made by several adjacent ways

comment:1 Changed 5 years ago by me@…

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 anonymous

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 naoliv

Cc: naoliv added

comment:4 Changed 7 months ago by Don-vip

Summary: Measure area made of several segments[PATCH] Measure area made of several segments

comment:5 Changed 7 months ago by Don-vip

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.

Modify Ticket

Change Properties
Set your email in Preferences
as new The owner will remain team.
as The resolution will be set.
to The owner will be changed from team to the specified user.
The owner will change to
as duplicate The resolution will be set to duplicate.The specified ticket will be cross-referenced with this ticket
The owner will be changed from team to anonymous.

Add Comment

E-mail address and name can be saved in the Preferences.

Note: See TracTickets for help on using tickets.