Modify

Opened 16 months ago

Closed 15 months ago

Last modified 15 months ago

#22703 closed defect (fixed)

[Patch] Fix 90° offset of `icon-rotation: way;` in mapcss

Reported by: Woazboat Owned by: team
Priority: normal Milestone: 23.02
Component: Core mappaint Version:
Keywords: Cc:

Description

The (undocumented) *-rotation: way;in mapcss has an offset of 90° compared to *-rotation: <fixed angle>

The 90 degree offset occurs because https://josm.openstreetmap.de/browser/josm/trunk/src/org/openstreetmap/josm/tools/RotationAngle.java#L37 uses Geometry.getSegmentAngle, which calculates the angle using Math.atan2 and therefore the rotation starting from the x-axis (east) in counter clockwise direction. The icon rotation is relative to the icon and therefore 'starts' at the y-axis (north) going in the clockwise direction.
The returned angle is already correctly inverted to fix the rotation angle, but the 90° offset is not corrected. This can be fixed by adding an offset of - Math.PI/2 to the angle (+Math.PI/2 if done after inversion).

https://github.com/JOSM/josm/pull/109
https://github.com/JOSM/josm/pull/109.patch

See also #22695

Attachments (0)

Change History (4)

comment:1 by taylor.smock, 15 months ago

Any chance you can write a test for it? I can if you don't have the time.

comment:2 by Woazboat, 15 months ago

I added some tests to the PR

comment:3 by taylor.smock, 15 months ago

Resolution: fixed
Status: newclosed

In 18661/josm:

Fix #22703, see #22695, #22704: 90° offset of icon-rotation: way; in mapcss (patch by Woazboat, modified)

This is due to Geometry.getSegmentAngle getting the rotation from the positive
x-axis instead of the positive y-axis, but this is easily corrected by
subtracting 90 degrees (pi/2) from the calculation.

The previous behavior differed from the static rotation angle behavior, which
uses the positive y-axis.

comment:4 by taylor.smock, 15 months ago

Milestone: 23.02

Modify Ticket

Change Properties
Set your email in Preferences
Action
as closed The owner will remain team.
as The resolution will be set.
The resolution will be deleted. Next status will be 'reopened'.

Add Comment


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