@@ -7,7 +7,7 @@ class AbstractFeature < ActiveRecord::Base
77 class_attribute :lowres_simplification
88 self . lowres_simplification = 2 # Threshold in meters
99
10- belongs_to :spatial_model , : polymorphic => :true , : autosave => false
10+ belongs_to :spatial_model , polymorphic : :true , autosave : false
1111
1212 attr_writer :make_valid
1313
@@ -16,7 +16,7 @@ class AbstractFeature < ActiveRecord::Base
1616 validates_presence_of :geog
1717 validate :validate_geometry , if : :will_save_change_to_geog?
1818 before_save :sanitize , if : :will_save_change_to_geog?
19- after_save :cache_derivatives , :if => [ :automatically_cache_derivatives? , :saved_change_to_geog? ]
19+ after_save :cache_derivatives , if : [ :automatically_cache_derivatives? , :saved_change_to_geog? ]
2020
2121 def self . cache_key
2222 collection_cache_key
@@ -41,15 +41,15 @@ def self.metadata_keys
4141 end
4242
4343 def self . polygons
44- where ( : feature_type => 'polygon' )
44+ where ( feature_type : 'polygon' )
4545 end
4646
4747 def self . lines
48- where ( : feature_type => 'line' )
48+ where ( feature_type : 'line' )
4949 end
5050
5151 def self . points
52- where ( : feature_type => 'point' )
52+ where ( feature_type : 'point' )
5353 end
5454
5555 def self . within_distance_of_point ( lat , lng , distance_in_meters , geom = 'geom_lowres' )
@@ -59,7 +59,7 @@ def self.within_distance_of_point(lat, lng, distance_in_meters, geom = 'geom_low
5959 else "ST_Transform(ST_SetSRID(ST_Point(:lng, :lat), 4326), #{ detect_srid ( geom ) } )"
6060 end
6161
62- binds = { : lng => lng . to_d , : lat => lat . to_d }
62+ binds = { lng : lng . to_d , lat : lat . to_d }
6363
6464 within_distance_of_sql ( point_sql , distance_in_meters , geom , **binds )
6565 end
@@ -71,7 +71,7 @@ def self.within_distance_of_line(points, distance_in_meters, geom = 'geom_lowres
7171 else "ST_Transform(ST_SetSRID(:points::geometry, 4326), #{ detect_srid ( geom ) } )"
7272 end
7373
74- binds = { : points => "LINESTRING(#{ points . map { |coords | coords . join ( ' ' ) } . join ( ', ' ) } )" }
74+ binds = { points : "LINESTRING(#{ points . map { |coords | coords . join ( ' ' ) } . join ( ', ' ) } )" }
7575
7676 within_distance_of_sql ( point_sql , distance_in_meters , geom , **binds )
7777 end
@@ -83,14 +83,14 @@ def self.within_distance_of_polygon(points, distance_in_meters, geom = 'geom_low
8383 else "ST_Transform(ST_Polygon(:points::geometry, 4326), #{ detect_srid ( geom ) } )"
8484 end
8585
86- binds = { : points => "LINESTRING(#{ points . map { |coords | coords . join ( ' ' ) } . join ( ', ' ) } )" }
86+ binds = { points : "LINESTRING(#{ points . map { |coords | coords . join ( ' ' ) } . join ( ', ' ) } )" }
8787
8888 within_distance_of_sql ( point_sql , distance_in_meters , geom , **binds )
8989 end
9090
9191 def self . within_distance_of_sql ( geometry_sql , distance_in_meters , features_column = 'geom_lowres' , **binds )
9292 if distance_in_meters . to_f > 0
93- where ( "ST_DWithin(features.#{ features_column } , #{ geometry_sql } , :distance)" , **binds , : distance => distance_in_meters )
93+ where ( "ST_DWithin(features.#{ features_column } , #{ geometry_sql } , :distance)" , **binds , distance : distance_in_meters )
9494 else
9595 where ( "ST_Intersects(features.#{ features_column } , #{ geometry_sql } )" , **binds )
9696 end
@@ -128,7 +128,7 @@ def self.valid
128128 end
129129
130130 def envelope ( buffer_in_meters = 0 )
131- 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 )
131+ 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 )
132132 envelope_json = envelope_json [ "coordinates" ] . first
133133
134134 raise "Can't calculate envelope for Feature #{ self . id } " if envelope_json . blank?
@@ -257,12 +257,12 @@ def bounds
257257 end
258258
259259 def cache_derivatives ( *args )
260- self . class . default_scoped . where ( :id => self . id ) . cache_derivatives ( *args )
260+ self . class . default_scoped . where ( id : self . id ) . cache_derivatives ( *args )
261261 end
262262
263263 def kml ( options = { } )
264264 column = options [ :lowres ] ? 'geom_lowres' : 'geog'
265- return SpatialFeatures ::Utils . select_db_value ( self . class . where ( :id => id ) . select ( "ST_AsKML(#{ column } , 6)" ) )
265+ return SpatialFeatures ::Utils . select_db_value ( self . class . where ( id : id ) . select ( "ST_AsKML(#{ column } , 6)" ) )
266266 end
267267
268268 def geojson ( *args )
@@ -290,7 +290,7 @@ def self.detect_srid(column_name)
290290 end
291291
292292 def self . join_other_features ( other )
293- joins ( 'INNER JOIN features AS other_features ON true' ) . where ( : other_features => { :id => other } )
293+ joins ( 'INNER JOIN features AS other_features ON true' ) . where ( other_features : { id : other } )
294294 end
295295
296296 def validate_geometry
0 commit comments