Class: AggregateFeature

Inherits:
AbstractFeature show all
Defined in:
app/models/aggregate_feature.rb

Constant Summary

Constants inherited from AbstractFeature

AbstractFeature::FEATURE_TYPES

Instance Method Summary collapse

Methods inherited from AbstractFeature

area_in_square_meters, cache_derivatives, #cache_derivatives, cache_key, #envelope, #feature_bounds, #geojson, geojson, intersecting, invalid, #kml, lines, #make_valid?, points, polygons, total_intersection_area_in_square_meters, valid, with_metadata

Instance Method Details

#refreshObject

Aggregate the features for the spatial model into a single feature



7
8
9
10
11
12
13
14
15
16
# File 'app/models/aggregate_feature.rb', line 7

def refresh
  self.geog = ActiveRecord::Base.connection.select_value "    SELECT ST_Collect(ARRAY[\n      (\#{features.select('ST_UNION(ST_CollectionExtract(geog::geometry, 1))').to_sql}),\n      (\#{features.select('ST_UNION(ST_CollectionExtract(geog::geometry, 2))').to_sql}),\n      (\#{features.select('ST_UNION(ST_CollectionExtract(geog::geometry, 3))').to_sql})\n    ])::geography\n  SQL\n  self.save!\nend\n"