class RGeo::Kml::EntityFactory
This is the default entity factory. It creates objects of type RGeo::Kml::Feature
and RGeo::Kml::FeatureCollection
. You may create your own entity factory by duck-typing this class.
Public Class Methods
Return the singleton instance of EntityFactory
.
# File lib/rgeo/kml/entities.rb, line 265 def self.instance @instance ||= self.new end
Public Instance Methods
Create and return a new feature, given geometry, ID, and properties hash. Note that, per the Kml
spec, geometry and/or properties may be nil.
# File lib/rgeo/kml/entities.rb, line 204 def feature(geometry_, id_=nil, properties_=nil) Feature.new(geometry_, id_, properties_ || {}) end
Create and return a new feature collection, given an enumerable of feature objects.
# File lib/rgeo/kml/entities.rb, line 212 def feature_collection(features_=[]) FeatureCollection.new(features_) end
Returns the geometry associated with the given feature.
# File lib/rgeo/kml/entities.rb, line 243 def get_feature_geometry(object_) object_.geometry end
Returns the ID of the given feature, or nil for no ID.
# File lib/rgeo/kml/entities.rb, line 250 def get_feature_id(object_) object_.feature_id end
Returns the properties of the given feature as a hash. Editing this hash does not change the state of the feature.
# File lib/rgeo/kml/entities.rb, line 258 def get_feature_properties(object_) object_.properties end
Returns true if the given object is a feature created by this entity factory.
# File lib/rgeo/kml/entities.rb, line 220 def is_feature?(object_) object_.kind_of?(Feature) end
Returns true if the given object is a feature collection created by this entity factory.
# File lib/rgeo/kml/entities.rb, line 228 def is_feature_collection?(object_) object_.kind_of?(FeatureCollection) end
Run Enumerable#map on the features contained in the given feature collection.
# File lib/rgeo/kml/entities.rb, line 236 def map_feature_collection(object_, &block_) object_.map(&block_) end