繁体   English   中英

在 Route-Me 中使用离线数据库

[英]Using offline database in Route-Me

我正在尝试使用Route-Me使用离线 MBTiles 数据库。 为此,我使用了 Landez ,而这又依赖于MBUtil

现在,我得到的只是一个灰色的屏幕,其中的引脚位于正确的位置。 以下是打印到控制台的内容:

initializing memory cache <RMMemoryCache: 0x4e42e50> with capacity 32
Opening database at /Users/chrislong/Library/Application Support/iPhone Simulator/4.3.2/Applications/E53BC885-1B02-4B06-B45B-408EB9A147DE/Documents/MapOpenStreetMap.sqlite
Map contents initialised. view: MapView at 0,0-320,411 tileSource <RMCachedTileSource: 0x4e428b0> renderer <RMCoreAnimationRenderer: 0x4e13dc0>
initializing memory cache <RMMemoryCache: 0x5929930> with capacity 32
Opening database at /Users/chrislong/Library/Application Support/iPhone Simulator/4.3.2/Applications/E53BC885-1B02-4B06-B45B-408EB9A147DE/Documents/MapMBTilestiles.mbtiles.sqlite
Warning: I could not find the column named 'tile_data'.
Warning: I could not find the column named 'tile_data'.
Warning: I could not find the column named 'tile_data'.
Warning: I could not find the column named 'tile_data'.
Map contents initialised. view: MapView at 0,0-320,411 tileSource <RMCachedTileSource: 0x592a400> renderer <RMCoreAnimationRenderer: 0x5925770>

值得注意的是,该文件名为tiles.mbtiles ,而不是MapMBTilestiles.mbtiles.sqlite ,并且存储在包的根目录中,而不是Documents文件夹中。

这是我用来制作mapView和加载数据库的代码:

CLLocationCoordinate2D center = {50, 50};
self.mapView = [[[RMMapView alloc] initWithFrame:self.view.frame] autorelease];
self.mapView.backgroundColor = [UIColor blackColor];
self.mapView.delegate = self;

NSURL *tilePath = [[NSBundle mainBundle] URLForResource:@"tiles" withExtension:@"mbtiles"];
RMMBTilesTileSource *tiles = [[[RMMBTilesTileSource alloc] initWithTileSetURL:tilePath] autorelease];
[self.mapView.contents removeAllCachedImages];
self.mapView.contents = [[[RMMapContents alloc] initWithView:self.mapView tilesource:tiles centerLatLon:center zoomLevel:0.0 maxZoomLevel:[tiles maxZoom] minZoomLevel:[tiles minZoom] backgroundImage:nil] autorelease];
[self addMarkers];

Route-Me 显然根本没有读取文件; 即使我完全删除数据库,我也会得到相同的日志 output。 IOW,问题可能是由于 Route-Me 无法找到该文件。 任何帮助,将不胜感激!

签出 - (RMTileImage *)tileImage:(RMTile)tile 来自 MapView->Map->Tile Source

我在使用 map2sqlite 生成的 sqlite db 时遇到了一些问题,直到我更改了行:

NSInteger y    = pow(2, zoom) - tile.y - 1;

至:

NSInteger y    = tile.y;

我现在正在使用 tilemill 生成的数据库,所以我没有进一步研究它,但如果我是你,我会扔进一些调试语句,看看它在寻找什么瓷砖与你的数据库中的瓷砖布局是什么. 我认为这可能与 mbtiles 平铺顺序与 osm 的平铺顺序有关。

——兰迪

我昨天实际上与这个问题搏斗。

那里似乎有两种不同的图块格式,google xyz 和 Openstreetmap 使用的 TMS。

Randy 突出显示的线条

NSInteger y    = pow(2, zoom) - tile.y - 1;

正在将一个转换为另一个。 例如,我正在使用 Maperative 构建我的 map,然后将其导出到目录中的图块,最后使用 mb-util 生成tiles.mbtiles 文件。

而且我遇到了完全相同的问题,进行上面 Randy 建议的更改并且它有效。

但是最终我写了一个 php 脚本来重命名瓷砖的文件名是正确的。 老实说,我还没有完全弄清楚哪些软件以什么格式导出。 我认为 mbtiles 应该是 TMS,这意味着 route-me 是 xyz,但我可能错了。

我在上面进行了更改,但在将 map 居中时遇到了一些问题。 经过一段时间的工作后,我将您上面提到的行更改为:

NSInteger y = tile.y - (pow(4, ((zoom / 2) - 1)));

希望这可以帮助任何有麻烦的人。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM