Class: Georeference::VerbatimData

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

Constant Summary

Constants inherited from Georeference

FACTORY

Instance Attribute Summary

Attributes inherited from Georeference

#collecting_event_id, #error_depth, #error_geographic_item_id, #error_radius, #geographic_item_id, #position, #request, #source_id, #type

Instance Method Summary collapse

Methods included from Housekeeping

#has_polymorphic_relationship?

Constructor Details

#initialize(params = {}) ⇒ VerbatimData

no available parms



3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# File 'app/models/georeference/verbatim_data.rb', line 3

def initialize(params = {}) # no available parms

  super

  self.is_median_z    = false
  self.is_undefined_z = false # and delta_z is zero, or ignored

  if collecting_event.nil?
  else
    # get the data from the parent.collecting_event, and make a point of it
    lat  = collecting_event.verbatim_latitude.to_f
    long = collecting_event.verbatim_longitude.to_f

    # value from collecting_event is normalised to meters
    z1   = collecting_event.minimum_elevation
    z2   = collecting_event.maximum_elevation
    if z1.blank?
      # no valid elevation provided
      self.is_undefined_z = true
      delta_z             = 0.0
    else
      # we have at least half of the range data
      delta_z = z1
      if z2.blank?
        # we have *only* half of the range data
        delta_z = z1
      else
        # we have full range data, so elevation is (top - bottom) / 2
        z2               = z2.to_f
        delta_z          = (z2 - z1) * 0.5
        # and show calculated median
        self.is_median_z = true
      end
    end
    #if geographic_item.nil?
      self.geographic_item = GeographicItem.new(point: Georeference::FACTORY.point(long, lat, delta_z))
    #end
    geographic_item
  end
end