travlrmap 0.0.6 → 0.0.7
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile +3 -1
- data/Gemfile.lock +7 -0
- data/config/travlrmap.yaml.dist +3 -3
- data/lib/travlrmap/sinatra_app.rb +43 -0
- data/lib/travlrmap/version.rb +1 -1
- metadata +4 -4
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
@@ -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
|
data/config/travlrmap.yaml.dist
CHANGED
@@ -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
|
data/lib/travlrmap/version.rb
CHANGED
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:
|
4
|
+
hash: 17
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 0
|
9
|
-
-
|
10
|
-
version: 0.0.
|
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-
|
18
|
+
date: 2014-12-23 00:00:00 +00:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|