-
-
Notifications
You must be signed in to change notification settings - Fork 893
Initial working fix - Resolves date line related issues. #2048
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 2 commits
c7be7cd
53e76fd
7594c2a
12ea190
f4ecf7a
e10b09b
1a3bc42
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,4 @@ | ||
| import 'dart:math' as math; | ||
| import 'dart:ui'; | ||
|
|
||
| import 'package:flutter_map/flutter_map.dart'; | ||
|
|
@@ -76,22 +77,36 @@ List<Offset> getOffsetsXY({ | |
| ]; | ||
| final halfScreenWidth = camera.size.width / 2; | ||
| final p = realPoints.elementAt(0); | ||
|
|
||
| // Define hysteresis threshold - this prevents oscillation | ||
| // The threshold value is approximately 5% of the screen width, | ||
| // which should provide enough stability without affecting usability | ||
| // Adjust hysteresis based on zoom level - tighter at high zoom, looser at low zoom | ||
| final double hysteresisThreshold = | ||
| camera.size.width * (0.05 / math.max(1, camera.zoom / 10)); | ||
|
|
||
| late double result; | ||
| late double bestX; | ||
| late double bestError; | ||
|
|
||
| for (int i = 0; i < addedWidths.length; i++) { | ||
| final addedWidth = addedWidths[i]; | ||
| final (x, _) = crs.transform(p.dx + addedWidth, p.dy, zoomScale); | ||
| final error = (x + ox - halfScreenWidth).abs(); | ||
|
|
||
| if (i == 0) { | ||
| result = addedWidth; | ||
| bestX = x; | ||
| bestError = error; | ||
| continue; | ||
| } | ||
| if ((bestX + ox - halfScreenWidth).abs() > | ||
| (x + ox - halfScreenWidth).abs()) { | ||
|
|
||
| // Only switch worlds if there's a significant improvement | ||
| // This prevents oscillation near the boundary | ||
| if (error < bestError - hysteresisThreshold) { | ||
| result = addedWidth; | ||
| bestX = x; | ||
| bestError = error; | ||
| } | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Could this be collapsed into a single decision? I'm also not aware of any situation where oscillation at the boundary is an issue? Did you reproduce this? As far as I understand, this is very different to #2019, but I'm probably missing something. // Only switch worlds if there's a significant improvement
// This prevents oscillation near the boundary
if (i == 0 || error < bestError - hysteresisThreshold) {
result = addedWidth;
bestError = error;
}
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'll have to give this a test - I had also noticed that the second assignment of bestX / bestError seemed unused. I knew I would need to review that anyways. Further, I remember this was related but I was iterating so many times I will confirm if reverting has impact and if so if we can simplify the logic. |
||
| } | ||
|
|
||
| return result; | ||
| } | ||
|
|
||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.