Authored by Justin R. Miller

fixes #122: added RMMBTilesSource centerCoordinate & centerZoom

... ... @@ -57,10 +57,18 @@
/** @name Querying Tile Source Information */
/** Any available HTML-formatted map legend data for the tile source, suitable for display in a UIWebView. */
- (NSString *)legend;
/** A suggested starting center coordinate for the map layer. */
- (CLLocationCoordinate2D)centerCoordinate;
/** A suggested starting center zoom level for the map layer. */
- (float)centerZoom;
/** Returns YES if the tile source provides full-world coverage; otherwise, returns NO. */
- (BOOL)coversFullWorld;
/** Any available HTML-formatted map legend data for the tile source, suitable for display in a UIWebView. */
- (NSString *)legend;
@end
... ...
... ... @@ -248,18 +248,6 @@
return bounds;
}
- (BOOL)coversFullWorld
{
RMSphericalTrapezium ownBounds = [self latitudeLongitudeBoundingBox];
RMSphericalTrapezium defaultBounds = kMBTilesDefaultLatLonBoundingBox;
if (ownBounds.southWest.longitude <= defaultBounds.southWest.longitude + 10 &&
ownBounds.northEast.longitude >= defaultBounds.northEast.longitude - 10)
return YES;
return NO;
}
- (NSString *)legend
{
__block NSString *legend;
... ... @@ -281,6 +269,57 @@
return legend;
}
- (CLLocationCoordinate2D)centerCoordinate
{
__block CLLocationCoordinate2D centerCoordinate = CLLocationCoordinate2DMake(0, 0);
[queue inDatabase:^(FMDatabase *db)
{
FMResultSet *results = [db executeQuery:@"select value from metadata where name = 'center'"];
[results next];
if ([results stringForColumn:@"value"] && [[[results stringForColumn:@"value"] componentsSeparatedByString:@","] count] >= 2)
centerCoordinate = CLLocationCoordinate2DMake([[[[results stringForColumn:@"value"] componentsSeparatedByString:@","] objectAtIndex:1] doubleValue],
[[[[results stringForColumn:@"value"] componentsSeparatedByString:@","] objectAtIndex:0] doubleValue]);
[results close];
}];
return centerCoordinate;
}
- (float)centerZoom
{
__block CGFloat centerZoom = [self minZoom];
[queue inDatabase:^(FMDatabase *db)
{
FMResultSet *results = [db executeQuery:@"select value from metadata where name = 'center'"];
[results next];
if ([results stringForColumn:@"value"] && [[[results stringForColumn:@"value"] componentsSeparatedByString:@","] count] >= 3)
centerZoom = [[[[results stringForColumn:@"value"] componentsSeparatedByString:@","] objectAtIndex:2] floatValue];
[results close];
}];
return centerZoom;
}
- (BOOL)coversFullWorld
{
RMSphericalTrapezium ownBounds = [self latitudeLongitudeBoundingBox];
RMSphericalTrapezium defaultBounds = kMBTilesDefaultLatLonBoundingBox;
if (ownBounds.southWest.longitude <= defaultBounds.southWest.longitude + 10 &&
ownBounds.northEast.longitude >= defaultBounds.northEast.longitude - 10)
return YES;
return NO;
}
- (void)didReceiveMemoryWarning
{
NSLog(@"*** didReceiveMemoryWarning in %@", [self class]);
... ...