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

Delete unused and broken LatLngBounds.pad() method. #1427

Merged
merged 1 commit into from
Feb 5, 2023

Commits on Jan 2, 2023

  1. Delete unused and broken LatLngBounds.pad() method.

    The method fails to deal correctly with LatLng wrap arounds. A more
    correct version would probably look more like:
    
        void pad(double bufferRatio) {
          final heightBuffer = (_sw!.latitude - _ne!.latitude).abs() * bufferRatio;
          final widthBuffer = (_sw!.longitude - _ne!.longitude).abs() * bufferRatio;
    
          final point1 = LatLng((90 + _sw!.latitude - heightBuffer) % 180 - 90,
              (180 + _sw!.longitude - widthBuffer) % 360 - 180);
          final point2 = LatLng((90 + _ne!.latitude + heightBuffer) % 180 - 90,
              (180 + _ne!.longitude + widthBuffer) % 360 - 180);
    
          final newBounds = LatLngBounds(point1, point2);
          _sw = newBounds.southWest;
          _ne = newBounds.northEast;
        }
    
    On a tangent, it probably should be a factory rather than a mutable
    method and the `bufferRatio` parameter is hard to use correctly. For
    example, bufferRatio = 0.5 would increase the bounds to 4 times its
    original size.
    ignatz committed Jan 2, 2023
    Configuration menu
    Copy the full SHA
    685af07 View commit details
    Browse the repository at this point in the history