Module: RGeo::CastOverlay

Included in:
Feature
Defined in:
lib/rgeo/geo_json/entities.rb

Class Method Summary collapse

Class Method Details

.included(base) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/rgeo/geo_json/entities.rb', line 8

def self.included(base)
  # The original {RGeo::Feature.cast} would copy a GeoJSON::Feature, which
  # fails most operations. When casting, we MUST get a geometry.
  original_cast = base.method(:cast)
  base.define_singleton_method(:cast) do |obj, *params|
    if obj.class == GeoJSON::Feature
      original_cast.call(obj.geometry, *params)
    else
      original_cast.call(obj, *params)
    end
  end
end