Skip to content
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

[BUG] Double bounding boxes in OverlayImageLayer cause incorrect size #1347

Open
5 tasks done
JosefWN opened this issue Aug 27, 2022 · 7 comments
Open
5 tasks done

[BUG] Double bounding boxes in OverlayImageLayer cause incorrect size #1347

JosefWN opened this issue Aug 27, 2022 · 7 comments
Labels
P: 4 (far future) S: core Scoped to the core flutter_map functionality

Comments

@JosefWN
Copy link
Contributor

JosefWN commented Aug 27, 2022

What is the bug?

I have discovered a couple of edge cases where having a bounding box:

class OverlayImage extends BaseOverlayImage {
  final LatLngBounds bounds;
  // ...

... in addition to the bounding box I added to support polar projections:

Positioned buildPositionedForOverlay(FlutterMapState map) {
  // northWest is not necessarily upperLeft depending on projection
  final bounds = Bounds<num>(
    map.project(this.bounds.northWest) - map.pixelOrigin,
    map.project(this.bounds.southEast) - map.pixelOrigin,
  );
  // ...

... will create a bounding box of incorrect size / incorrect position. Not way off, but noticeably.

What is the expected behaviour?

Image positioning issues should not occur.

How can we reproduce this issue?

Trying the EPSG:3413 example reprojected in EPSG:3996

Do you have a potential solution?

In my fork I solved this by changing bounds to a List<LatLng>. This would be a breaking API change. Should I make a PR for 3.0.0?

Can you provide any other information?

No response

Platforms Affected

MacOS

Severity

Obtrusive: Prevents normal functioning but causes no errors in the console

Frequency

Consistently: Always occurs at the same time and location

Requirements

  • I agree to follow this project's Code of Conduct
  • My Flutter/Dart installation is unaltered, and flutter doctor finds no relevant issues
  • I am using the latest stable version of this package
  • I have checked the FAQs section on the documentation website
  • I have checked for similar issues which may be duplicates
@JosefWN JosefWN added bug This issue reports broken functionality or another error needs triage This new bug report needs reproducing and prioritizing labels Aug 27, 2022
@JosefWN JosefWN changed the title [BUG] Double bounding boxes in OverlayImageLayer cause [BUG] Double bounding boxes in OverlayImageLayer cause incorrect size Aug 27, 2022
@JaffaKetchup
Copy link
Member

Hi @JosefWN,
Can you try using the LatLngBounds.fromPoints constructor, and see if that makes a difference?

@JosefWN
Copy link
Contributor Author

JosefWN commented Aug 29, 2022

Same problem. Here is a minimal snippet (EPSG:3996) reproducing it:

final topLeft = LatLng(74.60299799700462, -170.9997690385578);
final bottomRight = LatLng(77.77365255354441, 91.91349368273093);

final bounds = LatLngBounds(topLeft, bottomRight);
final projBounds1 = Bounds<num>(
  map.project(bounds.northWest) - map.pixelOrigin,
  map.project(bounds.southEast) - map.pixelOrigin,
);

final projBounds2 = Bounds<num>(
  map.project(topLeft) - map.pixelOrigin,
  map.project(bottomRight) - map.pixelOrigin,
);

final bounds2 = LatLngBounds.fromPoints([topLeft, bottomRight]);
final projBounds3 = Bounds<num>(
  map.project(bounds2.northWest) - map.pixelOrigin,
  map.project(bounds2.southEast) - map.pixelOrigin,
);

print('projBounds1 (current):');
print('topLeft: ${projBounds1.topLeft}');
print('bottomRight: ${projBounds1.bottomRight}');

print('topLeft: ${map.unproject(projBounds1.topLeft + map.pixelOrigin)}');
print('bottomRight: ${map.unproject(projBounds1.bottomRight + map.pixelOrigin)}');

print('projBounds2 (proposed):');
print('topLeft: ${projBounds2.topLeft}');
print('bottomRight: ${projBounds2.bottomRight}');

print('topLeft: ${map.unproject(projBounds2.topLeft + map.pixelOrigin)}');
print('bottomRight: ${map.unproject(projBounds2.bottomRight + map.pixelOrigin)}');

print('projBounds3 (LatLngBounds.fromPoints):');
print('topLeft: ${projBounds3.topLeft}');
print('bottomRight: ${projBounds3.bottomRight}');

print('topLeft: ${map.unproject(projBounds3.topLeft + map.pixelOrigin)}');
print('bottomRight: ${map.unproject(projBounds3.bottomRight + map.pixelOrigin)}');

This returns:

[        ] flutter: projBounds1 (current):
[        ] flutter: topLeft: CustomPoint (588.0229903084105, -381.9199091615926)
[        ] flutter: bottomRight: CustomPoint (1781.8419762539538, 414.2663707511856)
[        ] flutter: topLeft: LatLng(latitude:77.773653, longitude:-170.999769)
[        ] flutter: bottomRight: LatLng(latitude:74.602998, longitude:91.913494)
[        ] flutter: projBounds2 (proposed):
[        ] flutter: topLeft: CustomPoint (553.5052798486024, -599.8504701739987)
[        ] flutter: bottomRight: CustomPoint (1561.317779848603, 421.633904826002)
[        ] flutter: topLeft: LatLng(latitude:74.602998, longitude:-170.999769)
[        ] flutter: bottomRight: LatLng(latitude:77.773653, longitude:91.913494)
[        ] flutter: projBounds3 (LatLngBounds.fromPoints):
[        ] flutter: topLeft: CustomPoint (588.0229903084105, -381.9199091615926)
[        ] flutter: bottomRight: CustomPoint (1781.8419762539538, 414.2663707511856)
[        ] flutter: topLeft: LatLng(latitude:77.773653, longitude:-170.999769)
[        ] flutter: bottomRight: LatLng(latitude:74.602998, longitude:91.913494)

It seems some corner coordinates are swapped around in the assumption that topLeft is southWest and bottomRight is northEast.

@JaffaKetchup JaffaKetchup added non-fatal and removed needs triage This new bug report needs reproducing and prioritizing labels Aug 31, 2022
@JaffaKetchup
Copy link
Member

(preventing staleness from setting in)

Thanks, we'll have a look at this when we get a moment.

@github-actions
Copy link

This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 5 days.

@github-actions
Copy link

This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 5 days.

@github-actions
Copy link

This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 5 days.

@github-actions github-actions bot added the Stale label Dec 24, 2022
@github-actions
Copy link

This issue was closed because it has been stalled for 5 days with no activity.

@JaffaKetchup JaffaKetchup reopened this Dec 29, 2022
@JaffaKetchup JaffaKetchup added P: 3 (low) (Default priority for feature requests) and removed non-fatal labels Jun 19, 2023
@JaffaKetchup JaffaKetchup added P: 4 (far future) S: core Scoped to the core flutter_map functionality and removed P: 3 (low) (Default priority for feature requests) labels Aug 8, 2024
@JaffaKetchup JaffaKetchup removed the bug This issue reports broken functionality or another error label Jan 18, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
P: 4 (far future) S: core Scoped to the core flutter_map functionality
Projects
None yet
Development

No branches or pull requests

2 participants