spatial_features 2.10.6 → 2.10.7

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: bcb19db9366e628655a5197f84d4274271013822121071a820941237eeb86fa0
4
- data.tar.gz: ac12926f535a66226a8297f13e65dd7a2e5ef72315ecf816d4fe17d177a13b28
3
+ metadata.gz: e62668e5118907b61af7d07274b1e136086f9aa920b8bcbc3a415fd7ce1d7846
4
+ data.tar.gz: '090b0a6b28286e52c57079b4e51250c10280b9a185c938b055696607f7ac61be'
5
5
  SHA512:
6
- metadata.gz: a130a20a293bfa1f9fd79ba33bfb2f270b51bcdb612cefb054d2c48a390f66b55072a5e2a797d054b266800f2943b98cd93f6263b44fecc153e879c06b1e3d48
7
- data.tar.gz: 02cd94b02d8ae93a39f238e9ec66cd259d663943815677673c2c446621af8ccc9a0121d887445e1b8cf625c1a9d19b04eb80bc31863d350bfed860cde49f11d9
6
+ metadata.gz: '0293f1342cf5dd4f23c311d4efe555b74e2e0805ce31c35f8e5f711613415a065a23a3105622204358201ef5dac8f60a98bd66de66aebc3da1ed29954f4cca9d'
7
+ data.tar.gz: 357e67c32a156fa8fd3ed6d67edfaddde398346babc4f384c3e7ec41b77a5b28cdb215b49021bebe948c27f57ea1f95ac9889caa9f0ba6bce5cf5556b62f4e6a
@@ -143,6 +143,10 @@ class AbstractFeature < ActiveRecord::Base
143
143
  @make_valid
144
144
  end
145
145
 
146
+ def wkt
147
+ ActiveRecord::Base.connection.select_value("SELECT ST_ASEWKT('#{geom}')")
148
+ end
149
+
146
150
  private
147
151
 
148
152
  def make_valid
@@ -14,8 +14,10 @@ class AggregateFeature < AbstractFeature
14
14
  SQL
15
15
 
16
16
  # Remove empty features so ST_COLLECT doesn't choke. This seems to be a difference between PostGIS 2.x and 3.x
17
+ # NOTE: ST_CollectionHomogenize is used to normalize geometry representation in order to avoid a segmentation fault
18
+ # we were seeing when intersecting complex geometry.
17
19
  self.geog = ActiveRecord::Base.connection.select_value <<~SQL
18
- SELECT COALESCE(ST_Collect(unnest)::geography, ST_GeogFromText('MULTIPOLYGON EMPTY'))
20
+ SELECT COALESCE(ST_CollectionHomogenize(ST_Collect(unnest))::geography, ST_GeogFromText('MULTIPOLYGON EMPTY'))
19
21
  FROM (SELECT unnest(#{feature_array_sql})) AS features
20
22
  WHERE NOT ST_IsEmpty(unnest)
21
23
  SQL
@@ -142,9 +142,11 @@ module SpatialFeatures
142
142
  scope = features_scope(self).select("#{geom} AS geom").select(:spatial_model_id)
143
143
 
144
144
  other_scope = features_scope(other).select("ST_Union(#{geom}) AS geom")
145
-
146
145
  return joins(%Q(INNER JOIN (#{scope.to_sql}) AS #{table_alias} ON #{table_alias}.spatial_model_id = #{table_name}.id))
147
- .joins(%Q(INNER JOIN (#{other_scope.to_sql}) AS #{other_alias} ON ST_DWithin(#{table_alias}.geom, #{other_alias}.geom, #{buffer})))
146
+ .joins(%Q(INNER JOIN (#{other_scope.to_sql}) AS #{other_alias}
147
+ ON NOT ST_IsEmpty(#{table_alias}.geom) -- Can't ST_DWithin empty geometry
148
+ AND NOT ST_IsEmpty(#{other_alias}.geom) -- Can't ST_DWithin empty geometry
149
+ AND ST_DWithin(#{table_alias}.geom, #{other_alias}.geom, #{buffer})))
148
150
  end
149
151
 
150
152
  def features_scope(other)
@@ -1,3 +1,3 @@
1
1
  module SpatialFeatures
2
- VERSION = "2.10.6"
2
+ VERSION = "2.10.7"
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.6
4
+ version: 2.10.7
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-22 00:00:00.000000000 Z
12
+ date: 2020-05-23 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rails