spatial_features 1.6.1 → 1.7.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 +4 -4
- data/README.md +3 -1
- data/app/models/feature.rb +14 -10
- data/lib/spatial_features/has_spatial_features.rb +2 -2
- data/lib/spatial_features/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 10ff909874fdd64f019a564dda17df6d63d6b405
|
4
|
+
data.tar.gz: bfcdee15505529b1142110722312c793821f3f16
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 59d516201f42433921e1def7cec21a42b17ba8340232dfef479b840b45c6e89334eced10212d47c3742b2c15f87a9d2ac50a17cca525847d861462f9b48a7d2a
|
7
|
+
data.tar.gz: 027192a3d69ebb10e98719fd1154e691d82ea2211faa925d785391a2f2325fd43caca1249476d8d590db9ad5ac49e66154dcd687fa8b27b4da61bd4631f6bf81
|
data/README.md
CHANGED
data/app/models/feature.rb
CHANGED
@@ -64,21 +64,23 @@ class Feature < ActiveRecord::Base
|
|
64
64
|
options.reverse_merge! :lowres_simplification => 2, :lowres_precision => 5
|
65
65
|
|
66
66
|
update_all <<-SQL.squish
|
67
|
-
geom
|
68
|
-
north
|
69
|
-
east
|
70
|
-
south
|
71
|
-
west
|
72
|
-
area
|
67
|
+
geom = ST_Transform(geog::geometry, #{detect_srid('geom')}),
|
68
|
+
north = ST_YMax(geog::geometry),
|
69
|
+
east = ST_XMax(geog::geometry),
|
70
|
+
south = ST_YMin(geog::geometry),
|
71
|
+
west = ST_XMin(geog::geometry),
|
72
|
+
area = ST_Area(geog),
|
73
|
+
centroid = ST_PointOnSurface(geog::geometry)
|
73
74
|
SQL
|
74
75
|
|
75
76
|
update_all <<-SQL.squish
|
76
|
-
geom_lowres
|
77
|
+
geom_lowres = ST_SimplifyPreserveTopology(geom, #{options[:lowres_simplification]})
|
77
78
|
SQL
|
78
79
|
|
79
80
|
update_all <<-SQL.squish
|
80
|
-
kml
|
81
|
-
kml_lowres
|
81
|
+
kml = ST_AsKML(geog, 6),
|
82
|
+
kml_lowres = ST_AsKML(geom_lowres, #{options[:lowres_precision]}),
|
83
|
+
kml_centroid = ST_AsKML(centroid)
|
82
84
|
SQL
|
83
85
|
end
|
84
86
|
|
@@ -91,7 +93,9 @@ class Feature < ActiveRecord::Base
|
|
91
93
|
end
|
92
94
|
|
93
95
|
def kml(options = {})
|
94
|
-
options[:lowres] ? kml_lowres : super()
|
96
|
+
geometry = options[:lowres] ? kml_lowres : super()
|
97
|
+
geometry = "<MultiGeometry>#{geometry}#{kml_centroid}</MultiGeometry>" if options[:centroid]
|
98
|
+
return geometry
|
95
99
|
end
|
96
100
|
|
97
101
|
private
|
@@ -10,7 +10,7 @@ module SpatialFeatures
|
|
10
10
|
scope :without_features, lambda { joins("LEFT OUTER JOIN features ON features.spatial_model_type = '#{name}' AND features.spatial_model_id = #{table_name}.id").where("features.id IS NULL") }
|
11
11
|
|
12
12
|
scope :with_spatial_cache, lambda {|klass| joins(:spatial_cache).where(:spatial_caches => { :intersection_model_type => klass }).uniq }
|
13
|
-
scope :without_spatial_cache, lambda {|klass|
|
13
|
+
scope :without_spatial_cache, lambda {|klass| joins("LEFT OUTER JOIN #{SpatialCache.table_name} ON spatial_model_id = #{table_name}.id AND spatial_model_type = '#{name}' and intersection_model_type = '#{klass}'").where('spatial_model_id IS NULL') }
|
14
14
|
scope :with_stale_spatial_cache, lambda { joins(:spatial_cache).where("#{table_name}.features_hash != spatial_caches.features_hash").uniq } if has_spatial_features_hash?
|
15
15
|
|
16
16
|
has_many :spatial_cache, :as => :spatial_model, :dependent => :delete_all
|
@@ -127,7 +127,7 @@ module SpatialFeatures
|
|
127
127
|
end
|
128
128
|
|
129
129
|
scope = scope.select("MIN(ST_Distance(features.geom, features_for_other.geom)) AS distance_in_meters") if options[:distance]
|
130
|
-
scope = scope.select("ST_Area(ST_Intersection(
|
130
|
+
scope = scope.select("ST_Area(ST_UNION(ST_Intersection(features.geom, features_for_other.geom))) AS intersection_area_in_square_meters") if options[:intersection_area]
|
131
131
|
return scope
|
132
132
|
end
|
133
133
|
|
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: 1.
|
4
|
+
version: 1.7.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: 2016-08-
|
12
|
+
date: 2016-08-16 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rails
|