Open jbouffard opened 6 years ago
You can use the following instead of apply methods:
mt.extentToBounds(mt.keyToExtent(key))
However, probably it makes sense to add keyToBounds
function.
Makes more sense to me to add a GridBounds.apply method that takes a SpatialKey. There is no information necessary from a LayoutDefinition or a MapKeyTransform to convert a SpatialKey to a GridBounds, it can be constructed just with the information of the SpatialKey.
I wold type this generally as GridBounds.apply [K: SpatialComponent]
Just to be explicit:
val key: SpatialKey = ???
val e: Extent = mt.keyToExtent(key) // Map Extent covered by the key
val gb: GridBounds = mt.extentToBounds(e) // Key bounds covered by extent
So there is much more direct way to get this answer:
GridBounds(colMin = key.col, rowMin = key.row, colMin = key.col, rowMin = key.row)
Whats really unfortunate is that we use GridBounds
to represent both bounds in tile space and pixel space which makes the above transformation pretty ambiguous since it could be either in this context.
The current conversion from a
SpatialKey
toGridBounds
is kinda awkward as it forces the user to use twoapply
methods consecutively:mapTransform(mapTransform(key))
. This is becauseMapKeyTransform
lacks a direct conversion betweenSpatialKey
s andGridBounds
. Adding akeyToGridBounds
method toMapKeyTransform
will not only make things look nicer, but it'll also make the code easier to read and reason about.