Bolton-and-Menk-GIS / restapi

Python API designed to work externally with ArcGIS REST Services to query and extract data, and view service properties. Uses arcpy for some functions if available, otherwise uses open source alternatives to interact with the ArcGIS REST API. Also includes a subpackage for administering ArcGIS Server Sites.
GNU General Public License v2.0
93 stars 31 forks source link

Fix bug where fields is ignored if exceed_limit is True #56

Closed marceloandrioni closed 3 months ago

marceloandrioni commented 3 months ago

This fixes #55.

Before the fix the fields was ignored when exceed_limit was True, e.g.:

import restapi

rest_url = 'https://sampleserver6.arcgisonline.com/arcgis/rest/services'
ags = restapi.ArcServer(rest_url)
usa = ags.getService('USA') #/USA/MapServer -> restapi.common_types.MapService
cities = usa.layer('Cities') # or can use layer id: usa.layer(0)

where = "st = 'CA' and pop2000 > 100000"

featureSet = cities.query(where=where, fields=["areaname", "capital"],
                          exceed_limit=True)
print(featureSet[0]["properties"])
# {
#   "areaname": "Anaheim",
#   "capital": "N",
#   "class": "city",
#   "objectid": 169,
#   "pop2000": 328014,
#   "st": "CA"
# }

after the fix:

featureSet = cities.query(where=where, fields=["areaname", "capital"],
                          exceed_limit=True)
print(featureSet[0]["properties"])
# {
#   "areaname": "Anaheim",
#   "capital": "N"
# }
philnagel commented 3 months ago

Thank you for the PR!