Module: SpatialFeatures::FusionTables::API
Constant Summary collapse
- FEATURE_COLUMNS =
{:name => 'STRING', :spatial_model_type => 'STRING', :spatial_model_id => 'NUMBER', :kml_lowres => 'LOCATION', :colour => 'STRING'}
- TABLE_STYLE =
{ :polygon_options => { :fill_color_styler => { :kind => 'fusiontables#fromColumn', :column_name => 'colour' }, :stroke_color => '#000000', :stroke_opacity => 0.2 }, :polyline_options => { :stroke_color_styler => { :kind => 'fusiontables#fromColumn', :column_name => 'colour'} } }
Instance Method Summary collapse
- #create_table(name) ⇒ Object
- #delete_table(table_id) ⇒ Object
- #find_or_create_table(name) ⇒ Object
- #find_table(name) ⇒ Object
- #service ⇒ Object
- #set_features(table_id, features, colour: nil) ⇒ Object
- #tables ⇒ Object
Instance Method Details
#create_table(name) ⇒ Object
16 17 18 19 20 21 |
# File 'lib/spatial_features/has_fusion_table_features/api.rb', line 16 def create_table(name) table_id = service.create_table(name, FEATURE_COLUMNS.collect {|name, type| {:name => name, :type => type} }) service.share_table(table_id) service.insert_style(table_id, TABLE_STYLE) return table_id end |
#delete_table(table_id) ⇒ Object
27 28 29 |
# File 'lib/spatial_features/has_fusion_table_features/api.rb', line 27 def delete_table(table_id) service.delete_table(table_id) end |
#find_or_create_table(name) ⇒ Object
12 13 14 |
# File 'lib/spatial_features/has_fusion_table_features/api.rb', line 12 def find_or_create_table(name) find_table(name) || create_table(name) end |
#find_table(name) ⇒ Object
23 24 25 |
# File 'lib/spatial_features/has_fusion_table_features/api.rb', line 23 def find_table(name) service.tables.find {|table| table.name == name }.try(:table_id) end |
#service ⇒ Object
40 41 42 |
# File 'lib/spatial_features/has_fusion_table_features/api.rb', line 40 def service @service ||= Service.new(Configuration.service_account_credentials) end |
#set_features(table_id, features, colour: nil) ⇒ Object
35 36 37 38 |
# File 'lib/spatial_features/has_fusion_table_features/api.rb', line 35 def set_features(table_id, features, colour: nil) colour_features(features, colour) service.replace_rows(table_id, features_to_csv(features)) end |
#tables ⇒ Object
31 32 33 |
# File 'lib/spatial_features/has_fusion_table_features/api.rb', line 31 def tables service.tables end |