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?
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 <SPAN class="operator token">=</SPAN> <SPAN class="token function">AGSServiceFeatureTable</SPAN><SPAN class="punctuation token">(</SPAN>url<SPAN class="punctuation token">:</SPAN> <SPAN class="token function">URL</SPAN><SPAN class="punctuation token">(</SPAN>string<SPAN class="punctuation token">:</SPAN> <SPAN class="string token"><SPAN>"</SPAN><A class="jive-link-external-small" href="https://community.esri.com/external-link.jspa?url=https%3A%2F%2Fsampleserver3.arcgisonline.com%2FArcGIS%2Frest%2Fservices%2FSanFrancisco%2F311Incidents%2FFeatureServer%2F0" target="_blank">https://sampleserver3.arcgisonline.com/ArcGIS/rest/services/SanFrancisco/311Incidents/FeatureServer/0</A><SPAN>"</SPAN></SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="operator token">!</SPAN><SPAN class="punctuation token">)</SPAN> sft<SPAN class="punctuation token">.</SPAN>featureRequestMode <SPAN class="operator token">=</SPAN> <SPAN class="punctuation token">.</SPAN>onInteractionNoCache <SPAN class="keyword token">let</SPAN> qp <SPAN class="operator token">=</SPAN> <SPAN class="token function">AGSQueryParameters</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN> qp<SPAN class="punctuation token">.</SPAN>whereClause <SPAN class="operator token">=</SPAN> <SPAN class="string token">"req_type = 'Sidewalk and Curb Issues'"</SPAN> sft<SPAN class="punctuation token">.</SPAN><SPAN class="token function">queryFeatures</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="keyword token">with</SPAN><SPAN class="punctuation token">:</SPAN> qp<SPAN class="punctuation token">,</SPAN> fields<SPAN class="punctuation token">:</SPAN> <SPAN class="punctuation token">.</SPAN>loadAll<SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">{</SPAN> result<SPAN class="punctuation token">,</SPAN> error <SPAN class="keyword token">in</SPAN> <SPAN class="keyword token">if</SPAN> <SPAN class="keyword token">let</SPAN> error <SPAN class="operator token">=</SPAN> error <SPAN class="punctuation token">{</SPAN> <SPAN class="token function">print</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="string token">"error querying: \(error)"</SPAN><SPAN class="punctuation token">)</SPAN> <SPAN class="punctuation token">}</SPAN> <SPAN class="keyword token">else</SPAN><SPAN class="punctuation token">{</SPAN> <SPAN class="token function">print</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="string token">"result: \(result)"</SPAN><SPAN class="punctuation token">)</SPAN> <SPAN class="keyword token">let</SPAN> enumerator <SPAN class="operator token">=</SPAN> result<SPAN class="operator token">?</SPAN><SPAN class="punctuation token">.</SPAN><SPAN class="token function">featureEnumerator</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN> <SPAN class="keyword token">while</SPAN> <SPAN class="keyword token">let</SPAN> feature <SPAN class="operator token">=</SPAN> enumerator<SPAN class="operator token">?</SPAN><SPAN class="punctuation token">.</SPAN><SPAN class="token function">nextObject</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">{</SPAN> <SPAN class="token function">print</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="string token">"feature: \(feature)"</SPAN><SPAN class="punctuation token">)</SPAN> <SPAN class="punctuation token">}</SPAN> <SPAN class="punctuation token">}</SPAN> <SPAN class="punctuation token">}</SPAN><SPAN class="line-numbers-rows"><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN></SPAN>
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.
Les membres connectés peuvent publier, suivre les mises à jour, et plus encore. Nouveau ici ? Inscrivez-vous gratuitement.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.