Unable to read AGSGDBGeodatabase

4171
5
Jump to solution
04-21-2014 12:53 AM
MuzammilAK
New Contributor
Dear All,


I'm developing a small application (with Runtime SDK for iOS 10.2.2) for displaying an offline geodatabase (.geodatabase file)  that I have created with ArcGIS for Desktop 10.2.1.

The application crashes at below line in debug mode. In Device mode, the gdb value is nil ( I used iTunes File Sharing for device).
AGSGDBGeodatabase *gdb = [[AGSGDBGeodatabase alloc] initWithPath:thePathString error:&error];

Exception Details in Console Window:

Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'This AGSFeatureTable is backed by a non-spatial table. A spatial table is required to be rendered in a layer.'


Looks like there is a problem with .geodatabase file. I tried a sample with 1 simple layer. It works.
But when i generate .geodatabase file with many layers, I get above exception.


Regards
Muzammil
0 Kudos
1 Solution

Accepted Solutions
YueWu1
by
Regular Contributor
Hello Muzammil,

I used this snippet code and successfully load a local geodatabase with several layers. You can take a try.

[PHP]AGSGDBGeodatabase *gdb = [[AGSGDBGeodatabase alloc] initWithPath:gdbPath error:&error];
    for (AGSFeatureTable* fTable in gdb.featureTables) {
        if ([fTable hasGeometry]) {
            [self.mapView addMapLayer:[[AGSFeatureTableLayer alloc]initWithFeatureTable:fTable]];
        }
[/PHP]

View solution in original post

0 Kudos
5 Replies
YueWu1
by
Regular Contributor
Hello Muzammil,

I am wondering do you have any standalone tables in your Feature Service? Or any one of your layers is based on a Join?
0 Kudos
AhmedElesawy
New Contributor
Create a bundle for the geodatabase file the problem is with getting the full path for the geodatabsae file
This happen with me last week
0 Kudos
YueWu1
by
Regular Contributor
Hello Muzammil,

I used this snippet code and successfully load a local geodatabase with several layers. You can take a try.

[PHP]AGSGDBGeodatabase *gdb = [[AGSGDBGeodatabase alloc] initWithPath:gdbPath error:&error];
    for (AGSFeatureTable* fTable in gdb.featureTables) {
        if ([fTable hasGeometry]) {
            [self.mapView addMapLayer:[[AGSFeatureTableLayer alloc]initWithFeatureTable:fTable]];
        }
[/PHP]

View solution in original post

0 Kudos
AbuMathew
New Contributor

I am using the following swift code to load a database which is more than 20 MB in size. This code works perfectly on simulator, but not on the iPad. A smaller sized database (<5MB) could be loaded on the device.

var gdb = AGSGDBGeodatabase();

            do{

                print(gdbPath)

                //try localGDB = AGSGDBGeodatabase(path: gdbPath)

                try gdb = AGSGDBGeodatabase.init(path: gdbPath)

               

               

       

                //Add layers from local database

                for featureTable in gdb.featureTables() as! [AGSFeatureTable] {

                    if featureTable.hasGeometry() {

                        self.mapView.addMapLayer(AGSFeatureTableLayer(featureTable: featureTable))

                    }

                }

            }catch let error1 as NSError{

                print("Error is - \(error1)")

            }

0 Kudos
MichaelDavis3
Regular Contributor

How are you creating gdbPath?  If it is the documents path keep in mind that this is unique for each session on the device.  The app runs under a different instance ID each time so you should get the path to the documents directory using something like this:

NSSearchPathForDirectoriesInDomains(.DocumentDirectory, .UserDomainMask, true)[0] as! NSString

0 Kudos