Class: Georeference::Gazetteer

Inherits:
Georeference
  • Object
show all
Defined in:
app/models/georeference/gazetteer.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#gazetteer_idObject

Returns the value of attribute gazetteer_id.



2
3
4
# File 'app/models/georeference/gazetteer.rb', line 2

def gazetteer_id
  @gazetteer_id
end

Instance Method Details

#dwc_georeference_attributes(h = {}) ⇒ Object



9
10
11
12
13
14
15
16
17
18
# File 'app/models/georeference/gazetteer.rb', line 9

def dwc_georeference_attributes(h = {})
  super(h)
  h.merge!(
    georeferenceSources: "TaxonWorks user-added Gazetteer.",
    georeferenceRemarks: "Created from a shape in TaxonWorks that a user added to the system.",
    geodeticDatum: nil
  )
  h[:georeferenceProtocol] = "User selection from the system's user-added shapes." if h[:georeferenceProtocol].blank?
  h
end

#gazetteerObject (private)



22
23
24
25
26
# File 'app/models/georeference/gazetteer.rb', line 22

def gazetteer
  return @gazetteer if defined?(@gazetteer)

  @gazetteer = ::Gazetteer.find_by(id: gazetteer_id)
end

#gazetteer_existsObject (private)



28
29
30
# File 'app/models/georeference/gazetteer.rb', line 28

def gazetteer_exists
  errors.add(:gazetteer_id, :invalid) if gazetteer.nil?
end

#set_geographic_item_from_gazetteerObject (private)



32
33
34
# File 'app/models/georeference/gazetteer.rb', line 32

def set_geographic_item_from_gazetteer
  self.geographic_item = gazetteer&.geographic_item if gazetteer_id.present?
end