@@ -6,23 +6,24 @@ part of 'shared.dart';
6
6
class TilesGenerator {
7
7
static Future <void > rectangleTiles (Map <String , dynamic > input) async {
8
8
final SendPort sendPort = input['sendPort' ];
9
- final LatLngBounds bounds = input['rectOutline' ];
10
- final int minZoom = input['minZoom' ];
11
- final int maxZoom = input['maxZoom' ];
12
- final Crs crs = input['crs' ];
13
- final CustomPoint <double > tileSize = input['tileSize' ];
9
+ final DownloadableRegion region = input['region' ];
10
+ final originalRegion = region.originalRegion as RectangleRegion ;
11
+
12
+ final tileSize = _getTileSize (region);
13
+ final northWest = originalRegion.bounds.northWest;
14
+ final southEast = originalRegion.bounds.southEast;
14
15
15
16
final recievePort = ReceivePort ();
16
17
sendPort.send (recievePort.sendPort);
17
18
final requestQueue = StreamQueue (recievePort);
18
19
19
- for (int zoomLvl = minZoom; zoomLvl <= maxZoom; zoomLvl++ ) {
20
- final CustomPoint <num > nwCustomPoint = crs
21
- .latLngToPoint (bounds. northWest, zoomLvl.toDouble ())
20
+ for (int zoomLvl = region. minZoom; zoomLvl <= region. maxZoom; zoomLvl++ ) {
21
+ final CustomPoint <num > nwCustomPoint = region. crs
22
+ .latLngToPoint (northWest, zoomLvl.toDouble ())
22
23
.unscaleBy (tileSize)
23
24
.floor ();
24
- final CustomPoint <num > seCustomPoint = crs
25
- .latLngToPoint (bounds. southEast, zoomLvl.toDouble ())
25
+ final CustomPoint <num > seCustomPoint = region. crs
26
+ .latLngToPoint (southEast, zoomLvl.toDouble ())
26
27
.unscaleBy (tileSize)
27
28
.ceil () -
28
29
const CustomPoint (1 , 1 );
@@ -47,11 +48,10 @@ class TilesGenerator {
47
48
// Theoretically, this could have been done using the same method as `lineTiles`, but `lineTiles` was built after this algorithm and this makes more sense for a circle
48
49
49
50
final SendPort sendPort = input['sendPort' ];
50
- final List <LatLng > circleOutline = input['circleOutline' ];
51
- final int minZoom = input['minZoom' ];
52
- final int maxZoom = input['maxZoom' ];
53
- final Crs crs = input['crs' ];
54
- final CustomPoint <double > tileSize = input['tileSize' ];
51
+ final DownloadableRegion region = input['region' ];
52
+
53
+ final tileSize = _getTileSize (region);
54
+ final circleOutline = region.originalRegion.toOutline ();
55
55
56
56
final recievePort = ReceivePort ();
57
57
sendPort.send (recievePort.sendPort);
@@ -60,11 +60,11 @@ class TilesGenerator {
60
60
// Format: Map<z, Map<x, List<y>>>
61
61
final Map <int , Map <int , List <int >>> outlineTileNums = {};
62
62
63
- for (int zoomLvl = minZoom; zoomLvl <= maxZoom; zoomLvl++ ) {
63
+ for (int zoomLvl = region. minZoom; zoomLvl <= region. maxZoom; zoomLvl++ ) {
64
64
outlineTileNums[zoomLvl] = < int , List <int >> {};
65
65
66
66
for (final LatLng node in circleOutline) {
67
- final CustomPoint <num > tile = crs
67
+ final CustomPoint <num > tile = region. crs
68
68
.latLngToPoint (node, zoomLvl.toDouble ())
69
69
.unscaleBy (tileSize)
70
70
.floor ();
@@ -146,18 +146,19 @@ class TilesGenerator {
146
146
}
147
147
148
148
final SendPort sendPort = input['sendPort' ];
149
- final List <List <LatLng >> rects = input['lineOutline' ];
150
- final int minZoom = input['minZoom' ];
151
- final int maxZoom = input['maxZoom' ];
152
- final Crs crs = input['crs' ];
153
- final CustomPoint <double > tileSize = input['tileSize' ];
149
+ final DownloadableRegion region = input['region' ];
150
+
151
+ final tileSize = _getTileSize (region);
152
+ final lineOutline = (region.originalRegion as LineRegion ).toOutlines (1 );
154
153
155
154
final recievePort = ReceivePort ();
156
155
sendPort.send (recievePort.sendPort);
157
156
final requestQueue = StreamQueue (recievePort);
158
157
159
- for (double zoomLvl = minZoom.toDouble (); zoomLvl <= maxZoom; zoomLvl++ ) {
160
- for (final List <LatLng > rect in rects) {
158
+ for (double zoomLvl = region.minZoom.toDouble ();
159
+ zoomLvl <= region.maxZoom;
160
+ zoomLvl++ ) {
161
+ for (final List <LatLng > rect in lineOutline) {
161
162
final LatLng rrBottomLeft = rect[0 ];
162
163
final LatLng rrBottomRight = rect[1 ];
163
164
final LatLng rrTopRight = rect[2 ];
@@ -176,27 +177,31 @@ class TilesGenerator {
176
177
rrBottomRight.longitude,
177
178
];
178
179
179
- final CustomPoint <num > rrNorthWest =
180
- crs.latLngToPoint (rrTopLeft, zoomLvl).unscaleBy (tileSize).floor ();
181
- final CustomPoint <num > rrNorthEast =
182
- crs.latLngToPoint (rrTopRight, zoomLvl).unscaleBy (tileSize).ceil () -
183
- const CustomPoint (1 , 0 );
184
- final CustomPoint <num > rrSouthWest = crs
180
+ final CustomPoint <num > rrNorthWest = region.crs
181
+ .latLngToPoint (rrTopLeft, zoomLvl)
182
+ .unscaleBy (tileSize)
183
+ .floor ();
184
+ final CustomPoint <num > rrNorthEast = region.crs
185
+ .latLngToPoint (rrTopRight, zoomLvl)
186
+ .unscaleBy (tileSize)
187
+ .ceil () -
188
+ const CustomPoint (1 , 0 );
189
+ final CustomPoint <num > rrSouthWest = region.crs
185
190
.latLngToPoint (rrBottomLeft, zoomLvl)
186
191
.unscaleBy (tileSize)
187
192
.ceil () -
188
193
const CustomPoint (0 , 1 );
189
- final CustomPoint <num > rrSouthEast = crs
194
+ final CustomPoint <num > rrSouthEast = region. crs
190
195
.latLngToPoint (rrBottomRight, zoomLvl)
191
196
.unscaleBy (tileSize)
192
197
.ceil () -
193
198
const CustomPoint (1 , 1 );
194
199
195
- final CustomPoint <num > srNorthWest = crs
200
+ final CustomPoint <num > srNorthWest = region. crs
196
201
.latLngToPoint (LatLng (rrAllLat.max, rrAllLon.min), zoomLvl)
197
202
.unscaleBy (tileSize)
198
203
.floor ();
199
- final CustomPoint <num > srSouthEast = crs
204
+ final CustomPoint <num > srSouthEast = region. crs
200
205
.latLngToPoint (LatLng (rrAllLat.min, rrAllLon.max), zoomLvl)
201
206
.unscaleBy (tileSize)
202
207
.ceil () -
0 commit comments