Hi All,
Currently I'm able to create geodatabase from single feature server and able to perform operations on it and able to sync back to arches server.
But if we want to create single geodatabase from multiple server's how we can achieve that?
Below is the code which I'm using to create single geodatabase.
self.generateParameters = [[AGSGDBGenerateParameters alloc]initWithExtent:envelope layerIDs:@[@1,@3]];
self.generateParameters.syncModel = AGSGDBSyncModelPerLayer;
AGSGDBLayerQuery *gdbQuery = [[AGSGDBLayerQuery alloc]init];
NSMutableArray *gdbQueries = [[NSMutableArray alloc]init];
gdbQuery.layerID = 2;
NSArray *detectionArray = [ModelFacade listOfDetectionsForWorkOrder:self.currentWorkOrder.orderID];
self.allDetectionsList = [NSArray arrayWithArray:detectionArray];
NSMutableString *expressionString = [[NSMutableString alloc] initWithString:@"TREE_DETECTION_ID IN("];
for (Detection *detection in detectionArray)
{
[expressionString appendString:@"'"];
[expressionString appendString:stringForObject(detection.tID)];
[expressionString appendString:@"'"];
[expressionString appendString:@","];
}
[expressionString deleteCharactersInRange:NSMakeRange([expressionString length]-1, 1)];
[expressionString appendString:@")"];
gdbQuery.whereClause = expressionString;
[gdbQueries addObject:gdbQuery];
// self.generateParameters.outSpatialReference = self.mapView.spatialReference;
self.generateParameters.queries = gdbQueries;
//Create the geodatabase task
self.geodatabaseTask =
[[AGSGDBSyncTask alloc] initWithURL:[NSURL URLWithString:kFeatureServiceURL] credential:nil];
self.geodatabaseTask.loadCompletion = ^(NSError *error){
if (error)
{
dispatch_async(dispatch_get_main_queue(), ^{
[weakSelf.progressHUD hide:YES];
[weakSelf.navigationItem setHidesBackButton:NO animated:YES];
weakSelf.downloadButton.userInteractionEnabled = YES;
});
NSLog(@"AGSGDBSyncTask failed to load!");
}
else
{
NSString * geoDatabasePath = [NSString stringWithFormat:@"Library/Application Support/QuantamInspect/%@",workOrder.orderName];
NSString *geoDatabaseFilePath = [NSHomeDirectory() stringByAppendingPathComponent:geoDatabasePath];
if (![[NSFileManager defaultManager] fileExistsAtPath:geoDatabaseFilePath])
[[NSFileManager defaultManager] createDirectoryAtPath:geoDatabaseFilePath withIntermediateDirectories:NO attributes:nil error:&error];
//Generate the geodatabase (with parameters)
weakSelf.geodatabaseJob =
[weakSelf.geodatabaseTask
generateGeodatabaseWithParameters:weakSelf.generateParameters
downloadFolderPath:geoDatabaseFilePath
useExisting:NO
//Status block - provides feedback form the asynchronous job
status:^(AGSResumableTaskJobStatus status, NSDictionary *userInfo){
NSNumber* totalBytesDownloaded = userInfo[@"AGSDownloadProgressTotalBytesDownloaded"];
NSNumber* totalBytesExpected = userInfo[@"AGSDownloadProgressTotalBytesExpected"];
if(totalBytesDownloaded!=nil && totalBytesExpected!=nil){
double dPercentage = (double)([totalBytesDownloaded doubleValue]/[totalBytesExpected doubleValue]);
weakSelf.progressHUD.detailsLabelText = [NSString stringWithFormat:@"%.0f %@",dPercentage*100, @"%"];
}
}
//Completion block - executes when the job has completed.
//This code creates a AGSFeatureTableLayer from the first table in the
//returned geodatabase.
completion:^(AGSGDBGeodatabase *geodatabase, NSError *error){
}
];
}
};
self.geodatabaseTask =
[[AGSGDBSyncTask alloc] initWithURL:[NSURL URLWithString:kFeatureServiceURL] credential:nil];
By this we are providing server url.
Please see enclose list of server. From that I want to create geodatabse using 2-3 server's.
Please let me know if anyone has any solution or question on this.
Thanks
Solved! Go to Solution.
Hi Hrishikesh,
Afaik, it´s not possible to join multiple services into a single client-side geodatabase. What we´ve done in our project is simply generating multiple geodatabases on the client. On top of this, we´ve built a small abstraction layer hiding the fact that there actually are multiple geodatabases in the bottom, making it all easy to work with.
In your case it seems all feature feature services reside on the same physical server. Is it possible to publish a new, single feature service containing all the feature layers required by your app?
Kristoffer
Hi Hrishikesh,
Afaik, it´s not possible to join multiple services into a single client-side geodatabase. What we´ve done in our project is simply generating multiple geodatabases on the client. On top of this, we´ve built a small abstraction layer hiding the fact that there actually are multiple geodatabases in the bottom, making it all easy to work with.
In your case it seems all feature feature services reside on the same physical server. Is it possible to publish a new, single feature service containing all the feature layers required by your app?
Kristoffer
Hey Kristoffer,
Thank you for your reply.
Yes we can publish a new service which will have all services using by my application.
But in future if any new service get added then in that case we have to publish the updated service. Correct me if my understanding is wrong.
Or is there any other way to tackle this situation?
You´re right - new feature layers need to be added to the "all-layers-service", but afaik, you´d still need to re-genereate the offline geodatabase, as the layerIds you´d like to sync are specified in the AGSGDBGenerateParameters.
Question is, what you´d like to happen. As new services are added, you´d like them to appear in the app? Even if you were able to keep multiple feature services in one offline base, you´d still need to re-create the offline geodatabase. Thus, perhaps it then actually makes more sense to keep the services separated, adding new services (and corresponding offline geodatabases) as they are published.
Hey How can we create geodatabase from multiple feature server's in iOSKristoffer,
Thank you for your reply. It really help me to understand in more details.
Thanks,
Hrishikesh Pol.