Class: GeoRuby::GeoJSONFeature
- Inherits:
-
Object
- Object
- GeoRuby::GeoJSONFeature
- Defined in:
- lib/geo_ruby/geojson.rb
Overview
Class added to support geojson ‘Feature’ objects
Instance Attribute Summary collapse
-
#geometry ⇒ Object
Returns the value of attribute geometry.
-
#id ⇒ Object
Returns the value of attribute id.
-
#properties ⇒ Object
Returns the value of attribute properties.
Instance Method Summary collapse
- #==(other) ⇒ Object
-
#initialize(geometry, properties = {}, id = nil) ⇒ GeoJSONFeature
constructor
A new instance of GeoJSONFeature.
- #to_json(options = {}) ⇒ Object (also: #as_geojson)
Constructor Details
#initialize(geometry, properties = {}, id = nil) ⇒ GeoJSONFeature
Returns a new instance of GeoJSONFeature.
19 20 21 22 23 |
# File 'lib/geo_ruby/geojson.rb', line 19 def initialize(geometry, properties = {}, id = nil) @geometry = geometry @properties = properties @id = id end |
Instance Attribute Details
#geometry ⇒ Object
Returns the value of attribute geometry.
17 18 19 |
# File 'lib/geo_ruby/geojson.rb', line 17 def geometry @geometry end |
#id ⇒ Object
Returns the value of attribute id.
17 18 19 |
# File 'lib/geo_ruby/geojson.rb', line 17 def id @id end |
#properties ⇒ Object
Returns the value of attribute properties.
17 18 19 |
# File 'lib/geo_ruby/geojson.rb', line 17 def properties @properties end |
Instance Method Details
#==(other) ⇒ Object
25 26 27 28 29 30 31 32 33 |
# File 'lib/geo_ruby/geojson.rb', line 25 def ==(other) if (self.class != other.class) false else (id == other.id) && (geometry == other.geometry) && (properties == other.properties) end end |
#to_json(options = {}) ⇒ Object Also known as: as_geojson
35 36 37 38 39 40 41 42 |
# File 'lib/geo_ruby/geojson.rb', line 35 def to_json( = {}) output = {} output[:type] = 'Feature' output[:geometry] = geometry output[:properties] = properties output[:id] = id unless id.nil? output.to_json() end |