Modify

Opened 5 years ago

Last modified 4 years ago

#19399 new enhancement

Merge BBox/Bounds/ProjectionBounds classes

Reported by: simon04 Owned by: team
Priority: normal Milestone:
Component: Core Version:
Keywords: refactoring Cc:

Description

Conceptually, all are rectangles of coordinates. However, each class completely different and compatible functions and constructors.

This is a simple data class for "rectangular" areas of the world, given in lat/lon min/max values.

A BBox represents an area in lat/lon space.

In contrast to a Bounds object, a BBox can represent an invalid (empty) area.

… "rectangular" areas of the world, given in east/north min/max values.

Use case: I'm just trying to get the area spanned by a collection of primitives for #19381. After half an hour I'm just confused… :(

Attachments (0)

Change History (6)

comment:1 by GerdP, 5 years ago

I also wondered, but I did bother to merge them. Both are used frequenty, also in many plugins.
Maybe LoadAndZoomHandler.zoom(Collection<OsmPrimitive> primitives, Bounds bbox) is close to what you need?

comment:2 by stoecker, 5 years ago

I'm pretty sure there is a reason we have different classes. They have semantic differences.

Last edited 5 years ago by stoecker (previous) (diff)

comment:3 by stoecker, 5 years ago

I'm just trying to get the area spanned by a collection of primitives

Should be simple:

b = new BBox();
for(prims) b.addPrimitive(..)

comment:4 by GerdP, 5 years ago

reg. #19381 you probably have to do more when it comes to deleted objects. A deleted way/relation has no nodes/members and thus will return an invalid bbox.

comment:5 by simon04, 4 years ago

I stumbled across this again via #20613:

org.openstreetmap.josm.data.osm.QuadBuckets often invokes org.openstreetmap.josm.data.IQuadBucketType#getBBox which always returns a new BBox (e.g. in org.openstreetmap.josm.data.osm.Way#getBBox) since BBox is mutable causing plenty of useless allocations just for the purpose of testing org.openstreetmap.josm.data.osm.BBox#bounds(BBox). Only rarely, the returned object is mutated.

Following the concept of the org.openstreetmap.josm.data.osm.I-interfaces, we should introduce an IBBox or IBounds interface without mutating methods. Alternative suggestions are welcome :)

comment:6 by simon04, 4 years ago

In 17703/josm:

see #19399 - Extract interface IBounds

Modify Ticket

Change Properties
Set your email in Preferences
Action
as new The owner will remain team.
as The resolution will be set. Next status will be 'closed'.
to The owner will be changed from team to the specified user.
Next status will be 'needinfo'. The owner will be changed from team to simon04.
as duplicate The resolution will be set to duplicate. Next status will be 'closed'. The specified ticket will be cross-referenced with this ticket.
The owner will be changed from team to anonymous. Next status will be 'assigned'.

Add Comment


E-mail address and name can be saved in the Preferences .
 
Note: See TracTickets for help on using tickets.