【问题标题】:Using offline database in Route-Me在 Route-Me 中使用离线数据库
【发布时间】:2011-07-05 23:57:51
【问题描述】:

我正在尝试使用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 显然根本没有读取文件;即使我完全删除数据库,我也会得到相同的日志输出。 IOW,问题可能是由于 Route-Me 无法找到该文件。任何帮助将不胜感激!

【问题讨论】:

  • 您能否向我发送有关如何添加图块图像以路由我的参考,因为我被这个问题困住了,现在我有了地图图像并且我设法将其添加到图块中,但我怎么能将其添加到地图中。谢谢

标签: iphone objective-c route-me


【解决方案1】:

查看 - (RMTileImage *)tileImage:(RMTile)tile from MapView->Map->Tile Source

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

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

到:

NSInteger y    = tile.y;

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

-- 兰迪

【讨论】:

  • 哇!你的补丁成功了!整个地图现在可以正常显示了!非常感谢!如果你愿意,你应该登录 GitHub(或者如果你还没有注册),然后 fork the file 并提交一个拉取请求,这样其他任何人都不会遇到问题!再次感谢! :D
  • 它对我不起作用,我仍然得到灰色视图。请帮忙
  • 这是一个非常古老的补丁 (2011)。我不再使用 main route-me fork,因为它似乎没有采取任何行动(最后一次提交是 2012 年)。 tilemill 在他们的 fork 上所做的工作是更近期且非常活跃的。看看:github.com/mapbox/mapbox-ios-sdk
【解决方案2】:

我昨天确实在为这个问题苦苦挣扎。

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

Randy 突出显示的那一行

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

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

我遇到了完全相同的问题,按照 Randy 上面的建议进行更改即可。

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

【讨论】:

  • 欢迎来到 Stack Overflow;谢谢您的意见!这是一个很棒的网站,所以我希望你留下来并做出贡献。 如果的话,我会永远自己解决这个问题!我知道你对这个过程中涉及的所有应用程序的意思;我花了大约三天的时间才弄清楚谁在哪里做什么,哈哈。
【解决方案3】:

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

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

希望这可以帮助遇到麻烦的人。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2023-04-10
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多