Class: ArcREST::Layer

Inherits:
Server
  • Object
show all
Includes:
Attributable
Defined in:
lib/arcrest/layer.rb

Overview

a layer

Constant Summary collapse

DATE =
'esriFieldTypeDate'
ATTRIBUTES =
%w[id name type drawing_info fields max_record_count].freeze
DEFAULT_PARAMS =
{ where: '1=1', outFields: '*' }.freeze
PARAMS =
%w[distance geometry geometryType inSR objectIds
outFields outSR relationParam returnDistinceValues
returnIdsOnly spatialRel time where].freeze
PARAMS_SP1 =
%w[returnCountOnly].freeze
PARAMS_10_1 =
%w[dbVersion geometryPrecision groupByFieldsForStatistics
maxAllowableOffset multiPatchOption orderByFields
outStatistics returnGeometry returnM returnZ].freeze
PARAMS_10_3 =
%w[returnExtentOnly resultOffset resultRecordCount].freeze

Constants inherited from Server

Server::BAD_ENDPOINT, Server::ENDPOINT_REGEX

Constants included from Curlable

Curlable::RETRIES

Instance Attribute Summary collapse

Attributes inherited from Server

#json, #url, #version

Instance Method Summary collapse

Methods included from Attributable

#create_getter, #create_method, #create_setter, #set_attr

Methods included from Curlable

#curl_get

Constructor Details

#initialize(url, headers = {}) ⇒ Layer

Returns a new instance of Layer.



26
27
28
29
30
# File 'lib/arcrest/layer.rb', line 26

def initialize(url, headers = {})
  super
  generate_attributes # dynamically create & assign values to attributes :)
  @fields = fields
end

Instance Attribute Details

#valid_paramsObject (readonly)

other accessors set in constructor



24
25
26
# File 'lib/arcrest/layer.rb', line 24

def valid_params
  @valid_params
end

Instance Method Details

#countObject



32
33
34
# File 'lib/arcrest/layer.rb', line 32

def count
  @version > 10 ? count_only_true : object_ids.count # v10.1 onwards
end

#features(options = {}) ⇒ Object



45
46
47
# File 'lib/arcrest/layer.rb', line 45

def features(options = {})
  query(options)['features']
end

#object_idsObject



36
37
38
# File 'lib/arcrest/layer.rb', line 36

def object_ids
  query(outFields: nil, returnIdsOnly: true)['objectIds'] # care - must specify outFields to overide default '*'
end

#query(options = {}) ⇒ Object



40
41
42
43
# File 'lib/arcrest/layer.rb', line 40

def query(options = {})
  validate(options.keys.map(&:to_s).sort)
  valid_resp(DEFAULT_PARAMS.merge(options))
end

#valid_optsObject



49
50
51
52
53
54
55
# File 'lib/arcrest/layer.rb', line 49

def valid_opts
  return PARAMS if @version < 10 || @version.to_s == '10.0'
  return (PARAMS + PARAMS_SP1).sort if @version < 10.1
  return (PARAMS + PARAMS_SP1 + PARAMS_10_1).sort if @version < 10.2

  (PARAMS + PARAMS_SP1 + PARAMS_10_1 + PARAMS_10_3).sort
end