#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
Any chance you can write a test for it? I can if you don't have the time.