class Terraformer::Feature

Attributes

crs[RW]
geometry[RW]
id[RW]
properties[W]

Public Class Methods

new(*args) click to toggle source
Calls superclass method Terraformer::Primitive::new
# File lib/terraformer/feature.rb, line 11
def initialize *args
  unless args.empty?
    super *args do |arg|
      self.id = arg['id'] if arg.key? 'id'
      self.properties = arg['properties'] if arg.key? 'properties'
      self.geometry = Terraformer.parse arg['geometry'] if arg['geometry']
    end
  end
end

Public Instance Methods

==(obj) click to toggle source
# File lib/terraformer/feature.rb, line 44
def == obj
  return false unless Feature === obj
  to_hash == obj.to_hash
end
geojson_io() click to toggle source
# File lib/terraformer/feature.rb, line 40
def geojson_io
  Terraformer.geojson_io self
end
great_circle_distance(other) click to toggle source
# File lib/terraformer/feature.rb, line 35
def great_circle_distance other
  other = other.geometry if Feature === other
  self.geometry.great_circle_distance other
end
properties() click to toggle source
# File lib/terraformer/feature.rb, line 21
def properties
  @properties ||= {}
end
to_hash(*args) click to toggle source
# File lib/terraformer/feature.rb, line 25
def to_hash *args
  h = {
    type: type,
    properties: properties,
  }
  h[:geometry] = geometry.to_hash(*args) if geometry
  h[:id] = id if id
  h
end