class RGeo::Kml::FeatureCollection
This is a Kml
wrapper entity that corresponds to the Kml
“FeatureCollection” 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 FeatureCollection
implementation need not subclass or even duck-type this class. The entity factory mediates all interaction between the Kml
engine and feature collections.
Public Class Methods
Create a new FeatureCollection
with the given features, which must be provided as an Enumerable.
# File lib/rgeo/kml/entities.rb, line 130 def initialize(features_=[]) @features = [] features_.each{ |f_| @features << f_ if f_.kind_of?(Feature) } end
Public Instance Methods
Two feature collections are equal if they contain the same features in the same order. This methods uses the == operator to test geometry equality, which may behave differently than the eql? method.
# File lib/rgeo/kml/entities.rb, line 164 def ==(rhs_) rhs_.kind_of?(FeatureCollection) && @features == rhs_.instance_variable_get(:@features) end
Access a feature by index.
# File lib/rgeo/kml/entities.rb, line 185 def [](index_) @features[index_] end
Iterates or returns an iterator for the features.
# File lib/rgeo/kml/entities.rb, line 171 def each(&block_) @features.each(&block_) end
Two feature collections are equal if they contain the same features in the same order. This methods uses the eql? method to test geometry equality, which may behave differently than the == operator.
# File lib/rgeo/kml/entities.rb, line 154 def eql?(rhs_) rhs_.kind_of?(FeatureCollection) && @features.eql?(rhs_.instance_variable_get(:@features)) end
Returns the number of features contained in this collection.
# File lib/rgeo/kml/entities.rb, line 178 def size @features.size end