lib/spatial_features/models/feature.rb in spatial_features-0.0.4 vs lib/spatial_features/models/feature.rb in spatial_features-0.0.5

- old
+ new

@@ -32,10 +32,11 @@ def self.invalid select('features.*, ST_IsValidReason(geog::geometry) AS invalid_geometry_message').where.not('ST_IsValid(geog::geometry)') end def envelope(buffer_in_meters = 0) - self.class.select("ST_Envelope(ST_Buffer(features.geog, #{buffer_in_meters})::geometry) AS result").where(:id => id).first.result.exterior_ring.points.values_at(0,2) + envelope_json = JSON.parse(self.class.select("ST_AsGeoJSON(ST_Envelope(ST_Buffer(features.geog, #{buffer_in_meters})::geometry)) AS result").where(:id => id).first.result) + envelope_json["coordinates"].first.values_at(0,2) end private def cache_derivatives