Fix: Labels overlap when map is rotated by Sublimis · Pull Request #1578 · mapsforge/mapsforge

Skip to content

Navigation Menu

Sign in

Appearance settings

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up

Appearance settings

Conversation

@Sublimis

Copy link

Contributor

Related (especially the comment):

double x = this.xy.x - origin.x;
double y = this.xy.y - origin.y;
if (!Rotation.noRotation(rotation)) {
androidCanvas.rotate(-rotation.degrees, rotation.px, rotation.py);
Point rotated = rotation.rotate(x, y, true);
x = rotated.x;
y = rotated.y;
}
// the offsets can only be applied after rotation, because the label needs to be rotated
// around its center.
x += this.horizontalOffset + boundary.left;
y += this.verticalOffset + boundary.top;

Before/After:

20241119_before20241119_after

@Sublimis

Copy link

Contributor Author

Please note that this fix is not perfect and may require more work, as it doesn't deal with offsets. Every proper solution should probably also recognize the additional offsets added, e.g.:

x += this.horizontalOffset + boundary.left;
y += this.verticalOffset + boundary.top;

and

x += this.horizontalOffset;
y += this.verticalOffset + textOffset; // the text offset has nothing to do with rotation, so add later

However, it does appear to be improvement over the current implementation.

@devemux86 devemux86 added the bug label

Nov 20, 2024

@devemux86 devemux86 added this to the 0.23.0 milestone

Nov 20, 2024

@devemux86 devemux86 merged commit 82ea30e into mapsforge:master

Nov 20, 2024

@devemux86

Copy link

Collaborator

@Sublimis Thanks!

@Sublimis Sublimis deleted the tmp13 branch

December 18, 2024 11:19

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

No reviews

Assignees

No one assigned

Labels

Projects

None yet

Milestone

0.23.0

Development

Successfully merging this pull request may close these issues.

2 participants

@Sublimis @devemux86