travlrmap 0.0.6 → 0.0.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.
data/Gemfile CHANGED
@@ -1,6 +1,8 @@
1
1
  source 'http://rubygems.org'
2
2
 
3
3
  gem 'sinatra'
4
- gem 'httparty', "0.11.0"
4
+ gem 'httparty', '0.11.0'
5
5
  gem 'json'
6
6
  gem 'gli'
7
+ gem 'ruby_kml'
8
+ gem 'nokogiri', '1.5.2'
@@ -1,6 +1,7 @@
1
1
  GEM
2
2
  remote: http://rubygems.org/
3
3
  specs:
4
+ builder (3.2.2)
4
5
  gli (2.12.2)
5
6
  httparty (0.11.0)
6
7
  multi_json (~> 1.0)
@@ -8,9 +9,13 @@ GEM
8
9
  json (1.8.1)
9
10
  multi_json (1.10.1)
10
11
  multi_xml (0.5.5)
12
+ nokogiri (1.5.2)
11
13
  rack (1.6.0)
12
14
  rack-protection (1.5.3)
13
15
  rack
16
+ ruby_kml (0.1.7)
17
+ builder
18
+ nokogiri
14
19
  sinatra (1.4.5)
15
20
  rack (~> 1.4)
16
21
  rack-protection (~> 1.4)
@@ -24,4 +29,6 @@ DEPENDENCIES
24
29
  gli
25
30
  httparty (= 0.11.0)
26
31
  json
32
+ nokogiri (= 1.5.2)
33
+ ruby_kml
27
34
  sinatra
@@ -25,8 +25,8 @@
25
25
 
26
26
  :types:
27
27
  :visit:
28
- :icon: /markers/mini-ORANGE-BLANK.png
28
+ :icon: http://your.site/markers/mini-ORANGE-BLANK.png
29
29
  :transit:
30
- :icon: /markers/mini-BLUE-BLANK.png
30
+ :icon: http://your.site/markers/mini-BLUE-BLANK.png
31
31
  :lived:
32
- :icon: /markers/mini-GREEN-BLANK.png
32
+ :icon: http://your.site/markers/mini-GREEN-BLANK.png
@@ -20,6 +20,10 @@ module Travlrmap
20
20
  alias_method :h, :escape_html
21
21
  end
22
22
 
23
+ def kml_style_url(type)
24
+ "travlrmap-%s-style" % type
25
+ end
26
+
23
27
  def load_map
24
28
  @points = []
25
29
 
@@ -40,6 +44,40 @@ module Travlrmap
40
44
  @pan_control = @map[:pan_control].nil? ? true : @map[:pan_control]
41
45
  end
42
46
 
47
+ def to_kml
48
+ kml = KMLFile.new
49
+ document = KML::Document.new(:name => "Travlrmap Data")
50
+ folder = KML::Folder.new(:name => "Countries")
51
+ folders = {}
52
+
53
+ @types.each do |k, t|
54
+ document.styles << KML::Style.new(
55
+ :id => kml_style_url(k),
56
+ :icon_style => KML::IconStyle.new(:icon => KML::Icon.new(:href => t[:icon]))
57
+ )
58
+ end
59
+
60
+ @points.sort_by{|p| p[:country]}.each do |point|
61
+ unless folders[point[:country]]
62
+ folder.features << folders[point[:country]] = KML::Folder.new(:name => point[:country])
63
+ end
64
+
65
+ f = folders[point[:country]]
66
+
67
+ f.features << KML::Placemark.new(
68
+ :name => point[:title],
69
+ :description => point[:comment],
70
+ :geometry => KML::Point.new(:coordinates => {:lat => point[:lat], :lng => point[:lon]}),
71
+ :style_url => "#%s" % kml_style_url(point[:type])
72
+ )
73
+ end
74
+
75
+ document.features << folder
76
+ kml.objects << document
77
+
78
+ kml.render
79
+ end
80
+
43
81
  get '/view/:view' do
44
82
  params[:view] ? view = params[:view].intern : view = :default
45
83
 
@@ -51,5 +89,10 @@ module Travlrmap
51
89
  set_map_vars(:default)
52
90
  erb :index
53
91
  end
92
+
93
+ get '/kml' do
94
+ content_type :"application/vnd.google-earth.kml+xml"
95
+ to_kml
96
+ end
54
97
  end
55
98
  end
@@ -1,3 +1,3 @@
1
1
  module Travlmap
2
- VERSION = "0.0.6"
2
+ VERSION = "0.0.7"
3
3
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: travlrmap
3
3
  version: !ruby/object:Gem::Version
4
- hash: 19
4
+ hash: 17
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 0
9
- - 6
10
- version: 0.0.6
9
+ - 7
10
+ version: 0.0.7
11
11
  platform: ruby
12
12
  authors:
13
13
  - R.I.Pienaar
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2014-12-21 00:00:00 +00:00
18
+ date: 2014-12-23 00:00:00 +00:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency