Esri / ArcREST

python package for REST API (AGS, AGOL, webmap JSON, etc..)
Apache License 2.0
192 stars 155 forks source link

outSR for QueryAllFeatures #242

Closed DShokes closed 8 years ago

DShokes commented 8 years ago

ArcRest or ArcRestHelper

ArcRestHelper

Version or date of download

3.5.3

Bug or Enhancement

Enhancement

Repo Steps or Enhancement details

Please allow arcresthelper featureservicetools QueryAllFeatures to return the features in a specific spatial reference by adding an optional "outSR" argument:

###
# at line 650
###
def QueryAllFeatures(self, url, sql, out_fields="*", chunksize=1000, savePath=None,printIndent="", outSR="")
###
# at line 692-4
###
results = fl.query(objectIds=oidsQuery, returnGeometry=True, out_fields=out_fields,outSR=outSR)

Thanks

Edit: geometryFilter would be great too!

DShokes commented 8 years ago

I'm not sure if QueryAllFeatures is intended to be used in place of directly running query on the FeatureLayer object. There are differences when the query returns no features.

>>>featureLayer.query(where = '1=2').features
[]
>>> featureLayer.query(where = '1=2')
<arcrest.common.general.FeatureSet object at 0x13F44EF0>
# but 
>>> fst.QueryAllFeatures(url = featureLayer.url,sql = '1=2')
{'message': 'No features matched the query', 'success': True}

Instead of returning a dict, could it return a featureSet:

if total == 0:
    print({'success':True, 'message':"No features matched the query"})
    return fl.query(where=sql, returnGeometry=True, out_fields=out_fields)

This would allow for easier replacement of query with QueryAllFeatures without worrying about breaking later FeatureSet property usage, such as fst.QueryAllFeatures(url = featureLayer.url,sql = '1=2').features.

MikeMillerGIS commented 8 years ago

Enhancement add, please verify

DShokes commented 8 years ago

looks great thanks!

>>> fst.QueryAllFeatures(flTrees.url, outSR = 4326)
4205 features to be downloaded
24% Completed: 1000/4205
48% Completed: 2000/4205
71% Completed: 3000/4205
95% Completed: 4000/4205
100% Completed: 4205/4205
<arcrest.common.general.FeatureSet object at 0x152B2190>
DShokes commented 8 years ago

When a query returns no features. REST responds with:

{
  "objectIdFieldName" : "OBJECTID", 
  "globalIdFieldName" : "GlobalID", 
  "features" : []
}

fst.QueryAllFeatures only returns []

MikeMillerGIS commented 8 years ago

try now,