Class: GeoRuby::SimpleFeatures::Feature
- Inherits:
-
Object
- Object
- GeoRuby::SimpleFeatures::Feature
- Defined in:
- lib/geojson.rb
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
- #as_json(options = nil) ⇒ Object
-
#initialize(geometry, properties = {}, id = nil) ⇒ Feature
constructor
A new instance of Feature.
Constructor Details
#initialize(geometry, properties = {}, id = nil) ⇒ Feature
Returns a new instance of Feature.
113 114 115 116 117 |
# File 'lib/geojson.rb', line 113 def initialize(geometry, properties={}, id=nil) @geometry=geometry @properties=properties @id=id end |
Instance Attribute Details
#geometry ⇒ Object
Returns the value of attribute geometry.
109 110 111 |
# File 'lib/geojson.rb', line 109 def geometry @geometry end |
#id ⇒ Object
Returns the value of attribute id.
111 112 113 |
# File 'lib/geojson.rb', line 111 def id @id end |
#properties ⇒ Object
Returns the value of attribute properties.
110 111 112 |
# File 'lib/geojson.rb', line 110 def properties @properties end |
Instance Method Details
#==(other) ⇒ Object
127 128 129 130 131 132 133 |
# File 'lib/geojson.rb', line 127 def ==(other) if other.class != self.class false else @geometry==other.geometry and @properties==other.properties and @id==other.id end end |
#as_json(options = nil) ⇒ Object
119 120 121 122 123 124 125 |
# File 'lib/geojson.rb', line 119 def as_json( = nil) result={:type=>"Feature", :geometry=>@geometry, :properties=>@properties} result[:id]=@id if @id!=nil return result.as_json() end |