docs: def query(self,
                where="1=1",
                out_fields="*",
                timeFilter=None,
                geometryFilter=None,
                returnGeometry=True,
                returnIDsOnly=False,
                returnCountOnly=False,
                returnFeatureClass=False,
                returnDistinctValues=False,
                returnExtentOnly=False,
                maxAllowableOffset=None,
                geometryPrecision=None,
                outSR=None,
                groupByFieldsForStatistics=None,
                statisticFilter=None,
                out_fc=None,
                **kwargs):
          """ queries a feature service based on a sql statement
              Inputs:
                 where - the selection sql statement
                 out_fields - the attribute fields to return
                 timeFilter - a TimeFilter object where either the start time
                              or start and end time are defined to limit the
                              search results for a given time.  The values in
                              the timeFilter should be as UTC timestampes in
                              milliseconds.  No checking occurs to see if they
                              are in the right format.
                 geometryFilter - a GeometryFilter object to parse down a given
                                 query by another spatial dataset.
                 returnGeometry - true means a geometry will be returned,
                                  else just the attributes
                 returnIDsOnly - false is default.  True means only OBJECTIDs
                                 will be returned
                 returnCountOnly - if True, then an integer is returned only
                                   based on the sql statement
                 returnFeatureClass - Default False. If true, query will be
                                      returned as feature class
                 out_fc - only valid if returnFeatureClass is set to True.
                          Output location of query.
                 groupByFieldsForStatistics - One or more field names on
                                      which the values need to be grouped for
                                      calculating the statistics.
                 statisticFilter - object that performs statistic queries
                 kwargs - optional parameters that can be passed to the Query
                   function.  This will allow users to pass additional
                   parameters not explicitly implemented on the function. A
                   complete list of functions available is documented on the
                   Query REST API.
              Output:
                 A list of Feature Objects (default) or a path to the output featureclass if
                 returnFeatureClass is set to True.
           """
          params = {"f": "json",
                    "where": where,
                    "outFields": out_fields,
                    "returnGeometry" : returnGeometry,
                    "returnIdsOnly" : returnIDsOnly,
                    "returnCountOnly" : returnCountOnly,
                    "returnDistinctValues" : returnDistinctValues,
                    "returnExtentOnly" : returnExtentOnly
                    }
          if outSR is not None:
              params['outSR'] = outSR
          if not maxAllowableOffset is None:
              params['maxAllowableOffset'] = maxAllowableOffset
          if not geometryPrecision is None:
              params['geometryPrecision'] = geometryPrecision
          for k,v in kwargs.items():
              params[k] = v
          if returnDistinctValues:
              params["returnGeometry"] = False
          if not timeFilter is None and \
             isinstance(timeFilter, filters.TimeFilter):
              params['time'] = timeFilter.filter
          if not geometryFilter is None and \
             isinstance(geometryFilter, filters.GeometryFilter):
              gf = geometryFilter.filter
              params['geometry'] = gf['geometry']
              params['geometryType'] = gf['geometryType']
              params['spatialRelationship'] = gf['spatialRel']
              params['inSR'] = gf['inSR']
              if "buffer" in gf:
                  params['buffer'] = gf['buffer']
              if "units" in gf:
                  params['units'] = gf['units']
          if not groupByFieldsForStatistics is None:
              params['groupByFieldsForStatistics'] = groupByFieldsForStatistics
          if not statisticFilter is None and \
             isinstance(statisticFilter, filters.StatisticFilter):
              params['outStatistics'] = statisticFilter.filter
          fURL = self._url + "/query"
          results = self._post(fURL, params,
                                 securityHandler=self._securityHandler,
                                 proxy_port=self._proxy_port,
                                 proxy_url=self._proxy_url)
          if 'error' in results:
              raise ValueError (results)
          if not returnCountOnly and not returnIDsOnly and \
             not returnDistinctValues and not returnExtentOnly:
              if returnFeatureClass:
                  json_text = json.dumps(results)
                  temp = scratchFolder() + os.sep + uuid.uuid4().get_hex() + ".json"
                  with open(temp, 'wb') as writer:
                      writer.write(json_text)
                      writer.flush()
                  del writer
                  fc = json_to_featureclass(json_file=temp,
                                            out_fc=out_fc)
                  os.remove(temp)
                  return fc
              else:
                  return FeatureSet.fromJSON(json.dumps(results))
          else:
              return results
          return