Class: Terraformer::Feature
- Extended by:
- Forwardable
- Defined in:
- lib/terraformer/feature.rb
Instance Attribute Summary collapse
-
#crs ⇒ Object
Returns the value of attribute crs.
-
#geometry ⇒ Object
Returns the value of attribute geometry.
-
#id ⇒ Object
Returns the value of attribute id.
- #properties ⇒ Object
Instance Method Summary collapse
- #==(obj) ⇒ Object
- #geojson_io ⇒ Object
- #great_circle_distance(other) ⇒ Object
-
#initialize(*args) ⇒ Feature
constructor
A new instance of Feature.
- #to_hash(*args) ⇒ Object
Methods inherited from Primitive
#bbox, #envelope, #to_json, #type
Constructor Details
#initialize(*args) ⇒ Feature
Returns a new instance of Feature.
11 12 13 14 15 16 17 18 19 |
# 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 |
Instance Attribute Details
#crs ⇒ Object
Returns the value of attribute crs.
6 7 8 |
# File 'lib/terraformer/feature.rb', line 6 def crs @crs end |
#geometry ⇒ Object
Returns the value of attribute geometry.
6 7 8 |
# File 'lib/terraformer/feature.rb', line 6 def geometry @geometry end |
#id ⇒ Object
Returns the value of attribute id.
6 7 8 |
# File 'lib/terraformer/feature.rb', line 6 def id @id end |
#properties ⇒ Object
21 22 23 |
# File 'lib/terraformer/feature.rb', line 21 def properties @properties ||= {} end |
Instance Method Details
#==(obj) ⇒ Object
44 45 46 47 |
# File 'lib/terraformer/feature.rb', line 44 def == obj return false unless Feature === obj to_hash == obj.to_hash end |
#geojson_io ⇒ Object
40 41 42 |
# File 'lib/terraformer/feature.rb', line 40 def geojson_io Terraformer.geojson_io self end |
#great_circle_distance(other) ⇒ Object
35 36 37 38 |
# 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 |
#to_hash(*args) ⇒ Object
25 26 27 28 29 30 31 32 33 |
# 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 |