spatial_features 2.10.9 → 2.11.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a716f42ee3c557baa01ea0a9e209f58e7bfb94163059057c7ff6fe303018de09
4
- data.tar.gz: 17b0fa1251fb09c2aef8d45f82adb89e2e5e141110c3b1a659b8f2b30ab28f07
3
+ metadata.gz: fb5268adbbf2c9b9019512e4d3617fc97c587497913202bf95c3dd35332497e8
4
+ data.tar.gz: 37928531494a21c1934425bb222759accdbfae763c7eb2e7f5570e8e17c69e42
5
5
  SHA512:
6
- metadata.gz: 3281304f2c534c57c98a2842cbf4cd77b14c59f3d54169c9ef0e39bd78b1f07e8ab775fe05cf575ee3f7443a3b13468638bebf3a7508e2931acfd0f4bacc96ea
7
- data.tar.gz: aaf5163cd6403673d418943585b20bd4817e6bfd4885fe08f4e663d29d003adfaa80e480f69554fe4f31522e4cbd9e695ac38c19d9797bbfe1d1c0fba5ccef4e
6
+ metadata.gz: d995ebde69133a39e99885ce694551d5bd64fb08a67b8e658d86138f56673b78a27f101f65cb86027e864d3fa0a3e2c05f43d944a3c55b2fac1a3e53a304715b
7
+ data.tar.gz: 99be0f11815754302e8b3f1cf50fa31964993fa43d2a1cc5a68e688eacb03d0d2116cea1ff71c7c7c8c2c99a7c7ae76c2dc83c0f6bef34ec525434bb990be2e1
@@ -40,6 +40,11 @@ class AbstractFeature < ActiveRecord::Base
40
40
  where(:feature_type => 'point')
41
41
  end
42
42
 
43
+ def self.within_distance(lat, lng, distance_in_meters)
44
+ # where("ST_DWithin(features.geog, ST_SetSRID( ST_Point( -71.104, 42.315), 4326)::geography, :distance)", :lat => lat, :lng => lng, :distance => distance_in_meters)
45
+ where("ST_DWithin(features.geog, ST_Point(:lng, :lat), :distance)", :lat => lat, :lng => lng, :distance => distance_in_meters)
46
+ end
47
+
43
48
  def self.area_in_square_meters(geom = 'geom_lowres')
44
49
  current_scope = all.polygons
45
50
  unscoped { connection.select_value(select("ST_Area(ST_Union(#{geom}))").from(current_scope, :features)).to_f }
@@ -81,6 +81,15 @@ module SpatialFeatures
81
81
  end
82
82
  end
83
83
 
84
+ def aggregate_features
85
+ type = base_class.to_s # Rails stores polymorphic foreign keys as the base class
86
+ if all == unscoped
87
+ AggregateFeature.where(:spatial_model_type => type)
88
+ else
89
+ AggregateFeature.where(:spatial_model_type => type, :spatial_model_id => all.unscope(:select))
90
+ end
91
+ end
92
+
84
93
  # Returns true if the model stores a hash of the features so we don't need to process the features if they haven't changed
85
94
  def has_spatial_features_hash?
86
95
  column_names.include? 'features_hash'
@@ -1,3 +1,3 @@
1
1
  module SpatialFeatures
2
- VERSION = "2.10.9"
2
+ VERSION = "2.11.0"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: spatial_features
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.10.9
4
+ version: 2.11.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ryan Wallace
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2020-05-30 00:00:00.000000000 Z
12
+ date: 2020-06-01 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rails