spatial_features 2.11.1 → 2.12.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 6c14269424ac2b30935b7f291f51080271e0932c400036bf5156223325ead8ba
4
- data.tar.gz: d715d47e9dfa87eee07e01bc71b03dc9af5ceb6415552f24663eef9a8d81bda6
3
+ metadata.gz: '035228e67c042788f246694fb215346e72303a7eebe7052cec11a01db0b26ab7'
4
+ data.tar.gz: 4361a0cf3ffa83dfddbe54a35717b2dd31633245fc28438dace60675a2058147
5
5
  SHA512:
6
- metadata.gz: 2b7fef2ae89493b544b46896136bddcd59afc470db34be530c2763cede9dca82082c695056583aa7665f03dab0c21f87d16429cc37d74682cf9ac984956c83cb
7
- data.tar.gz: 16bc0f99d7249a85f0c48e07f0b9dd5b02058fa307c4eea20142dedf6e695b9c035528d26b26c22dc9ec420247d36a4f8476f8e5b5a0fe865bac68650d64ecfb
6
+ metadata.gz: c0e3d96ed8f19a968fbb1ff9fb583091cd7a6565a86d288977baf87eeea6be0412ee52321a24a911baaeb5326d1aa32bf65c176a992d1357e0055c06ad580bb5
7
+ data.tar.gz: 796f292feae7681fd6e4f6b3785421932d9a0a00585b17a5506c25f6399047cb04119e2bcae4db48f1418cace52267821a898fcbd84c1460026bb3dd8cabae26
@@ -148,6 +148,10 @@ class AbstractFeature < ActiveRecord::Base
148
148
  @make_valid
149
149
  end
150
150
 
151
+ def wkt
152
+ ActiveRecord::Base.connection.select_value("SELECT ST_ASEWKT('#{geom}')")
153
+ end
154
+
151
155
  private
152
156
 
153
157
  def make_valid
@@ -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'
@@ -67,9 +67,10 @@ module SpatialFeatures
67
67
  private
68
68
 
69
69
  def spatial_feature_imports(import_options, make_valid)
70
- import_options.collect do |data_method, importer_name|
71
- data = send(data_method)
72
- spatial_importer_from_name(importer_name).new(data, :make_valid => make_valid) if data.present?
70
+ import_options.flat_map do |data_method, importer_name|
71
+ Array.wrap(send(data_method)).map do |data|
72
+ spatial_importer_from_name(importer_name).new(data, :make_valid => make_valid) if data.present?
73
+ end
73
74
  end.compact
74
75
  end
75
76
 
@@ -1,3 +1,3 @@
1
1
  module SpatialFeatures
2
- VERSION = "2.11.1"
2
+ VERSION = "2.12.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.11.1
4
+ version: 2.12.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-06-11 00:00:00.000000000 Z
12
+ date: 2020-06-14 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rails