Skip to content

Commit 7079d55

Browse files
committed
Remove feature conversion file. Add meaning of some features and colours
- The features are now documented at https://shelterapp.dk/api/features/. - Updated the features. - Found out that DOS format CRLF is NOT necessary - Introduced colours for some specific shelters.
1 parent 7bd2e07 commit 7079d55

File tree

3 files changed

+92
-60
lines changed

3 files changed

+92
-60
lines changed

shelters/features_conversion

Lines changed: 0 additions & 12 deletions
This file was deleted.

shelters/shelters-json-to-kml.rb

Lines changed: 59 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -14,47 +14,77 @@
1414

1515
shelters = JSON.parse(File.read(shelters_file))
1616

17-
printf("%s\r\n",'<?xml version="1.0" encoding="UTF-8"?>')
18-
printf("%s\r\n",'<kml xmlns="http://earth.google.com/kml/2.0">')
19-
printf("<Document>\r\n")
20-
printf("<name>Shelters in Denmark.</name>\r\n")
17+
printf("%s\n",'<?xml version="1.0" encoding="UTF-8"?>')
18+
printf("%s\n",'<kml xmlns="http://earth.google.com/kml/2.0">')
19+
printf("<Document>\n")
20+
printf("<name>Shelters in Denmark.</name>\n")
2121
shelters.each do |shelter|
22-
printf("<Placemark>\r\n<styleUrl>#placemark-orange</styleUrl>\r\n<name>%s</name>\r\n<description>", shelter['name'].gsub(/"/, '').gsub(/&/, '&amp;'))
22+
printf("<Placemark>\n<name>%s</name>\n<description>\n", shelter['name'].gsub(/"/, '').gsub(/&/, '&amp;'))
2323
printf("Address: %s, ", shelter['address']) unless ( shelter['address'] == '' )
24-
counter = 1
25-
shelter['features'].each do |x|
26-
case x
27-
when 9002
28-
printf("Has WC")
29-
when 9001
30-
printf("Has Primitive Toilet")
31-
when 9000
32-
printf("No information on toilet")
24+
25+
# Process the features. Documented at https://shelterapp.dk/api/features/
26+
shelter['features'].each do |feature|
27+
case feature
28+
when 0
29+
printf("Putting up a tent is allowed.")
3330
when 1
34-
printf("Is accessible for disabled")
31+
printf("Is accessible for disabled.")
3532
when 6
36-
printf("Has access to drinking water")
33+
printf("Has access to drinking water.")
3734
when 9
38-
printf("Has shelter")
35+
printf("Has shelter.")
3936
when 10
40-
printf("Has fireplace")
37+
printf("Has fireplace.")
4138
when 11
42-
printf("Is accessible via Cano")
39+
printf("Is accessible via Cano.")
4340
when 12
44-
printf("Has shower facilities")
41+
printf("Has shower facilities.")
4542
when 13
46-
printf("Dogs allowed")
43+
printf("Dogs allowed.")
4744
when 14
48-
printf("Horses allowed")
45+
printf("Horses allowed.")
4946
when 15
50-
printf("Accessible with baby stroller")
47+
printf("Accessible with baby stroller.")
48+
when 3081
49+
printf("Has space for hammock.")
50+
when 9000
51+
printf("No information on toilet.")
52+
when 9001
53+
printf("Has Primitive Toilet.")
54+
when 9002
55+
printf("Has WC.")
56+
when 9003
57+
printf("Is bookable.")
58+
when 9004
59+
printf("Is paid.")
60+
when 9005
61+
printf("There are photo's in the app.")
5162
else
52-
printf("This shelter has an unknown feature: %i. That's exciting! What will it be?", x)
63+
printf("This shelter has an unknown feature: %i. That's exciting! What will it be?", feature)
5364
end
54-
printf(", ") if ( counter < shelter['features'].count )
55-
counter += 1
65+
printf("\n")
5666
end
57-
printf("Booking possible") if ( shelter['booking'] == 1 )
58-
printf("</description>\r\n<Point><coordinates>%s,%s,0</coordinates></Point>\r\n</Placemark>\r\n", shelter['longitude'], shelter['latitude'])
67+
# Default the colour is yellow
68+
icon_colour = "yellow"
69+
70+
# Green if only a tent is allowed
71+
icon_colour = "green" if ( shelter['features'].include?(0) )
72+
73+
# Orange if there is a shelter and a tent is allowed
74+
icon_colour = "orange" if ( shelter['features'].include?(9) and shelter['features'].include?(0) )
75+
76+
# Pink if there is a shelter and a tent is allowed and it has water and a toilet
77+
icon_colour = "pink" if ( shelter['features'].include?(9) and shelter['features'].include?(0) and shelter['features'].include?(6) and ( shelter['features'].include?(9001) or shelter['features'].include?(9002) ) )
78+
79+
# Blue if there is a shelter and NO tent is explicitly allowed
80+
icon_colour = "blue" if ( shelter['features'].include?(9) and !shelter['features'].include?(0) )
81+
82+
# Purple if it's a paid shelterplace OR reservation is possible
83+
icon_colour = "purple" if ( shelter['features'].include?(9004) or shelter['features'].include?(9003) )
84+
85+
# Red if it's a paid shelterplace with reservation
86+
icon_colour = "red" if ( shelter['features'].include?(9004) and shelter['features'].include?(9003) )
87+
88+
printf("</description>\n<Point><coordinates>%s,%s,0</coordinates>\n</Point>\n<styleUrl>#placemark-%s</styleUrl>\n</Placemark>\n", shelter['longitude'], shelter['latitude'], icon_colour)
5989
end
60-
printf("%s\r\n%s", '</Document>', '</kml>')
90+
printf("%s\n%s", '</Document>', '</kml>')

shelters/shelters-json-to-poi.rb

Lines changed: 33 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -16,35 +16,49 @@
1616

1717
shelters.each do |shelter|
1818
printf("%s,%s,\"%s\",\"Features:\n", shelter['longitude'], shelter['latitude'], shelter['name'].gsub(/"/, ''))
19-
shelter['features'].each do |x|
20-
case x
21-
when 9002
22-
puts "WC"
23-
when 9001
24-
puts "Primitive Toilet"
25-
when 9000
26-
puts "No information on toilet"
19+
printf("Address: %s\n", shelter['address']) unless ( shelter['address'] == '' )
20+
21+
# Process the features. Documented at https://shelterapp.dk/api/features/
22+
shelter['features'].each do |feature|
23+
case feature
24+
when 0
25+
printf("Putting up a tent is allowed.")
2726
when 1
28-
puts "Accessible for disabled"
27+
printf("Is accessible for disabled.")
2928
when 6
30-
puts "Access to drinking water"
29+
printf("Has access to drinking water.")
3130
when 9
32-
puts "Has shelter"
31+
printf("Has shelter.")
3332
when 10
34-
puts "Has fireplace"
33+
printf("Has fireplace.")
3534
when 11
36-
puts "Accessible via Cano"
35+
printf("Is accessible via Cano.")
3736
when 12
38-
puts "Has shower facilities"
37+
printf("Has shower facilities.")
3938
when 13
40-
puts "Dogs allowed"
39+
printf("Dogs allowed.")
4140
when 14
42-
puts "Horses allowed"
41+
printf("Horses allowed.")
4342
when 15
44-
puts "Accessible with baby stroller"
43+
printf("Accessible with baby stroller.")
44+
when 3081
45+
printf("Has space for hammock.")
46+
when 9000
47+
printf("No information on toilet.")
48+
when 9001
49+
printf("Has Primitive Toilet.")
50+
when 9002
51+
printf("Has WC.")
52+
when 9003
53+
printf("Is bookable.")
54+
when 9004
55+
printf("Is paid.")
56+
when 9005
57+
printf("There are photo's in the app.")
58+
else
59+
printf("This shelter has an unknown feature: %i. That's exciting! What will it be?", feature)
4560
end
61+
printf("\n")
4662
end
47-
printf("Address: %s\n", shelter['address']) unless ( shelter['address'] == '' )
48-
printf("Booking possible\n") if ( shelter['booking'] == 1 )
4963
printf("\"\n")
5064
end

0 commit comments

Comments
 (0)