Class: GeoRuby::SimpleFeatures::Feature

Inherits:
Object
  • Object
show all
Defined in:
lib/geojson.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#geometryObject

Returns the value of attribute geometry.



109
110
111
# File 'lib/geojson.rb', line 109

def geometry
  @geometry
end

#idObject

Returns the value of attribute id.



111
112
113
# File 'lib/geojson.rb', line 111

def id
  @id
end

#propertiesObject

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(options = nil)
  result={:type=>"Feature",
    :geometry=>@geometry,
    :properties=>@properties}
  result[:id]=@id if @id!=nil
  return result.as_json(options)
end