Select to view content in your preferred language

update feature in from text file

1181
7
Jump to solution
11-02-2012 11:33 AM
VIKRANTKRISHNA
Regular Contributor
Sorry about asking bunch of question in one day. I am new in this development area and having some problems in implementing  few things.
I have three feature layers that I need to update in offline mode. On popupsContainerDidFinishViewingPopups method, I am testing the offline status of the device, and if offline then I am writing feature to a text file. There are saperate textfiles for saperate feature layer. Each text file looks like this, basically writing featureset to file.

"geometryType":"esriGeometryPoint","features":[{"geometry":{"x":456050.74480000045,"y":5001363.0892999982,"spatialReference":{"wkid":26915}},"attributes":{"CostToRepair":"500","USNG":"null","OBJECTID":10003,"Latitude":"null","Notes":"null","Longitude":"null","IndicentID":1,"Structure":2,"Category":1}}],"spatialReference":{"wkid":26915}}


The problem I am having is in updating features back from text file. And the way I am doing is this


 -(IBAction)syncInspections:(id)sender{          NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);                  NSString *documentDir = [paths1 objectAtIndex:0];         NSString *readPolyFile = [documentDir stringByAppendingPathComponent:@"InfraPolygonFile.txt"];         NSString *readLineFile = [documentDir stringByAppendingPathComponent:@"InfraLinesFile.txt"];         NSString *readPointFile = [documentDir stringByAppendingPathComponent:@"InfraPointFile.txt"];                  NSString *addedPolygonString = [NSString stringWithContentsOfFile:readPolyFile              encoding:NSUnicodeStringEncoding error:nil] ;                           NSMutableDictionary *polyDict = [addedPolygonString AGSJSONValue];         NSArray *polyArray = [AGSJSONUtility decodeFromDictionary:polyDict                                                              withKey:@"features"                                                            fromClass:[AGSGraphic class]];          if(polyArray.count){          [self.impactPolygon updateFeatures:polyArray];         }                           NSString *addedPointString = [NSString stringWithContentsOfFile:readPointFile e           ncoding:NSUnicodeStringEncoding error:nil] ;                           NSMutableDictionary *pointDict = [addedPointString AGSJSONValue];         NSArray *pointArray = [AGSJSONUtility decodeFromDictionary:pointDict                                                       withKey:@"features"                                                     fromClass:[AGSGraphic class]];         if(pointArray.count){             [self.impactPoints updateFeatures:pointArray];         }                  NSString *addedLinesString = [NSString stringWithContentsOfFile:readLineFile             encoding:NSUnicodeStringEncoding error:nil] ;                           NSMutableDictionary *linesDict = [addedLinesString AGSJSONValue];         NSArray *linesArray = [AGSJSONUtility decodeFromDictionary:linesDict                                                       withKey:@"features"                                                     fromClass:[AGSGraphic class]];         if(linesArray.count){           [self.impactLine updateFeatures:linesArray];         }          }  - (void)featureLayer:(AGSFeatureLayer *)featureLayer operation:(NSOperation *)op didFailFeatureEditsWithError:(NSError *)error {          NSLog(@"%@,%@",error.localizedDescription, featureLayer.name);      }  


It works fine if I am updating any one layer at a time, that is by commenting out updateFeatures method of other two layer. But, if I am updating all the three layers in this method, then its giving me error message  " 'GET' method not supported" randomly for one of the layer.

Is there anything I am doing wrong.

Any suggestion appreciated.
0 Kudos
1 Solution

Accepted Solutions
NimeshJarecha
Esri Regular Contributor
I got your point. We can investigate further if you capture the request/response. You should use tool like Charles Proxy or may be some other tool to capture it. Once, you have that, post it here and we'll look at it.

Regards,
Nimesh

View solution in original post

0 Kudos
7 Replies
NimeshJarecha
Esri Regular Contributor
Could you please intercept your request and response for all three layers and post here?

Regards,
Nimesh
0 Kudos
VIKRANTKRISHNA
Regular Contributor
Hi Nimesh,
              I have been really struggling with this problem. I don't know if this is a correct way to reading and writing features from text file for multiple layers. I have attached a text file with the piece of code I am using to implement this.



All three textfiles look like this


