spatial_features 2.8.1 → 2.9.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/models/abstract_feature.rb +25 -0
- data/app/models/aggregate_feature.rb +2 -0
- data/config/initializers/mime_types.rb +1 -0
- data/lib/spatial_features/version.rb +1 -1
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 17c8fdb48ee250613d98e9e0bd615a673c6ec4c19e470ca7ecf30d9697b9391a
|
4
|
+
data.tar.gz: feea9dc4293d2f5003f7d69a62b56cb180ccd79588ca03779430a6cc178e33d4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 76cc314c548cfbb14f51d4979b574c4735aecb97f65e1e99387d83cb426917ae031286c8b2a5ac1193643ba2858e0c3cfcac27d079368ab4ddf617a389fbb721
|
7
|
+
data.tar.gz: 4bb9f272f48e30324df8e4f545a7ba0b953b24b76ecf5499d4f237971db73dc20a4ba5d0c8a0bcf6b33610ffe229f29839be5c9357e330292fc4b3ce6c63a613
|
@@ -100,6 +100,27 @@ class AbstractFeature < ActiveRecord::Base
|
|
100
100
|
SQL
|
101
101
|
end
|
102
102
|
|
103
|
+
def self.geojson(lowres: false, precision: 6, properties: {}, srid: 4326) # default srid is 4326 so output is Google Maps compatible
|
104
|
+
column = lowres ? "ST_Transform(geom_lowres, #{srid})" : 'geog'
|
105
|
+
properties_sql = <<~SQL if properties.present?
|
106
|
+
, 'properties', json_build_object(#{properties.map {|k,v| "'#{k}',#{v}" }.join(',') })
|
107
|
+
SQL
|
108
|
+
|
109
|
+
sql = <<~SQL
|
110
|
+
json_build_object(
|
111
|
+
'type', 'FeatureCollection',
|
112
|
+
'features', json_agg(
|
113
|
+
json_build_object(
|
114
|
+
'type', 'Feature',
|
115
|
+
'geometry', ST_AsGeoJSON(#{column}, #{precision})::json
|
116
|
+
#{properties_sql}
|
117
|
+
)
|
118
|
+
)
|
119
|
+
)
|
120
|
+
SQL
|
121
|
+
connection.select_value(all.select(sql))
|
122
|
+
end
|
123
|
+
|
103
124
|
def feature_bounds
|
104
125
|
{n: north, e: east, s: south, w: west}
|
105
126
|
end
|
@@ -114,6 +135,10 @@ class AbstractFeature < ActiveRecord::Base
|
|
114
135
|
return geometry
|
115
136
|
end
|
116
137
|
|
138
|
+
def geojson(*args)
|
139
|
+
self.class.where(id: id).geojson(*args)
|
140
|
+
end
|
141
|
+
|
117
142
|
def make_valid?
|
118
143
|
@make_valid
|
119
144
|
end
|
@@ -1,3 +1,5 @@
|
|
1
|
+
require_dependency SpatialFeatures::Engine.root.join('app/models/abstract_feature')
|
2
|
+
|
1
3
|
class AggregateFeature < AbstractFeature
|
2
4
|
has_many :features, lambda { |aggregate| where(:spatial_model_type => aggregate.spatial_model_type) }, :foreign_key => :spatial_model_id, :primary_key => :spatial_model_id
|
3
5
|
|
@@ -0,0 +1 @@
|
|
1
|
+
Mime::Type.register "application/vnd.geo+json", :geojson
|
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.
|
4
|
+
version: 2.9.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: 2019-
|
12
|
+
date: 2019-12-07 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rails
|
@@ -173,6 +173,7 @@ files:
|
|
173
173
|
- app/models/spatial_cache.rb
|
174
174
|
- app/models/spatial_proximity.rb
|
175
175
|
- config/initializers/chroma_serializers.rb
|
176
|
+
- config/initializers/mime_types.rb
|
176
177
|
- config/initializers/register_oids.rb
|
177
178
|
- lib/spatial_features.rb
|
178
179
|
- lib/spatial_features/caching.rb
|
@@ -220,7 +221,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
220
221
|
version: '0'
|
221
222
|
requirements: []
|
222
223
|
rubyforge_project:
|
223
|
-
rubygems_version: 2.7.
|
224
|
+
rubygems_version: 2.7.9
|
224
225
|
signing_key:
|
225
226
|
specification_version: 4
|
226
227
|
summary: Adds spatial methods to a model.
|