knisleyj

ArcGISFeatuerLayer fails to initialize using a FeatureSet

Discussion created by knisleyj on Sep 5, 2013
Latest reply on Nov 19, 2013 by knisleyj
I'm trying to instantiate an ArcGISFeatureLayer using the constructor:
public ArcGISFeatureLayer (String layerDefinition, FeatureSet featureCollection, ArcGISFeatureLayer.Options layerOption)

My layer definition is a string resource (in JSON format) and the feature set is the result of a query that contains a few graphics. The map view, layer definition, and feature set all have the same spatial reference (102100), however I keep getting an error that my feature set needs to be projected. The full error is:
E/ArcGIS(2057): Failed to initialize the ArcGISFeatureLayer.
E/ArcGIS(2057): java.lang.UnsupportedOperationException: The Feature collection need to be projected.
E/ArcGIS(2057):  at com.esri.android.map.ags.ArcGISFeatureLayer.initLayer(Unknown Source)
E/ArcGIS(2057):  at com.esri.android.map.ags.ArcGISFeatureLayer$1.run(Unknown Source)
E/ArcGIS(2057):  at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:390)
E/ArcGIS(2057):  at java.util.concurrent.FutureTask.run(FutureTask.java:234)
E/ArcGIS(2057):  at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1080)
E/ArcGIS(2057):  at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:573)
E/ArcGIS(2057):  at java.lang.Thread.run(Thread.java:856)


Oddly enough, it works if I use an empty FeatureSet and then add graphics from my existing FeatureSet.

In summary, this throws an error:
offlineLayer = new ArcGISFeatureLayer(layerDef, featureSet, new Options());


While this works:
offlineLayer = new ArcGISFeatureLayer(layerDef, new FeatureSet(), new Options());
offlineLayer.addGraphics(featureSet.getGraphics());


Is this a bug? It's easy enough to work around, I just don't understand why the first line throws an error.

Here is a sample of the query results in JSON format:
{
    "objectIdFieldName": "OBJECTID",
    "geometryType": "esriGeometryPoint",
    "spatialReference": {
        "wkid": 102100
    },
    "fieldAliases": {
        "EDITORNAME": "EDITORNAME",
        "LASTUPDATE": "LASTUPDATE",
        "Description": "Description",
        "Category": "Category",
        "CREATIONDATE": "CREATIONDATE",
        "CREATORNAME": "CREATORNAME",
        "OBJECTID": "OBJECTID"
    },
    "fields": [
        {
            "name": "OBJECTID",
            "alias": "OBJECTID",
            "type": "esriFieldTypeOID"
        },
        {
            "name": "Category",
            "alias": "Category",
            "type": "esriFieldTypeString",
            "length": 50
        },
        {
            "name": "Description",
            "alias": "Description",
            "type": "esriFieldTypeString",
            "length": 50
        },
        {
            "name": "CREATORNAME",
            "alias": "CREATORNAME",
            "type": "esriFieldTypeString",
            "length": 50
        },
        {
            "name": "CREATIONDATE",
            "alias": "CREATIONDATE",
            "type": "esriFieldTypeDate",
            "length": 36
        },
        {
            "name": "EDITORNAME",
            "alias": "EDITORNAME",
            "type": "esriFieldTypeString",
            "length": 50
        },
        {
            "name": "LASTUPDATE",
            "alias": "LASTUPDATE",
            "type": "esriFieldTypeDate",
            "length": 36
        }
    ],
    "features": [
        {
            "attributes": {
                "OBJECTID": 1,
                "Category": "Cat1",
                "Description": "Desc1",
                "CREATORNAME": "test",
                "CREATIONDATE": 1377539896000,
                "EDITORNAME": "test",
                "LASTUPDATE": 1377540070000
            },
            "geometry": {
                "x": -10015683.0399,
                "y": 4189540.4191000015,
                "spatialReference": {
                    "wkid": 102100,
                    "latestWkid": 3857
                }
            }
        },
        {
            "attributes": {
                "OBJECTID": 2,
                "Category": "Cat2",
                "Description": "Desc2",
                "CREATORNAME": "test",
                "CREATIONDATE": 1377539898000,
                "EDITORNAME": "test",
                "LASTUPDATE": 1377540114000
            },
            "geometry": {
                "x": -10009514.3383,
                "y": 4190218.3222000003,
                "spatialReference": {
                    "wkid": 102100,
                    "latestWkid": 3857
                }
            }
        }
    ]
}


