class RGeo::Kml::Feature
This is a Kml
wrapper entity that corresponds to the Kml
“Feature” type. It is an immutable type.
This is the default implementation that is generated by RGeo::Kml::EntityFactory
. You may replace this implementation by writing your own entity factory. Note that an alternate Feature
implementation need not subclass or even duck-type this class. the entity factory mediates all interaction between the Kml
engine and features.
Public Class Methods
Create a feature wrapping the given geometry, with the given ID and properties.
# File lib/rgeo/kml/entities.rb, line 29 def initialize(geometry_, id_=nil, properties_={}) @geometry = geometry_ @id = id_ @properties = {} properties_.each do |k_, v_| @properties[k_.to_s] = v_ end end
Public Instance Methods
Two features are equal if their geometries, IDs, and properties are all equal. This method uses the == operator to test geometry equality, which may behave differently than the eql? method.
# File lib/rgeo/kml/entities.rb, line 67 def ==(rhs_) rhs_.kind_of?(Feature) && @geometry == rhs_.geometry && @id == rhs_.feature_id && @properties == rhs_.instance_variable_get(:@properties) end
Two features are equal if their geometries, IDs, and properties are all equal. This method uses the eql? method to test geometry equality, which may behave differently than the == operator.
# File lib/rgeo/kml/entities.rb, line 57 def eql?(rhs_) rhs_.kind_of?(Feature) && @geometry.eql?(rhs_.geometry) && @id.eql?(rhs_.feature_id) && @properties.eql?(rhs_.instance_variable_get(:@properties)) end
Returns the ID for this feature, which may be nil.
# File lib/rgeo/kml/entities.rb, line 81 def feature_id @id end
Returns the geometry contained in this feature, which may be nil.
# File lib/rgeo/kml/entities.rb, line 74 def geometry @geometry end
Gets an array of the known property keys in this feature.
# File lib/rgeo/kml/entities.rb, line 104 def keys @properties.keys end
Returns a copy of the properties for this feature.
# File lib/rgeo/kml/entities.rb, line 88 def properties @properties.dup end
Gets the value of the given named property. Returns nil if the given property is not found.
# File lib/rgeo/kml/entities.rb, line 96 def property(key_) @properties[key_.to_s] end