lib/spatial_features/models/feature.rb in spatial_features-1.0.0 vs lib/spatial_features/models/feature.rb in spatial_features-1.0.1

- old
+ new

@@ -33,10 +33,14 @@ select('features.*, ST_IsValidReason(geog::geometry) AS invalid_geometry_message').where.not('ST_IsValid(geog::geometry)') end def envelope(buffer_in_meters = 0) 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) + envelope_json = envelope_json["coordinates"].first + + raise "Can't calculate envelope for Feature #{self.id}" if envelope_json.blank? + + return envelope_json.values_at(0,2) end private def cache_derivatives