Replacement for AGSQueryTask in Quartz

921
2
Jump to solution
11-22-2016 10:42 AM
JamesRichards1
Occasional Contributor

I noticed that AGSQueryTask is no longer available in Quartz. What is the preferred way to query for features on the server? If I create an AGSServiceFeatureTable and then call queryFeaturesWithParameters:completion: method will that run the query against the server or just the features that have been fetched so far?

0 Kudos
1 Solution

Accepted Solutions
RyanOlson1
Esri Contributor

With swift 3 the code would look like this to do a query against a ServiceFeatureTable. Make sure to hold a reference to the ServiceFeatureTable so that it doesn't go out of scope and get deallocd before the request is finished.

     

sft = AGSServiceFeatureTable(url: URL(string: "https://sampleserver3.arcgisonline.com/ArcGIS/rest/services/SanFrancisco/311Incidents/FeatureServer/...")!)
sft.featureRequestMode = .onInteractionNoCache
        
let qp = AGSQueryParameters()
qp.whereClause = "req_type = 'Sidewalk and Curb Issues'"

sft.queryFeatures(with: qp, fields: .loadAll){ result, error in
        
    if let error = error {
        print("error querying: \(error)")
    }
    else{
        print("result: \(result)")
        let enumerator = result?.featureEnumerator()
        while let feature = enumerator?.nextObject(){
            print("feature: \(feature)")
        }
    }
}‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍

View solution in original post

2 Replies
NimeshJarecha
Esri Regular Contributor

The AGSServiceFeatureTable has a property featureRequestMode. If it is set to AGSFeatureRequestModeManualCache then query will happen locally, all other modes query will happen against server. 

RyanOlson1
Esri Contributor

With swift 3 the code would look like this to do a query against a ServiceFeatureTable. Make sure to hold a reference to the ServiceFeatureTable so that it doesn't go out of scope and get deallocd before the request is finished.

     

sft = AGSServiceFeatureTable(url: URL(string: "https://sampleserver3.arcgisonline.com/ArcGIS/rest/services/SanFrancisco/311Incidents/FeatureServer/...")!)
sft.featureRequestMode = .onInteractionNoCache
        
let qp = AGSQueryParameters()
qp.whereClause = "req_type = 'Sidewalk and Curb Issues'"

sft.queryFeatures(with: qp, fields: .loadAll){ result, error in
        
    if let error = error {
        print("error querying: \(error)")
    }
    else{
        print("result: \(result)")
        let enumerator = result?.featureEnumerator()
        while let feature = enumerator?.nextObject(){
            print("feature: \(feature)")
        }
    }
}‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