AnsweredAssumed Answered

How can we create geodatabase from multiple feature server's in iOS

Question asked by HrishiPol on Jun 30, 2015
Latest reply on Jun 30, 2015 by HrishiPol

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

Outcomes