diff --git a/FMDatabase.m b/FMDatabase.m
index 7c8eb88..4d952c7 100644
--- a/FMDatabase.m
+++ b/FMDatabase.m
@@ -702,8 +702,9 @@ - (void)setUseCount:(long)value {
}
}
-- (NSString*) description {
- return [NSString stringWithFormat:@"%@ %d hit(s) for query %@", [super description], useCount, query];
+- (NSString*) description
+{
+ return [NSString stringWithFormat:@"%@ %ld hit(s) for query %@", [super description], useCount, query];
}
diff --git a/FMDatabaseAdditions.m b/FMDatabaseAdditions.m
index 1b357f9..0f8e868 100644
--- a/FMDatabaseAdditions.m
+++ b/FMDatabaseAdditions.m
@@ -58,17 +58,17 @@ - (NSData*)dataForQuery:(NSString*)query, ...; {
//this technique is being implemented as described by Matt Gallagher at
//http://cocoawithlove.com/2009/05/variable-argument-lists-in-cocoa.html
-- (id)executeQuery:(NSString *)sql withArgumentsInArray:(NSArray *)arguments {
-
+- (id)executeQuery:(NSString *)sql withArgumentsInArray:(NSArray *)arguments
+{
id returnObject;
//also need make sure that everything in arguments is an Obj-C object
//or else argList will be the wrong size
NSUInteger argumentsCount = [arguments count];
- char *argList = (char *)malloc(sizeof(id *) * argumentsCount);
+ va_list* argList = malloc(sizeof(id *) * argumentsCount);
[arguments getObjects:(id *)argList];
- returnObject = [self executeQuery:sql arguments:argList];
+ returnObject = [self executeQuery:sql arguments:*argList];
free(argList);
@@ -82,10 +82,10 @@ - (BOOL) executeUpdate:(NSString*)sql withArgumentsInArray:(NSArray *)arguments
//also need make sure that everything in arguments is an Obj-C object
//or else argList will be the wrong size
NSUInteger argumentsCount = [arguments count];
- char *argList = (char *)malloc(sizeof(id *) * argumentsCount);
+ va_list* argList = malloc(sizeof(id *) * argumentsCount);
[arguments getObjects:(id *)argList];
- returnBool = [self executeUpdate:sql arguments:argList];
+ returnBool = [self executeUpdate:sql arguments:*argList];
free(argList);
diff --git a/map2sqlite.m b/map2sqlite.m
index 7fcfffc..f229cd1 100644
--- a/map2sqlite.m
+++ b/map2sqlite.m
@@ -99,7 +99,7 @@
#define NSStringFromRect(r) ([NSString stringWithFormat:@"{x=%1.1f,y=%1.1f,w=%1.1f,h=%1.1f}", (r).origin.x, (r).origin.y, (r).size.width, (r).size.height])
// version of this program
-#define kVersion @"1.0"
+#define kVersion @"2.0"
// mandatory preference keys
#define kMinZoomKey @"map.minZoom"
@@ -126,6 +126,49 @@
* Helper functions
*/
+
+/*
+/// Converts a QuadKey into tile XY coordinates.
+///
+/// QuadKey of the tile.
+/// Output parameter receiving the tile X coordinate.
+/// Output parameter receiving the tile Y coordinate.
+/// Output parameter receiving the level of detail.
+ */
+void QuadKeyToTileXY(const char* quadKey, int* tileX, int* tileY, int* levelOfDetail)
+{
+ *levelOfDetail = strlen(quadKey);
+ *tileX = 0;
+ *tileY = 0;
+
+ for(int i = *levelOfDetail; i > 0; i--)
+ {
+ int mask = 1 << (i - 1);
+ switch (quadKey[*levelOfDetail - i])
+ {
+ case '0':
+ break;
+
+ case '1':
+ *tileX |= mask;
+ break;
+
+ case '2':
+ *tileY |= mask;
+ break;
+
+ case '3':
+ *tileX |= mask;
+ *tileY |= mask;
+ break;
+
+ default:
+ NSLog(@"Invalid QuadKey digit sequence.");
+ }
+ }
+}
+
+
/*
* Calculates the top left coordinate of a tile.
* (assumes OpenStreetmap tiles)
@@ -141,21 +184,26 @@ CGPoint pointForTile(int row, int col, int zoom) {
/*
* Prints usage information.
*/
-void printUsage() {
- NSLog(@"Usage: map2sqlite -db [-mapdir