Closed tomquas closed 1 year ago
Thanks for a good proposal!
Box
interface (and GeoBox
+ ProjBox
implementations) should have method to calculate center point as suggested.
Related to this use case there is also the following method (along with zoomIn
and zoomOut
) in Scalable2i
:
@override
Scalable2i zoomTo(int zoom) {
assert(zoom >= 0, 'Zoom must be >= 0');
if (this.zoom == zoom) {
return this;
}
final shift = zoom - this.zoom;
return shift > 0
? Scalable2i(
zoom: zoom,
x: x << shift,
y: y << shift,
)
: Scalable2i(
zoom: zoom,
x: x >> shift.abs(),
y: y >> shift.abs(),
);
}
A sample:
const tile = Scalable2i(zoom: 2, x: 1, y: 1);
print(tile.zoomTo(3)); // zoom=3 x=2 y=2
print(tile.zoomTo(4)); // zoom=4 x=4 y=4
However even if this returns a tile in a zoomed level that is inside the tile in the original zoom, the returned tile is not in center of original tile (as maybe needed).
For a tile (zoom=2 x=1 y=1) and target zoom=4, this gives (zoom=4 x=4 y=4) even if the range of target tiles inside the source tile would be (zoom=4 x=4..7 y=4..7).
So yes, either Box
could have that center point method and it would have other use cases too.
Or for this use case geographic tile matrix sets new methods like drafted in the issue #158.
Not related to this use case, but similar proposal is also in issue #135.
oh cool, thanks for the hint; i wasn't aware of zoomTo. an alignment parameter as specified in #158 sounds like the way to solve this.
New geobase version 0.4.0 started with prelese 0.4.0-dev.0 implementing #158.
Implemented in version 0.4.0.
hi, first: thank you very much for this great addition to the dart world.
i am mapping tile coordinates from one zoom level to another like this:
now if instead i could say .center2D instead of .corners2D.first my subequent calculations would be easier.
should Box or GeoBox get a .center2d method?