Sha256: d89ad47f94f0d4a87b81631318ab20f2b911f306d9e898a9ac876556b953f717

Contents?: true

Size: 758 Bytes

Versions: 2

Compression:

Stored size: 758 Bytes

Contents

module FieldView
  class Feature
    attr_accessor :type, :coordinates
    def initialize(json_feature_object)
      # Use RGEO??
      self.type = json_feature_object[:type]
      self.coordinates = json_feature_object[:coordinates]
    end

    def point?()
      return !!(self.type =~ /\Apoint\z/i)
    end

    def multi_polygon?()
      return !!(self.type =~ /\Amultipolygon\z/i)
    end
  end
  class Boundary
    attr_accessor :id, :units, :area, :centroid, :geometry
    def initialize(json_object)
      self.id = json_object[:id]
      self.area = json_object[:area][:q]
      self.units = json_object[:area][:u]
      self.centroid = Feature.new(json_object[:centroid])
      self.geometry = Feature.new(json_object[:geometry])
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
fieldview-0.0.1 lib/fieldview/boundary.rb
fieldview-0.0.0 lib/fieldview/boundary.rb