file 1: 
{"geometryType":"esriGeometryPolygon","features":[{"geometry":{"spatialReference":{"wkid":26915},"rings":[[[454624.71300000045,5002318.9177999999],[454948.50889999978,5001754.4406000003],[454239.10940000042,5001505.4506999999],[454624.71300000045,5002318.9177999999]]]},"attributes":{"CostToRepair":"25000","USNG":null,"OBJECTID":5602,"Latitude":null,"Notes":null,"Longitude":null,"IncidentID":1,"Structure":null,"Category":7}},{"geometry":{"spatialReference":{"wkid":26915},"rings":[[[456335.37490000029,5001531.3358999984],[456678.07160000037,5001735.495600001],[456811.74760000024,5001378.2160999998],[456371.83200000029,5001217.8048999999],[456335.37490000029,5001531.3358999984]]]},"attributes":{"CostToRepair":"20000","USNG":null,"OBJECTID":2002,"Latitude":null,"Notes":null,"Longitude":null,"IncidentID":1,"Structure":4,"Category":1}}],"spatialReference":{"wkid":26915}}


file 2: 

{"geometryType":"esriGeometryPolyline","features":[{"geometry":{"paths":[[[456694.88599999977,5001929.1936000008],[457409.26250000019,5000738.5662999982],[456456.76059999969,5000579.8160000006]]],"spatialReference":{"wkid":26915}},"attributes":{"CostToRepair":"2200","USNG":null,"OBJECTID":4401,"Latitude":null,"Notes":null,"Longitude":null,"IncidentID":1,"Structure":3,"Category":4}}],"spatialReference":{"wkid":26915}}



file 3:

{"geometryType":"esriGeometryPoint","features":[{"geometry":{"x":455925.14580000023,"y":5001122.9238000009,"spatialReference":{"wkid":26915}},"attributes":{"CostToRepair":"1500","USNG":null,"OBJECTID":10403,"Latitude":null,"Notes":null,"Longitude":null,"IndicentID":1,"Structure":3,"Category":5}},{"geometry":{"x":454339.92470000032,"y":5000404.7103000004,"spatialReference":{"wkid":26915}},"attributes":{"CostToRepair":"15000","USNG":null,"OBJECTID":13203,"Latitude":null,"Notes":null,"Longitude":null,"IndicentID":1,"Structure":2,"Category":1}},{"geometry":{"x":455925.14580000023,"y":5001122.9238000009,"spatialReference":{"wkid":26915}},"attributes":{"CostToRepair":"2500","USNG":null,"OBJECTID":10403,"Latitude":null,"Notes":null,"Longitude":null,"IndicentID":1,"Structure":3,"Category":2}}],"spatialReference":{"wkid":26915}}



Once user taps the sync button, syncInspections method is called and thereafter three other methods are called one by one. I am getting an error "GET" method not supported at the point when updating from 1st file.

I am not clearing the outputs of textfile just to test things. So, if I close the application and reload it and sync the inspections again without doing anything else, everything works fine. I copy pasting the json features from text file into the REST interface and everything works fine there as well.
0 Kudos
NimeshJarecha
Esri Regular Contributor
I got your point. We can investigate further if you capture the request/response. You should use tool like Charles Proxy or may be some other tool to capture it. Once, you have that, post it here and we'll look at it.

Regards,
Nimesh
0 Kudos
VIKRANTKRISHNA
Regular Contributor
Hi Nimesh,
               I checked the request and response in charles proxy. What I noticed was the every time I update features after editing in offline mode, polygon layer updates are getting picked from polyline file and vice-versa. But, this is not happening when reload the app and then sync the layers by same button tap.

Thanks,
Vikrant
0 Kudos
VIKRANTKRISHNA
Regular Contributor
Hi Nimesh,
             I figured the issue, it was something my mistake in the code in popup edit finish method. Although, it became possible because of charles proxy. Really sorry about wasting your time for something wrong on my end.

Thanks,
Vikrant
0 Kudos
NimeshJarecha
Esri Regular Contributor
No problem. Good to know that you got it working.

Regards,
Nimesh
0 Kudos
VIKRANTKRISHNA
Regular Contributor
One more questions linked to this. In my didFeatureEditWithResults, I am getting correct update,delete and update response for the feature layer, but not for the table (also of type FeatureLayer) record editing. Although editing  process is executing correctly, but not getting any callback response on this layer.
0 Kudos