And the layer definition:
{
    \"currentVersion\": 10.1,
    \"id\": 0,
    \"name\": \"Test\",
    \"type\": \"Feature Layer\",
    \"description\": \"\",
    \"copyrightText\": \"\",
    \"defaultVisibility\": true,
    \"editFieldsInfo\": {
        \"creationDateField\": \"CREATIONDATE\",
        \"creatorField\": \"CREATORNAME\",
        \"editDateField\": \"LASTUPDATE\",
        \"editorField\": \"EDITORNAME\"
    },
    \"ownershipBasedAccessControlForFeatures\": null,
    \"syncCanReturnChanges\": false,
    \"relationships\": [],
    \"isDataVersioned\": true,
    \"supportsRollbackOnFailureParameter\": false,
    \"supportsStatistics\": true,
    \"supportsAdvancedQueries\": true,
    \"geometryType\": \"esriGeometryPoint\",
    \"minScale\": 0,
    \"maxScale\": 0,
    \"extent\": {
        \"xmin\": -10015683.0399,
        \"ymin\": 4185636.876500003,
        \"xmax\": -10005662.0863,
        \"ymax\": 4190218.3222000003,
        \"spatialReference\": {
            \"wkid\": 102100,
            \"latestWkid\": 3857
        }
    },
    \"drawingInfo\": {
        \"renderer\": {
            \"type\": \"simple\",
            \"symbol\": {
                \"type\": \"esriPMS\",
                \"url\": \"827ba8a40a3e18f97744adf3582f89b0\",
                \"imageData\": \"iVBORw0KGgoAAAANSUhEUgAAABMAAAASCAYAAAC5DOVpAAAAAXNSR0IB2cksfwAAAAlwSFlzAAAOxAAADsQBlSsOGwAAAU1JREFUOI2t0zFLw0AYxvF/2tAbAg5dbKKLU1c3IZuCDg7Ouoj9AOKo30CcRATByVERowhOIiKd3EQHKSLi4kUpZOvwgm0caktMWptUn+nuOH48HPea/GPMQRdewSwo5Toi1T9hbzBhwCEiUxoO8rA6Co3MmIZFYB8Y+T6qNJVytWUtOUFwlwr7AKsJu0AlcVukjMithnUbdgwI+2K6WJxsNhpHiJT7NQYKwLYPs++wUoJ6AtOwRhBsAeoXKJr5FtxrpZYdkasuppXaRGQjJRKNjcilDws2XLSbiTwNAXViALVusxac5+CTFP+uRx5seO5i4xBouAbmhsC8zsKMHWbGQjhJYDk4a8EekE8tKVUbE3lMYCWoa6gC0xmKedFN/MG9TJhleYj0xgw4DdujZKSgXuIz+gOzwddwA7gDKaWOo60SGIADMylaEYcAvgDsemR5EOk4KgAAAABJRU5ErkJggg==\",
                \"contentType\": \"image/png\",
                \"width\": 14,
                \"height\": 13,
                \"angle\": 0,
                \"xoffset\": 0,
                \"yoffset\": 0
            },
            \"label\": \"\",
            \"description\": \"\"
        },
        \"transparency\": 0,
        \"labelingInfo\": null
    },
    \"hasM\": false,
    \"hasZ\": false,
    \"allowGeometryUpdates\": true,
    \"hasAttachments\": false,
    \"htmlPopupType\": \"esriServerHTMLPopupTypeAsHTMLText\",
    \"objectIdField\": \"OBJECTID\",
    \"globalIdField\": \"\",
    \"displayField\": \"CREATORNAME\",
    \"typeIdField\": \"\",
    \"fields\": [
        {
            \"name\": \"OBJECTID\",
            \"type\": \"esriFieldTypeOID\",
            \"alias\": \"OBJECTID\",
            \"domain\": null,
            \"editable\": false,
            \"nullable\": false
        },
        {
            \"name\": \"Category\",
            \"type\": \"esriFieldTypeString\",
            \"alias\": \"Category\",
            \"domain\": null,
            \"editable\": true,
            \"nullable\": true,
            \"length\": 50
        },
        {
            \"name\": \"Description\",
            \"type\": \"esriFieldTypeString\",
            \"alias\": \"Description\",
            \"domain\": null,
            \"editable\": true,
            \"nullable\": true,
            \"length\": 50
        },
        {
            \"name\": \"CREATORNAME\",
            \"type\": \"esriFieldTypeString\",
            \"alias\": \"CREATORNAME\",
            \"domain\": null,
            \"editable\": false,
            \"nullable\": true,
            \"length\": 50
        },
        {
            \"name\": \"CREATIONDATE\",
            \"type\": \"esriFieldTypeDate\",
            \"alias\": \"CREATIONDATE\",
            \"domain\": null,
            \"editable\": false,
            \"nullable\": true,
            \"length\": 36
        },
        {
            \"name\": \"EDITORNAME\",
            \"type\": \"esriFieldTypeString\",
            \"alias\": \"EDITORNAME\",
            \"domain\": null,
            \"editable\": false,
            \"nullable\": true,
            \"length\": 50
        },
        {
            \"name\": \"LASTUPDATE\",
            \"type\": \"esriFieldTypeDate\",
            \"alias\": \"LASTUPDATE\",
            \"domain\": null,
            \"editable\": false,
            \"nullable\": true,
            \"length\": 36
        }
    ],
    \"types\": [],
    \"templates\": [
        {
            \"name\": \"Test\",
            \"description\": \"\",
            \"prototype\": {
                \"attributes\": {
                    \"LASTUPDATE\": null,
                    \"Category\": null,
                    \"Description\": null,
                    \"CREATORNAME\": null,
                    \"CREATIONDATE\": null,
                    \"EDITORNAME\": null
                }
            },
            \"drawingTool\": \"esriFeatureEditToolPoint\"
        }
    ],
    \"maxRecordCount\": 5000,
    \"supportedQueryFormats\": \"JSON, AMF\",
    \"capabilities\": \"Create,Delete,Query,Update,Uploads,Editing\"
}

Outcomes