spatial_features 2.4.2 → 2.4.3

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
  SHA1:
3
- metadata.gz: f6acc1a46c7687ff927a94e56123507706058d37
4
- data.tar.gz: e1f5bf281678659318cb8a809d2c1023248e5a36
3
+ metadata.gz: 68aa7bdc309d176e516eb2a32156373e0dbaad1c
4
+ data.tar.gz: 0c1a5d5153cc35ab38d5a37a96a9bafc4c154adc
5
5
  SHA512:
6
- metadata.gz: f8b977e8bdae0fb80bb20cc72cb12f1b50c879a06106b0238490fc407ce06cc85a77224458c23e94ce716761f8ca8f3caa4423312c34134152518153c421d7c1
7
- data.tar.gz: 705ab2d9a20c0e78d61d29220e100654d7fcc412880e2e1689ebe1d56b32e49863619db51b50a0842e01a8fe5b017d9c70209c5e351eac9bf35f6adb55bf5b41
6
+ metadata.gz: 77bf00cb03c9608d111c8474912d7bcd125746ae5e150fdf6d098cd1b6677ed182b162d3528bbf852c92322a126ea40ae2610a347ebb064d078ac94258f3a96b
7
+ data.tar.gz: c232858bf11da70cabe5dc7ea468524fed63c949f73e8b8b600fb38f940f7b55a48a8d30fcbd6fc44a85ef612f49081965f4ad86abf1d31e430517eb6da2d95c
@@ -1,9 +1,11 @@
1
- ActiveRecord::ConnectionAdapters::PostgreSQLAdapter.class_eval do
2
- def initialize_type_map_with_postgres_oids mapping
3
- initialize_type_map_without_postgres_oids mapping
1
+ module PostGISTypes
2
+ def initialize_type_map(mapping)
3
+ super
4
4
  register_class_with_limit mapping, 'geometry', ActiveRecord::ConnectionAdapters::PostgreSQLAdapter::OID::SpecializedString
5
5
  register_class_with_limit mapping, 'geography', ActiveRecord::ConnectionAdapters::PostgreSQLAdapter::OID::SpecializedString
6
6
  end
7
+ end
7
8
 
8
- alias_method_chain :initialize_type_map, :postgres_oids
9
+ ActiveRecord::ConnectionAdapters::PostgreSQLAdapter.class_eval do
10
+ prepend PostGISTypes
9
11
  end
@@ -3,12 +3,23 @@ module SpatialFeatures
3
3
  module API
4
4
  extend self
5
5
 
6
- FEATURE_COLUMNS = {:name => 'STRING', :spatial_model_type => 'STRING', :spatial_model_id => 'NUMBER', :kml_lowres => 'LOCATION', :colour => 'STRING'}
6
+ FEATURE_COLUMNS = {
7
+ :name => 'STRING',
8
+ :spatial_model_type => 'STRING',
9
+ :spatial_model_id => 'NUMBER',
10
+ :kml_lowres => 'LOCATION',
11
+ :colour => 'STRING',
12
+ :metadata => 'STRING'
13
+ }
7
14
  TABLE_STYLE = {
8
15
  :polygon_options => { :fill_color_styler => { :kind => 'fusiontables#fromColumn', :column_name => 'colour' }, :stroke_color => '#000000', :stroke_opacity => 0.2 },
9
16
  :polyline_options => { :stroke_color_styler => { :kind => 'fusiontables#fromColumn', :column_name => 'colour'} }
10
17
  }
11
18
 
19
+ TABLE_TEMPLATE = {
20
+ :body => "<h3>{name}</h3>{metadata}"
21
+ }
22
+
12
23
  def find_or_create_table(name)
13
24
  find_table(name) || create_table(name)
14
25
  end
@@ -17,6 +28,7 @@ module SpatialFeatures
17
28
  table_id = service.create_table(name, FEATURE_COLUMNS.collect {|name, type| {:name => name, :type => type} })
18
29
  service.share_table(table_id)
19
30
  service.insert_style(table_id, TABLE_STYLE)
31
+ service.insert_template(table_id, TABLE_TEMPLATE)
20
32
  return table_id
21
33
  end
22
34
 
@@ -46,7 +58,9 @@ module SpatialFeatures
46
58
  def features_to_csv(features)
47
59
  csv = CSV.generate do |csv|
48
60
  features.each do |feature|
49
- csv << FEATURE_COLUMNS.keys.collect {|attribute| feature.send(attribute) }
61
+ csv << FEATURE_COLUMNS.keys.collect do |attribute|
62
+ render_feature_attribute feature.send(attribute)
63
+ end
50
64
  end
51
65
  end
52
66
 
@@ -55,6 +69,17 @@ module SpatialFeatures
55
69
  return file
56
70
  end
57
71
 
72
+ def render_feature_attribute(value)
73
+ case value
74
+ when Hash
75
+ value.collect do |name, val|
76
+ "<b>#{name}:</b> #{val}"
77
+ end.join('<br/>')
78
+ else
79
+ value
80
+ end
81
+ end
82
+
58
83
  def colour_features(features, colour)
59
84
  case colour
60
85
  when Symbol
@@ -42,6 +42,15 @@ module SpatialFeatures
42
42
  fusion_tables_service.insert_style(table_id, style, :fields => 'styleId')
43
43
  end
44
44
 
45
+ def delete_template(table_id, template_id)
46
+ fusion_tables_service.delete_template(table_id, template_id, :fields => nil)
47
+ end
48
+
49
+ def insert_template(table_id, template)
50
+ template.reverse_merge! 'name' => 'default_table_template'
51
+ fusion_tables_service.insert_template(table_id, template, :fields => 'templateId')
52
+ end
53
+
45
54
  def delete_row(table_id, row_id)
46
55
  fusion_tables_service.sql_query("DELETE FROM #{table_id} WHERE ROWID = #{row_id}")
47
56
  end
@@ -1,3 +1,3 @@
1
1
  module SpatialFeatures
2
- VERSION = "2.4.2"
2
+ VERSION = "2.4.3"
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.4.2
4
+ version: 2.4.3
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: 2017-03-05 00:00:00.000000000 Z
12
+ date: 2017-09-04 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rails
@@ -31,14 +31,14 @@ dependencies:
31
31
  requirements:
32
32
  - - "~>"
33
33
  - !ruby/object:Gem::Version
34
- version: '4.0'
34
+ version: '4.1'
35
35
  type: :runtime
36
36
  prerelease: false
37
37
  version_requirements: !ruby/object:Gem::Requirement
38
38
  requirements:
39
39
  - - "~>"
40
40
  - !ruby/object:Gem::Version
41
- version: '4.0'
41
+ version: '4.1'
42
42
  - !ruby/object:Gem::Dependency
43
43
  name: rgeo-shapefile
44
44
  requirement: !ruby/object:Gem::Requirement
@@ -196,7 +196,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
196
196
  version: '0'
197
197
  requirements: []
198
198
  rubyforge_project:
199
- rubygems_version: 2.5.2
199
+ rubygems_version: 2.6.12
200
200
  signing_key:
201
201
  specification_version: 4
202
202
  summary: Adds spatial methods to a model.