Created
September 16, 2014 14:47
-
-
Save jpotts18/171ed6356c4f8db2da29 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// viewDidLoad | |
AGSGDBGeodatabase *gdb = [[AGSGDBGeodatabase alloc] initWithPath:[self getDBPath] error:&error]; | |
for (AGSFeatureTable* fTable in gdb.featureTables) { | |
if ([fTable.tableName isEqual: @"wwGrid"]){ | |
continue; | |
} | |
if ([fTable hasGeometry]) { | |
AGSFeatureTableLayer *featureTableLayer = [[AGSFeatureTableLayer alloc] initWithFeatureTable:fTable]; | |
NSLog(@"Layer => %@ visible => %i", fTable.tableName, featureTableLayer.visible); | |
[self.mapView addMapLayer:featureTableLayer]; | |
} | |
} | |
// helper methods | |
- (void)copyDatabaseToDocuments | |
{ | |
NSFileManager *fileManager = [NSFileManager defaultManager]; | |
NSError *error; | |
NSString *dbPath = [self getDBPath]; | |
BOOL success = [fileManager fileExistsAtPath:dbPath]; | |
if(!success){ | |
NSString *defaultDBPath = [[[NSBundle mainBundle] resourcePath] stringByAppendingPathComponent:@GDB_PATH]; | |
success = [fileManager copyItemAtPath:defaultDBPath toPath:dbPath error:&error]; | |
if (!success){ | |
NSAssert1(0, @"Failed to create writable database file with message %@", [error localizedDescription]); | |
} | |
} | |
} | |
- (NSString *) getDBPath | |
{ | |
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); | |
NSString *documentsDir = [paths objectAtIndex:0]; | |
return [documentsDir stringByAppendingString:@GDB_PATH]; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment