ios - HERE MAPS (iOS Swift SDK) 如何识别要加载的 Tile?
问题描述
我试图理解 Tile 的概念并用它来呈现光栅。
我已经在 github 上看到了一个例子,其中一张熊猫的图片再次被加载。
我有以下 RasterLayer:
dimensions : 944, 1014, 957216 (nrow, ncol, ncell)
resolution : 0.0136, 0.00857 (x, y)
extent : 2.00348, 15.79388, 46.99609, 55.08617 (xmin, xmax, ymin, ymax)
crs : +proj=longlat +datum=WGS84 +no_defs +ellps=WGS84 +towgs84=0,0,0
我想将其显示为 HERE 地图上的叠加层。
Tile 是完成这项任务的正确方法吗?
例如,我可以将我的栅格划分为 256x256 像素的 png 文件。我只是不明白如何选择与屏幕上显示的区域相对应的正确一个。
我试图找到任何描述并打印出来自
func mapTileLayer(_ mapTileLayer: NMAMapTileLayer,
requestDataForTileAt x: UInt, _ y: UInt, _ zoomLevel: UInt) -> Data {
print(x)
print(y)
print(zoomLevel)
print("-------------------")
if let pandaImg = UIImage(named: "panda.png") {
if let data = pandaImg.pngData()?
.base64EncodedData(options: Data.Base64EncodingOptions.lineLength64Characters) {
if let base64Image = String(data: data, encoding: String.Encoding.utf8) {
if let decodedData = Data(base64Encoded: base64Image,
options: Data.Base64DecodingOptions.ignoreUnknownCharacters) {
return decodedData
}
}
}
}
但仍然不明白它是如何工作的,因为打印出来是这样的:
-------------------
569025
346855
20
<NMAGeoCoordinates: 0x2823f47e0; latitude = -90.000000; longitude = -180.000000; altitude = -340282346638528859811704183484516925440.000000>
-------------------
569026
346855
20
<NMAGeoCoordinates: 0x2823f53a0; latitude = -90.000000; longitude = -180.000000; altitude = -340282346638528859811704183484516925440.000000>
-------------------
569027
346855
20
<NMAGeoCoordinates: 0x2823e7940; latitude = -90.000000; longitude = -180.000000; altitude = -340282346638528859811704183484516925440.000000>
-------------------
569023
346855
20
<NMAGeoCoordinates: 0x2823f6120; latitude = -90.000000; longitude = -180.000000; altitude = -340282346638528859811704183484516925440.000000>
有没有办法识别显示的区域以便我选择正确的瓷砖?还是有其他方法来呈现叠加层?我也尝试使用地图标记,但有很多(光栅->地图制作者),所以 iPhone 的内存消耗增加了。