From 8fa1f81bb62164ba0826d4a3c3c08fb5fef5300c Mon Sep 17 00:00:00 2001 From: JaffaKetchup Date: Sat, 11 Jan 2025 21:37:43 +0000 Subject: [PATCH 1/6] Updated to support flutter_map v8 Removed usage of `Point` --- .../internal/tile_loops/count.dart | 139 +++++++------- .../internal/tile_loops/generate.dart | 173 ++++++++++-------- .../internal/tile_loops/shared.dart | 40 ++-- pubspec.yaml | 5 +- 4 files changed, 197 insertions(+), 160 deletions(-) diff --git a/lib/src/bulk_download/internal/tile_loops/count.dart b/lib/src/bulk_download/internal/tile_loops/count.dart index be2075fe..812623f0 100644 --- a/lib/src/bulk_download/internal/tile_loops/count.dart +++ b/lib/src/bulk_download/internal/tile_loops/count.dart @@ -38,15 +38,17 @@ class TileCounters { for (double zoomLvl = region.minZoom.toDouble(); zoomLvl <= region.maxZoom; zoomLvl++) { - final nwPoint = (region.crs.latLngToPoint(northWest, zoomLvl) / - region.options.tileSize) - .floor(); - final sePoint = (region.crs.latLngToPoint(southEast, zoomLvl) / - region.options.tileSize) - .ceil() - - const Point(1, 1); - - tileCount += (sePoint.x - nwPoint.x + 1) * (sePoint.y - nwPoint.y + 1); + final scaleLvl = region.crs.scale(zoomLvl); + + final nw = region.crs.latLngToXY(northWest, scaleLvl); + final nwX = (nw.$1 / region.options.tileDimension).floor(); + final nwY = (nw.$2 / region.options.tileDimension).floor(); + + final se = region.crs.latLngToXY(southEast, scaleLvl); + final seX = (se.$1 / region.options.tileDimension).ceil() - 1; + final seY = (se.$2 / region.options.tileDimension).ceil() - 1; + + tileCount += (seX - nwX + 1) * (seY - nwY + 1); } return _trimToRange(region, tileCount); @@ -64,20 +66,19 @@ class TileCounters { 0, ); - for (int zoomLvl = region.minZoom; zoomLvl <= region.maxZoom; zoomLvl++) { - final centerTile = (region.crs.latLngToPoint( - region.originalRegion.center, - zoomLvl.toDouble(), - ) / - region.options.tileSize) - .floor(); + for (double zoomLvl = region.minZoom.toDouble(); + zoomLvl <= region.maxZoom; + zoomLvl++) { + final scaleLvl = region.crs.scale(zoomLvl); + + final (_, rawCenterY) = + region.crs.latLngToXY(region.originalRegion.center, scaleLvl); + final centerY = (rawCenterY / region.options.tileDimension).floor(); - final radius = centerTile.y - - (region.crs.latLngToPoint(edgeTile, zoomLvl.toDouble()) / - region.options.tileSize) - .floor() - .y; + final (_, rawEdgeY) = region.crs.latLngToXY(edgeTile, scaleLvl); + final edgeY = (rawEdgeY / region.options.tileDimension).floor(); + final radius = centerY - edgeY; final radiusSquared = radius * radius; if (radius == 0) { @@ -113,12 +114,12 @@ class TileCounters { final p1 = polygon.points[i1]; final p2 = polygon.points[i2]; - final normal = Point(p2.y - p1.y, p1.x - p2.x); + final normal = Point(p2.$2 - p1.$2, p1.$1 - p2.$1); var minA = largestInt; var maxA = smallestInt; for (final p in a.points) { - final projected = normal.x * p.x + normal.y * p.y; + final projected = normal.x * p.$1 + normal.y * p.$2; if (projected < minA) minA = projected; if (projected > maxA) maxA = projected; } @@ -126,7 +127,7 @@ class TileCounters { var minB = largestInt; var maxB = smallestInt; for (final p in b.points) { - final projected = normal.x * p.x + normal.y * p.y; + final projected = normal.x * p.$1 + normal.y * p.$2; if (projected < minB) minB = projected; if (projected > maxB) maxB = projected; } @@ -145,6 +146,8 @@ class TileCounters { for (double zoomLvl = region.minZoom.toDouble(); zoomLvl <= region.maxZoom; zoomLvl++) { + final scaleLvl = region.crs.scale(zoomLvl); + final generatedTiles = []; for (final rect in lineOutline) { @@ -169,51 +172,49 @@ class TileCounters { ]; final rotatedRectangleNW = - (region.crs.latLngToPoint(rotatedRectangle.topLeft, zoomLvl) / - region.options.tileSize) + (region.crs.latLngToXY(rotatedRectangle.topLeft, scaleLvl) / + region.options.tileDimension) .floor(); final rotatedRectangleNE = - (region.crs.latLngToPoint(rotatedRectangle.topRight, zoomLvl) / - region.options.tileSize) + (region.crs.latLngToXY(rotatedRectangle.topRight, scaleLvl) / + region.options.tileDimension) .ceil() - - const Point(1, 0); + (1, 0); final rotatedRectangleSW = - (region.crs.latLngToPoint(rotatedRectangle.bottomLeft, zoomLvl) / - region.options.tileSize) + (region.crs.latLngToXY(rotatedRectangle.bottomLeft, scaleLvl) / + region.options.tileDimension) .ceil() - - const Point(0, 1); + (0, 1); final rotatedRectangleSE = - (region.crs.latLngToPoint(rotatedRectangle.bottomRight, zoomLvl) / - region.options.tileSize) + (region.crs.latLngToXY(rotatedRectangle.bottomRight, scaleLvl) / + region.options.tileDimension) .ceil() - - const Point(1, 1); + (1, 1); - final straightRectangleNW = (region.crs.latLngToPoint( + final straightRectangleNW = (region.crs.latLngToXY( LatLng(rotatedRectangleLats.max, rotatedRectangleLngs.min), - zoomLvl, + scaleLvl, ) / - region.options.tileSize) + region.options.tileDimension) .floor(); - final straightRectangleSE = (region.crs.latLngToPoint( + final straightRectangleSE = (region.crs.latLngToXY( LatLng( rotatedRectangleLats.min, rotatedRectangleLngs.max, ), - zoomLvl, + scaleLvl, ) / - region.options.tileSize) + region.options.tileDimension) .ceil() - - const Point(1, 1); + (1, 1); - for (int x = straightRectangleNW.x; x <= straightRectangleSE.x; x++) { + for (int x = straightRectangleNW.$1; x <= straightRectangleSE.$1; x++) { bool foundOverlappingTile = false; - for (int y = straightRectangleNW.y; y <= straightRectangleSE.y; y++) { - final tile = _Polygon( - Point(x, y), - Point(x + 1, y), - Point(x + 1, y + 1), - Point(x, y + 1), - ); + for (int y = straightRectangleNW.$2; + y <= straightRectangleSE.$2; + y++) { + final tile = + _Polygon((x, y), (x + 1, y), (x + 1, y + 1), (x, y + 1)); if (generatedTiles.contains(tile.hashCode)) continue; if (overlap( _Polygon( @@ -251,35 +252,43 @@ class TileCounters { for (double zoomLvl = region.minZoom.toDouble(); zoomLvl <= region.maxZoom; zoomLvl++) { - final allOutlineTiles = >{}; + final scaleLvl = region.crs.scale(zoomLvl); - final pointsOutline = customPolygonOutline - .map((e) => region.crs.latLngToPoint(e, zoomLvl).floor()); + final allOutlineTiles = <(int, int)>{}; - for (final triangle in Earcut.triangulateFromPoints( - pointsOutline.map((e) => e.toDoublePoint()), + final pointsOutline = customPolygonOutline + .map((e) => region.crs.latLngToXY(e, scaleLvl).floorToDouble()); + + for (final triangle in Earcut.triangulateRaw( + List.generate( + pointsOutline.length * 2, + (i) => i.isEven + ? pointsOutline.elementAt(i ~/ 2).$1 + : pointsOutline.elementAt(i ~/ 2).$2, + growable: false, + ), ).map(pointsOutline.elementAt).slices(3)) { final outlineTiles = { ..._bresenhamsLGA( - Point(triangle[0].x, triangle[0].y), - Point(triangle[1].x, triangle[1].y), - unscaleBy: region.options.tileSize, + triangle[0], + triangle[1], + unscaleBy: region.options.tileDimension, ), ..._bresenhamsLGA( - Point(triangle[1].x, triangle[1].y), - Point(triangle[2].x, triangle[2].y), - unscaleBy: region.options.tileSize, + triangle[1], + triangle[2], + unscaleBy: region.options.tileDimension, ), ..._bresenhamsLGA( - Point(triangle[2].x, triangle[2].y), - Point(triangle[0].x, triangle[0].y), - unscaleBy: region.options.tileSize, + triangle[2], + triangle[0], + unscaleBy: region.options.tileDimension, ), }; allOutlineTiles.addAll(outlineTiles); final byY = >{}; - for (final Point(:x, :y) in outlineTiles) { + for (final (x, y) in outlineTiles) { (byY[y] ??= {}).add(x); } diff --git a/lib/src/bulk_download/internal/tile_loops/generate.dart b/lib/src/bulk_download/internal/tile_loops/generate.dart index 459042ab..5424d708 100644 --- a/lib/src/bulk_download/internal/tile_loops/generate.dart +++ b/lib/src/bulk_download/internal/tile_loops/generate.dart @@ -49,16 +49,19 @@ class TileGenerators { for (double zoomLvl = region.minZoom.toDouble(); zoomLvl <= region.maxZoom; zoomLvl++) { - final nwPoint = (region.crs.latLngToPoint(northWest, zoomLvl) / - region.options.tileSize) - .floor(); - final sePoint = (region.crs.latLngToPoint(southEast, zoomLvl) / - region.options.tileSize) - .ceil() - - const Point(1, 1); - - for (int x = nwPoint.x; x <= sePoint.x; x++) { - for (int y = nwPoint.y; y <= sePoint.y; y++) { + final intZoomLvl = zoomLvl.toInt(); + final scaleLvl = region.crs.scale(zoomLvl); + + final nw = region.crs.latLngToXY(northWest, scaleLvl); + final nwX = (nw.$1 / region.options.tileDimension).floor(); + final nwY = (nw.$2 / region.options.tileDimension).floor(); + + final se = region.crs.latLngToXY(southEast, scaleLvl); + final seX = (se.$1 / region.options.tileDimension).ceil() - 1; + final seY = (se.$2 / region.options.tileDimension).ceil() - 1; + + for (int x = nwX; x <= seX; x++) { + for (int y = nwY; y <= seY; y++) { tileCounter++; if (tileCounter < start) continue; if (tileCounter > end) { @@ -67,7 +70,7 @@ class TileGenerators { } await requestQueue.next; - sendPort.send((x, y, zoomLvl.toInt())); + sendPort.send((x, y, intZoomLvl)); } } } @@ -105,19 +108,21 @@ class TileGenerators { 0, ); - for (int zoomLvl = region.minZoom; zoomLvl <= region.maxZoom; zoomLvl++) { - final centerTile = (region.crs.latLngToPoint( - region.originalRegion.center, - zoomLvl.toDouble(), - ) / - region.options.tileSize) - .floor(); + for (double zoomLvl = region.minZoom.toDouble(); + zoomLvl <= region.maxZoom; + zoomLvl++) { + final intZoomLvl = zoomLvl.toInt(); + final scaleLvl = region.crs.scale(zoomLvl); + + final centerTile = + (region.crs.latLngToXY(region.originalRegion.center, scaleLvl) / + region.options.tileDimension) + .floor(); - final radius = centerTile.y - - (region.crs.latLngToPoint(edgeTile, zoomLvl.toDouble()) / - region.options.tileSize) - .floor() - .y; + final radius = centerTile.$2 - + (region.crs.latLngToXY(edgeTile, scaleLvl).$2 / + region.options.tileDimension) + .floor(); final radiusSquared = radius * radius; @@ -130,7 +135,7 @@ class TileGenerators { } await requestQueue.next; - sendPort.send((centerTile.x, centerTile.y, zoomLvl)); + sendPort.send((centerTile.$1, centerTile.$2, intZoomLvl)); continue; } @@ -144,7 +149,7 @@ class TileGenerators { } await requestQueue.next; - sendPort.send((centerTile.x, centerTile.y, zoomLvl)); + sendPort.send((centerTile.$1, centerTile.$2, intZoomLvl)); } tileCounter++; @@ -155,7 +160,7 @@ class TileGenerators { } await requestQueue.next; - sendPort.send((centerTile.x, centerTile.y - 1, zoomLvl)); + sendPort.send((centerTile.$1, centerTile.$2 - 1, intZoomLvl)); } tileCounter++; @@ -166,7 +171,7 @@ class TileGenerators { } await requestQueue.next; - sendPort.send((centerTile.x - 1, centerTile.y, zoomLvl)); + sendPort.send((centerTile.$1 - 1, centerTile.$2, intZoomLvl)); } tileCounter++; @@ -177,7 +182,7 @@ class TileGenerators { } await requestQueue.next; - sendPort.send((centerTile.x - 1, centerTile.y - 1, zoomLvl)); + sendPort.send((centerTile.$1 - 1, centerTile.$2 - 1, intZoomLvl)); } continue; @@ -194,7 +199,7 @@ class TileGenerators { } await requestQueue.next; - sendPort.send((dx + centerTile.x, dy + centerTile.y, zoomLvl)); + sendPort.send((dx + centerTile.$1, dy + centerTile.$2, intZoomLvl)); } tileCounter++; @@ -205,7 +210,9 @@ class TileGenerators { } await requestQueue.next; - sendPort.send((dx + centerTile.x, -dy - 1 + centerTile.y, zoomLvl)); + sendPort.send( + (dx + centerTile.$1, -dy - 1 + centerTile.$2, intZoomLvl), + ); } } } @@ -245,12 +252,12 @@ class TileGenerators { final p1 = polygon.points[i1]; final p2 = polygon.points[i2]; - final normal = Point(p2.y - p1.y, p1.x - p2.x); + final normal = Point(p2.$2 - p1.$2, p1.$1 - p2.$1); var minA = largestInt; var maxA = smallestInt; for (final p in a.points) { - final projected = normal.x * p.x + normal.y * p.y; + final projected = normal.x * p.$1 + normal.y * p.$2; if (projected < minA) minA = projected; if (projected > maxA) maxA = projected; } @@ -258,7 +265,7 @@ class TileGenerators { var minB = largestInt; var maxB = smallestInt; for (final p in b.points) { - final projected = normal.x * p.x + normal.y * p.y; + final projected = normal.x * p.$1 + normal.y * p.$2; if (projected < minB) minB = projected; if (projected > maxB) maxB = projected; } @@ -292,6 +299,9 @@ class TileGenerators { for (double zoomLvl = region.minZoom.toDouble(); zoomLvl <= region.maxZoom; zoomLvl++) { + final intZoomLvl = zoomLvl.toInt(); + final scaleLvl = region.crs.scale(zoomLvl); + final generatedTiles = []; for (final rect in lineOutline) { @@ -316,51 +326,49 @@ class TileGenerators { ]; final rotatedRectangleNW = - (region.crs.latLngToPoint(rotatedRectangle.topLeft, zoomLvl) / - region.options.tileSize) + (region.crs.latLngToXY(rotatedRectangle.topLeft, scaleLvl) / + region.options.tileDimension) .floor(); final rotatedRectangleNE = - (region.crs.latLngToPoint(rotatedRectangle.topRight, zoomLvl) / - region.options.tileSize) + (region.crs.latLngToXY(rotatedRectangle.topRight, scaleLvl) / + region.options.tileDimension) .ceil() - - const Point(1, 0); + (1, 0); final rotatedRectangleSW = - (region.crs.latLngToPoint(rotatedRectangle.bottomLeft, zoomLvl) / - region.options.tileSize) + (region.crs.latLngToXY(rotatedRectangle.bottomLeft, scaleLvl) / + region.options.tileDimension) .ceil() - - const Point(0, 1); + (0, 1); final rotatedRectangleSE = - (region.crs.latLngToPoint(rotatedRectangle.bottomRight, zoomLvl) / - region.options.tileSize) + (region.crs.latLngToXY(rotatedRectangle.bottomRight, scaleLvl) / + region.options.tileDimension) .ceil() - - const Point(1, 1); + (1, 1); - final straightRectangleNW = (region.crs.latLngToPoint( + final straightRectangleNW = (region.crs.latLngToXY( LatLng(rotatedRectangleLats.max, rotatedRectangleLngs.min), - zoomLvl, + scaleLvl, ) / - region.options.tileSize) + region.options.tileDimension) .floor(); - final straightRectangleSE = (region.crs.latLngToPoint( + final straightRectangleSE = (region.crs.latLngToXY( LatLng( rotatedRectangleLats.min, rotatedRectangleLngs.max, ), - zoomLvl, + scaleLvl, ) / - region.options.tileSize) + region.options.tileDimension) .ceil() - - const Point(1, 1); + (1, 1); - for (int x = straightRectangleNW.x; x <= straightRectangleSE.x; x++) { + for (int x = straightRectangleNW.$1; x <= straightRectangleSE.$1; x++) { bool foundOverlappingTile = false; - for (int y = straightRectangleNW.y; y <= straightRectangleSE.y; y++) { - final tile = _Polygon( - Point(x, y), - Point(x + 1, y), - Point(x + 1, y + 1), - Point(x, y + 1), - ); + for (int y = straightRectangleNW.$2; + y <= straightRectangleSE.$2; + y++) { + final tile = + _Polygon((x, y), (x + 1, y), (x + 1, y + 1), (x, y + 1)); if (generatedTiles.contains(tile.hashCode)) continue; if (overlap( @@ -383,7 +391,7 @@ class TileGenerators { } await requestQueue.next; - sendPort.send((x, y, zoomLvl.toInt())); + sendPort.send((x, y, intZoomLvl)); } else if (foundOverlappingTile) { break; } @@ -425,35 +433,44 @@ class TileGenerators { for (double zoomLvl = region.minZoom.toDouble(); zoomLvl <= region.maxZoom; zoomLvl++) { - final allOutlineTiles = >{}; + final intZoomLvl = zoomLvl.toInt(); + final scaleLvl = region.crs.scale(zoomLvl); - final pointsOutline = region.originalRegion.outline - .map((e) => region.crs.latLngToPoint(e, zoomLvl).floor()); + final allOutlineTiles = <(int, int)>{}; - for (final triangle in Earcut.triangulateFromPoints( - pointsOutline.map((e) => e.toDoublePoint()), + final pointsOutline = region.originalRegion.outline + .map((e) => region.crs.latLngToXY(e, scaleLvl).floorToDouble()); + + for (final triangle in Earcut.triangulateRaw( + List.generate( + pointsOutline.length * 2, + (i) => i.isEven + ? pointsOutline.elementAt(i ~/ 2).$1 + : pointsOutline.elementAt(i ~/ 2).$2, + growable: false, + ), ).map(pointsOutline.elementAt).slices(3)) { final outlineTiles = { ..._bresenhamsLGA( - Point(triangle[0].x, triangle[0].y), - Point(triangle[1].x, triangle[1].y), - unscaleBy: region.options.tileSize, + triangle[0], + triangle[1], + unscaleBy: region.options.tileDimension, ), ..._bresenhamsLGA( - Point(triangle[1].x, triangle[1].y), - Point(triangle[2].x, triangle[2].y), - unscaleBy: region.options.tileSize, + triangle[1], + triangle[2], + unscaleBy: region.options.tileDimension, ), ..._bresenhamsLGA( - Point(triangle[2].x, triangle[2].y), - Point(triangle[0].x, triangle[0].y), - unscaleBy: region.options.tileSize, + triangle[2], + triangle[0], + unscaleBy: region.options.tileDimension, ), }; allOutlineTiles.addAll(outlineTiles); final byY = >{}; - for (final Point(:x, :y) in outlineTiles) { + for (final (x, y) in outlineTiles) { (byY[y] ??= {}).add(x); } @@ -477,12 +494,12 @@ class TileGenerators { } await requestQueue.next; - sendPort.send((x, y, zoomLvl.toInt())); + sendPort.send((x, y, intZoomLvl)); } } } - for (final Point(:x, :y) in allOutlineTiles) { + for (final (x, y) in allOutlineTiles) { tileCounter++; if (tileCounter < start) continue; if (tileCounter > end) { @@ -491,7 +508,7 @@ class TileGenerators { } await requestQueue.next; - sendPort.send((x, y, zoomLvl.toInt())); + sendPort.send((x, y, intZoomLvl)); } } diff --git a/lib/src/bulk_download/internal/tile_loops/shared.dart b/lib/src/bulk_download/internal/tile_loops/shared.dart index d2f3004d..a391dc16 100644 --- a/lib/src/bulk_download/internal/tile_loops/shared.dart +++ b/lib/src/bulk_download/internal/tile_loops/shared.dart @@ -7,8 +7,6 @@ import 'dart:math'; import 'package:async/async.dart'; import 'package:collection/collection.dart'; import 'package:dart_earcut/dart_earcut.dart'; -import 'package:flutter_map/flutter_map.dart'; -import 'package:flutter_map/flutter_map.dart' hide Polygon; import 'package:latlong2/latlong.dart'; import 'package:meta/meta.dart'; @@ -20,12 +18,12 @@ part 'generate.dart'; @immutable class _Polygon { - _Polygon(Point nw, Point ne, Point se, Point sw) + _Polygon((int, int) nw, (int, int) ne, (int, int) se, (int, int) sw) : points = [nw, ne, se, sw] { hashCode = Object.hashAll(points); } - final List> points; + final List<(int, int)> points; @override late final int hashCode; @@ -38,19 +36,19 @@ class _Polygon { /// Bresenham’s line generation algorithm, ported (with minor API differences) /// from [anushaihalapathirana/Bresenham-line-drawing-algorithm](https://github.com/anushaihalapathirana/Bresenham-line-drawing-algorithm). -Iterable> _bresenhamsLGA( - Point start, - Point end, { - double unscaleBy = 1, +Iterable<(int, int)> _bresenhamsLGA( + (double, double) start, + (double, double) end, { + int unscaleBy = 1, }) sync* { - final dx = end.x - start.x; - final dy = end.y - start.y; + final dx = end.$1 - start.$1; + final dy = end.$2 - start.$2; final absdx = dx.abs(); final absdy = dy.abs(); - var x = start.x; - var y = start.y; - yield Point((x / unscaleBy).floor(), (y / unscaleBy).floor()); + var x = start.$1; + var y = start.$2; + yield ((x, y) / unscaleBy).floor(); if (absdx > absdy) { var d = 2 * absdy - absdx; @@ -63,7 +61,7 @@ Iterable> _bresenhamsLGA( y = dy < 0 ? y - 1 : y + 1; d = d + (2 * absdy - 2 * absdx); } - yield Point((x / unscaleBy).floor(), (y / unscaleBy).floor()); + yield ((x, y) / unscaleBy).floor(); } } else { // case when slope is greater than or equals to 1 @@ -77,7 +75,19 @@ Iterable> _bresenhamsLGA( x = dx < 0 ? x - 1 : x + 1; d = d + (2 * absdx) - (2 * absdy); } - yield Point((x / unscaleBy).floor(), (y / unscaleBy).floor()); + yield ((x, y) / unscaleBy).floor(); } } } + +extension on (double, double) { + (double, double) operator /(num other) => ($1 / other, $2 / other); + + (int, int) floor() => ($1.floor(), $2.floor()); + (double, double) floorToDouble() => ($1.floorToDouble(), $2.floorToDouble()); + (int, int) ceil() => ($1.ceil(), $2.ceil()); +} + +extension on (int, int) { + (int, int) operator -((int, int) other) => ($1 - other.$1, $2 - other.$2); +} diff --git a/pubspec.yaml b/pubspec.yaml index 199e1fc6..ad8956c9 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -29,11 +29,12 @@ environment: dependencies: async: ^2.11.0 collection: ^1.18.0 - dart_earcut: ^1.1.0 + dart_earcut: ^1.2.0 flat_buffers: ^23.5.26 flutter: sdk: flutter - flutter_map: ^7.0.2 + flutter_map: + git: https://github.com/fleaflet/flutter_map.git http: ^1.2.2 latlong2: ^0.9.1 meta: ^1.15.0 From a0f1b8cabe9f7d013a78ff616fa72689f140db37 Mon Sep 17 00:00:00 2001 From: JaffaKetchup Date: Sat, 11 Jan 2025 21:43:28 +0000 Subject: [PATCH 2/6] Upgrade example app to flutter_map v8 --- .../components/render_object.dart | 23 ++++++++++++++----- .../src/screens/main/map_view/map_view.dart | 9 +++----- example/pubspec.yaml | 4 +--- 3 files changed, 21 insertions(+), 15 deletions(-) diff --git a/example/lib/src/screens/main/map_view/components/download_progress/components/render_object.dart b/example/lib/src/screens/main/map_view/components/download_progress/components/render_object.dart index 1304f6b7..0a5d0e5d 100644 --- a/example/lib/src/screens/main/map_view/components/download_progress/components/render_object.dart +++ b/example/lib/src/screens/main/map_view/components/download_progress/components/render_object.dart @@ -230,9 +230,9 @@ class _DownloadProgressMaskerRenderer extends RenderProxyBox { /// Project specified coordinates to a screen space [Rect] Rect _calculateRectOfCoords(LatLng nwCoord, LatLng seCoord) { - final nwScreen = mapCamera.latLngToScreenPoint(nwCoord); - final seScreen = mapCamera.latLngToScreenPoint(seCoord); - return Rect.fromPoints(nwScreen.toOffset(), seScreen.toOffset()); + final nwScreen = mapCamera.latLngToScreenOffset(nwCoord); + final seScreen = mapCamera.latLngToScreenOffset(seCoord); + return Rect.fromPoints(nwScreen, seScreen); } /// Handles incoming tiles from the input stream, modifying the [_tileMapping] @@ -272,9 +272,20 @@ class _DownloadProgressMaskerRenderer extends RenderProxyBox { } else { final zoom = tile.z.toDouble(); _tileMapping[intermediateZoomTile] = tmv = _TileMappingValue.newTile( - nwCoord: mapCamera.crs.pointToLatLng(tile * tileSize, zoom), - seCoord: mapCamera.crs - .pointToLatLng((tile + const Point(1, 1)) * tileSize, zoom), + nwCoord: mapCamera.crs.offsetToLatLng( + Offset( + (tile.x * tileSize).toDouble(), + (tile.y * tileSize).toDouble(), + ), + zoom, + ), + seCoord: mapCamera.crs.offsetToLatLng( + Offset( + ((tile.x + 1) * tileSize).toDouble(), + ((tile.y + 1) * tileSize).toDouble(), + ), + zoom, + ), ); _mostRecentTile = () => _calculateRectOfCoords(tmv.nwCoord, tmv.seCoord); diff --git a/example/lib/src/screens/main/map_view/map_view.dart b/example/lib/src/screens/main/map_view/map_view.dart index a2bfe56b..9420ddb6 100644 --- a/example/lib/src/screens/main/map_view/map_view.dart +++ b/example/lib/src/screens/main/map_view/map_view.dart @@ -171,8 +171,7 @@ class _MapViewState extends State with TickerProviderStateMixin { final coords = provider.currentConstructingCoordinates; if (coords.length > 1) { final newPointPos = _mapController.mapController.camera - .latLngToScreenPoint(coords.first) - .toOffset(); + .latLngToScreenOffset(coords.first); provider.customPolygonSnap = coords.first != coords.last && sqrt( pow(newPointPos.dx - evt.localPosition.dx, 2) + @@ -196,11 +195,9 @@ class _MapViewState extends State with TickerProviderStateMixin { final coords = provider.currentConstructingCoordinates; if (coords.length > 1) { final newPointPos = _mapController.mapController.camera - .latLngToScreenPoint(coords.first) - .toOffset(); + .latLngToScreenOffset(coords.first); final centerPos = _mapController.mapController.camera - .latLngToScreenPoint(provider.currentNewPointPos!) - .toOffset(); + .latLngToScreenOffset(provider.currentNewPointPos!); provider.customPolygonSnap = coords.first != coords.last && sqrt( pow(newPointPos.dx - centerPos.dx, 2) + diff --git a/example/pubspec.yaml b/example/pubspec.yaml index b48b6e7c..73ea88a1 100644 --- a/example/pubspec.yaml +++ b/example/pubspec.yaml @@ -33,9 +33,7 @@ dependencies: dependency_overrides: flutter_map: - git: - url: https://github.com/fleaflet/flutter_map.git - ref: d816b4d54f9245e260b125ea1adbf300b5c39843 + git: https://github.com/fleaflet/flutter_map.git flutter_map_tile_caching: path: ../ From 49f8dab56b37c069afb14f9e734a3140a2609b61 Mon Sep 17 00:00:00 2001 From: JaffaKetchup Date: Sat, 11 Jan 2025 21:45:19 +0000 Subject: [PATCH 3/6] Prepared for v10.1 release --- CHANGELOG.md | 4 ++++ example/pubspec.yaml | 2 +- pubspec.yaml | 2 +- windowsApplicationInstallerSetup.iss | 2 +- 4 files changed, 7 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index db299bd8..2c5325fb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -18,6 +18,10 @@ Many thanks to my sponsors, no matter how much or how little they donated. Spons # Changelog +## [10.1.0] - 2025/XX/XX + +* Added support for flutter_map v8 + ## [10.0.0] - "Better Browsing" - 2025/01/11 This update builds on v9 to fully embrace the new many-to-many relationship between tiles and stores, which allows for more flexibility when constructing the `FMTCTileProvider`. diff --git a/example/pubspec.yaml b/example/pubspec.yaml index 73ea88a1..e1facc1d 100644 --- a/example/pubspec.yaml +++ b/example/pubspec.yaml @@ -1,7 +1,7 @@ name: fmtc_demo description: The demo app for 'flutter_map_tile_caching', showcasing its functionality and use-cases. publish_to: "none" -version: 10.0.0 +version: 10.1.0 environment: sdk: ">=3.6.0 <4.0.0" diff --git a/pubspec.yaml b/pubspec.yaml index ad8956c9..4b8d34f0 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,7 +1,7 @@ name: flutter_map_tile_caching description: Plugin for 'flutter_map' providing advanced caching functionality, with ability to download map regions for offline use. -version: 10.0.0 +version: 10.1.0 repository: https://github.com/JaffaKetchup/flutter_map_tile_caching issue_tracker: https://github.com/JaffaKetchup/flutter_map_tile_caching/issues diff --git a/windowsApplicationInstallerSetup.iss b/windowsApplicationInstallerSetup.iss index 65baa309..53b7ccb7 100644 --- a/windowsApplicationInstallerSetup.iss +++ b/windowsApplicationInstallerSetup.iss @@ -1,7 +1,7 @@ ; Script generated by the Inno Setup Script Wizard #define MyAppName "FMTC Demo" -#define MyAppVersion "for 10.0.0" +#define MyAppVersion "for 10.1.0" #define MyAppPublisher "JaffaKetchup Development" #define MyAppURL "https://github.com/JaffaKetchup/flutter_map_tile_caching" #define MyAppSupportURL "https://github.com/JaffaKetchup/flutter_map_tile_caching/issues" From b21bf370cef740c240f45d421fa9497bace156a0 Mon Sep 17 00:00:00 2001 From: JaffaKetchup Date: Sat, 11 Jan 2025 21:46:25 +0000 Subject: [PATCH 4/6] Bumped SDK & Flutter requirements to align with FM v8 --- pubspec.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pubspec.yaml b/pubspec.yaml index 4b8d34f0..c68a8188 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -23,8 +23,8 @@ platforms: windows: environment: - sdk: ">=3.3.0 <4.0.0" - flutter: ">=3.19.0" + sdk: ">=3.6.0 <4.0.0" + flutter: ">=3.27.0" dependencies: async: ^2.11.0 From 8a40457adff87de75f55b36bbac1640786325b88 Mon Sep 17 00:00:00 2001 From: JaffaKetchup Date: Sun, 2 Feb 2025 21:42:10 +0000 Subject: [PATCH 5/6] Finalized changes --- CHANGELOG.md | 2 +- pubspec.yaml | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2c5325fb..433138db 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -18,7 +18,7 @@ Many thanks to my sponsors, no matter how much or how little they donated. Spons # Changelog -## [10.1.0] - 2025/XX/XX +## [10.1.0] - 2025/02/02 * Added support for flutter_map v8 diff --git a/pubspec.yaml b/pubspec.yaml index c68a8188..8b2d8ec4 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -33,8 +33,7 @@ dependencies: flat_buffers: ^23.5.26 flutter: sdk: flutter - flutter_map: - git: https://github.com/fleaflet/flutter_map.git + flutter_map: ^8.0.0 http: ^1.2.2 latlong2: ^0.9.1 meta: ^1.15.0 From 5876eaa3ec8e5ef2fb96cbfa368dd2f1b873ec95 Mon Sep 17 00:00:00 2001 From: JaffaKetchup Date: Sun, 2 Feb 2025 21:45:27 +0000 Subject: [PATCH 6/6] Fixed GitHub Workflow --- .github/workflows/main.yml | 22 ---------------------- 1 file changed, 22 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 1a06f7f2..7b569be7 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -8,28 +8,6 @@ concurrency: cancel-in-progress: true jobs: - score-package: - name: "Score Package" - runs-on: ubuntu-latest - steps: - - name: Checkout Repository - uses: actions/checkout@v4 - - name: Run Dart Package Analyser - uses: axel-op/dart-package-analyzer@master - id: analysis - with: - githubToken: ${{ secrets.GITHUB_TOKEN }} - - name: Check Package Scores - env: - TOTAL: ${{ steps.analysis.outputs.total }} - TOTAL_MAX: ${{ steps.analysis.outputs.total_max }} - run: | - if (( $TOTAL < $TOTAL_MAX )) - then - echo Package score less than available score. Improve the score! - exit 1 - fi - analyse-code: name: "Analyse Code" runs-on: ubuntu-latest