mousebird-consulting-inc / WhirlyGlobe

WhirlyGlobe Development
Other
828 stars 254 forks source link

Vector tiles #380

Closed sam899 closed 8 years ago

sam899 commented 9 years ago

I'm trying to implement vector tiles from Tilemill using the following guide: http://mousebirdconsulting.blogspot.co.uk/2014/03/vector-maps-introduction.html

However, I'm getting multiple compile issues trying to compile the carto_vector_dice project Main issues include:

Is there a more up to date guide for generating vector tiles that I've missed, or any instructions for setting up the carto_vector_dice project?

Thanks!

mousebird commented 9 years ago

That's using the old Maply Vector Tiles approach. These days I'd recommend using Mapbox Vector Tiles in combination with either the Mapnik XML or a Mapbox GL Style. The former is more fully fleshed out, but the latter is where things are going in the future.

I believe you can build a vector tiles MBTiles file with Mapbox Studio (aka TileMill2).

sam899 commented 9 years ago

Great, thanks. I'll give it a go!

In regards to using vector maps, I'm using cocoapods on the develop branch and get a build error when trying to use the vector classes (eg MaplyMapnikVector, MapnikStyleSet)

I also see in WhirlyGlobeComponent.h that the vector headers arern't included when using cocoapods:

#ifdef NOTPODSPECWG
#import <vector_tiles/MaplyVectorTiles.h>
#import <vector_tiles/MaplyMapnikVectorTiles.h>
#import <vector_tiles/MapnikStyleSet.h>
#import <vector_tiles/MapboxMultiSourceTileInfo.h>
#import <vector_tiles/MapboxVectorStyleSet.h>
#import <vector_tiles/MapboxVectorStyleBackground.h>
#endif

Is there something else that's needed to use vectors with cocoapods, or isnt this supported yet?

mousebird commented 9 years ago

Mapbox Vector Tiles and Cocoapods aren't compatible, I'm afraid. There's a problem with the standard Google Protobuffer libraries pod. You'll need to use the source distribution for WhirlyGlobe-Maply if you want MVT.

sam899 commented 9 years ago

I've given the new Mapbox vector tiles a go, but having some issues on the develop branch. Firstly, the Mapbox streets vectors overlay layer example doesnt seem to work.

However, I tried to load a local mbtiles file with the following code:

NSString *mapFile = [[NSBundle mainBundle] pathForResource:@"Map-vector" ofType:@"mbtiles"];
NSString *styleFile = [[NSBundle mainBundle] pathForResource:@"Map-vector-style" ofType:@"json"];

MapnikStyleSet *style = [[MapnikStyleSet alloc] initForViewC:globeViewC];
[style loadJsonFile:styleFile];
[style generateStyles];

MaplyMBTileSource *tileSource = [[MaplyMBTileSource alloc] initWithMBTiles:mapFile];
MaplyMapnikVectorTiles *vecTiles = [[MaplyMapnikVectorTiles alloc] initWithMBTiles:tileSource style:style viewC:globeViewC];

MaplyQuadPagingLayer *pageLayer = [[MaplyQuadPagingLayer alloc] initWithCoordSystem:[[MaplySphericalMercator alloc] initWebStandard] delegate:vecTiles];
pageLayer.numSimultaneousFetches = 6;
pageLayer.flipY = false;
pageLayer.importance = 1024*1024*2;
pageLayer.useTargetZoomLevel = true;
pageLayer.singleLevelLoading = true;
[globeViewC addLayer:pageLayer];

It crashes in the following method:

- (void)startFetchForTile:(MaplyTileID)tileID forLayer:(MaplyQuadPagingLayer *)layer {
    ...
    if([tileData isCompressed]) {
        ....
}

[OS_dispatch_data isCompressed]: unrecognized selector sent to instance 0x7fdbb2358880

Any ideas?

mousebird commented 9 years ago

I noticed the style wasn't getting loaded. The path had changed. I fixed that, but I'm not seeing all the data showing up. The new GL styles can be something of a moving target.

It looks like you're not loading the NSData category that implements isCompressed. Is that crash in the test app or in your own app?

mousebird commented 9 years ago

Huh, it looks like Mapbox has rolled back some of the v8 syntax, so my parser no longer works.

I'm gonna back off on that and wait till they're finished messing with it.

mousebird commented 8 years ago

Marked as a feature request because this is related to the Mapbox GL Style.

mousebird commented 8 years ago

I believe we're up to date with the current version of the Mapbox GL style. What's there is only partially implemented, however.