fleaflet / flutter_map

A versatile mapping package for Flutter. Simple and easy to learn, yet completely customizable and configurable, it's the best choice for mapping in your Flutter app.
https://pub.dev/packages/flutter_map
BSD 3-Clause "New" or "Revised" License
2.68k stars 848 forks source link

fix: `PolylineLayer` throws exception: "The west longitude can't be smaller than the east longitude" #1879

Closed josxha closed 1 month ago

josxha commented 1 month ago

Some linestrings caused the PolylineLayer to throw an assertion exception.

Assertion failed: file:///Users/matthiaskoch/.pub-cache/git/flutter_map-930e8b60e125e630e3c85ab373c0ebb8e9b08d70/lib/src/geo/latlng_bounds.dart:82:16
east >= west
"The west longitude can't be smaller than the east longitude"

packages/flutter_map/src/geo/latlng_bounds.dart 82:28                             unsafe
packages/flutter_map/src/layer/polyline_layer/polyline_layer.dart 171:41          [_aggressivelyCullPolylines]
packages/flutter_map/src/layer/polyline_layer/polyline_layer.dart 138:11          build

This bug was reported by borg_1of3 on discord: https://discord.com/channels/951867686378409984/1235305884620689558/1235305884620689558

The bug sneaked into the code base in https://github.com/fleaflet/flutter_map/pull/1834.

monsieurtanuki commented 1 month ago

My 2 cents: inlatlng_bounds.dart we see several times things like

    double minX = 180;
    double maxX = -180;
    double minY = 90;
    double maxY = -90;

As a refactoring, we may be better off making those values static const double and reuse those values elsewhere.

fmt-Println-MKO commented 1 month ago

thanks for the quick fix :)

josxha commented 1 month ago

@mootw thanks for the review and @monsieurtanuki thanks for the comment. I added the requested refactoring. Does anyone want to take another look before we merge?