Skip to content

Instantly share code, notes, and snippets.

@jpotts18
Created September 16, 2014 14:47
Show Gist options
  • Save jpotts18/171ed6356c4f8db2da29 to your computer and use it in GitHub Desktop.
Save jpotts18/171ed6356c4f8db2da29 to your computer and use it in GitHub Desktop.
// 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