summaryrefslogtreecommitdiffstats
path: root/sci-geosciences/happycamel/files/happycamel-ds-icons.patch
blob: 439f0492b08e751e9966367897ea0075161e66f2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
diff -dPNur HappyCamel.current/cli.py HappyCamel/cli.py
--- HappyCamel.current/cli.py	2013-08-27 05:13:35.000000000 +0200
+++ HappyCamel/cli.py	2013-09-24 19:46:02.000000000 +0200
@@ -257,6 +257,10 @@
                        var = "show_waypoints",
                        default = defaults["show_waypoints"],
                        help = "Show the waypoints in the KMZ file. Currently set to %default.")
+      parser.addOption("--google-maps", type = "bool", bool_action = True,
+                       var = "for_google_maps",
+                       default = defaults["for_google_maps"],
+                       help = "Generate for google-maps. Currently set to %default.")
 
     # The options relating to image parsing
     parser.addHelpRule("\nUsually, metadata is read through the internal library, but written through the external Exiftool command. Using Exiftool is much slower, but using the internal library for writing carries some risk as it is not as mature.\nThe following options influence this behavior:")
@@ -333,6 +337,7 @@
       options["between_color"]  = False
       options["between_width"]  = False
       options["show_waypoints"] = False
+      options["for_google_maps"]= True
 
     # Check if the user specified any photo's
     if (len(args) < 1) and not (options["report_times"] or options["save_config"]):
diff -dPNur HappyCamel.current/config.py HappyCamel/config.py
--- HappyCamel.current/config.py	2013-08-27 05:13:35.000000000 +0200
+++ HappyCamel/config.py	2013-09-24 19:46:49.000000000 +0200
@@ -77,6 +77,7 @@
     "between_color":       [str,   "KMZ File", "Between color", "60ffffff"],
     "between_width":       [float, "KMZ File", "Between width", 2.0],
     "show_waypoints":      [bool,  "KMZ File", "Show waypoints", False],
+    "for_google_maps":     [bool,  "KMZ File", "Generate for Google Maps", True],
     "order":               [str,   "KMZ File", "Order", "D"],
     "image_size":          [int,   "KMZ File", "Pixels", 200],
     "icon_size":           [int,   "KMZ File", "Icon pixels", 0],
diff -dPNur HappyCamel.current/kmlhandler.py HappyCamel/kmlhandler.py
--- HappyCamel.current/kmlhandler.py	2013-08-27 05:13:35.000000000 +0200
+++ HappyCamel/kmlhandler.py	2013-09-24 19:53:49.000000000 +0200
@@ -59,7 +59,7 @@
     self.between_tracks_width = between_tracks_width
 
   def writeKML(self, out_fp, write_photos = True, write_waypoints = True,
-               write_track = True, write_between_tracks = True):
+               write_track = True, write_between_tracks = True, for_google_maps = True):
     """ Write a KML file to the specified file pointer out_fp. The arguments
         specify which parts of the file should be included. If write_photos is
         True, thumbnails should be included. If write_waypoints is True,
@@ -80,7 +80,7 @@
 
     if (write_photos):
       self.logger.debug("Writing photo folder")
-      self.writePhotos(out_fp)
+      self.writePhotos(out_fp, for_google_maps)
 
     if (write_waypoints):
       self.logger.debug("Writing waypoints folder")
@@ -92,7 +92,7 @@
 
     out_fp.write('</Document>\n')
 
-  def writePhotos(self, out_fp):
+  def writePhotos(self, out_fp, for_google_maps):
     """ Write the photo references with comments and stuff to the file pointer
         out_fp . """
 
@@ -116,10 +116,9 @@
     out_fp.write('<Folder>\n')
     out_fp.write('  <name>Images</name>\n')
     # Write each thumbnail as a placemark
+
     for photo in self.photo_list:
       if (photo in self.thumbnail_names): # Only process if there's a thumbnail
-        location = photo.getLocation()
-
 	if (self.use_icons):
 	  out_fp.write('  <Style id="photo_%s">\n' % self.thumbnail_names[photo])
 	  out_fp.write('    <IconStyle>\n')
@@ -133,6 +132,10 @@
 	  out_fp.write('    </LabelStyle>\n')
 	  out_fp.write('  </Style>\n')
 
+    for photo in self.photo_list:
+      if (photo in self.thumbnail_names): # Only process if there's a thumbnail
+        location = photo.getLocation()
+
         out_fp.write('  <Placemark>\n')
         out_fp.write('    <name>%s</name>\n' % photo.getName())
         out_fp.write('    <description><![CDATA[')
@@ -157,9 +160,22 @@
           out_fp.write('    <Snippet>%s</Snippet>\n' % photo.getName())
 
 	if (self.use_icons):
-	  out_fp.write('      <styleUrl>#photo_%s</styleUrl>\n' % self.thumbnail_names[photo])
+	  if (for_google_maps):
+	    out_fp.write('  <StyleMap><Pair><Style>\n')
+	    out_fp.write('    <IconStyle>\n')
+	    out_fp.write('      <scale>1.5</scale>\n')
+	    out_fp.write('      <Icon>\n')
+	    out_fp.write('        <href>icons/%s</href>\n' % self.thumbnail_names[photo])
+	    out_fp.write('      </Icon>\n')
+	    out_fp.write('    </IconStyle>\n')
+	    out_fp.write('    <LabelStyle>\n')
+	    out_fp.write('      <scale>0.2</scale>\n')
+	    out_fp.write('    </LabelStyle>\n')
+	    out_fp.write('  </Style></Pair></StyleMap>\n')
+	  else:
+	    out_fp.write('  <styleUrl>#photo_%s</styleUrl>\n' % self.thumbnail_names[photo])
 	else:
-	  out_fp.write('    <styleUrl>#photo_mark</styleUrl>\n')
+	    out_fp.write('    <styleUrl>#photo_mark</styleUrl>\n')
         out_fp.write('    <Point>\n')
         if (location[2]):
           out_fp.write('      <altitudeMode>clampToGround</altitudeMode>\n')
@@ -202,7 +218,7 @@
       # Write the actual waypoints
       for waypoint in waypoints:
         out_fp.write('  <Placemark id="%s">\n' % waypoint[3])
-        out_fp.write('  <styleUrl>waypoint_style</styleUrl>\n')
+        out_fp.write('  <styleUrl>#waypoint_style</styleUrl>\n')
         out_fp.write('  <Point>\n')
         out_fp.write('    <coordinates>%.5f,%.5f,%.3f</coordinates>\n' % (waypoint[1], waypoint[0], (waypoint[2] or 0)))
         out_fp.write('  </Point>\n')
@@ -399,7 +415,7 @@
         self.logger.error("Couldn't make a thumbnail of image %s." % photo.getName())
         
   def writeFile(self, write_photos = False, write_waypoints = False,
-                write_track = False, write_between_tracks = False):
+                write_track = False, write_between_tracks = False, for_google_maps = True):
     """ Write the KMZ file. The arguments specify which parts of the file should
         be included. If write_photos is True, thumbnails should be included.
         If write_waypoints is True, waypoints should be included. If write_track
@@ -440,7 +456,7 @@
               self.between_tracks_color, self.between_tracks_width,
               self.photos_clickable, self.photos_url, bool(self.icon_size))
     kml_fp = StringIO.StringIO()
-    kml.writeKML(kml_fp, write_photos, write_waypoints, write_track, write_between_tracks)
+    kml.writeKML(kml_fp, write_photos, write_waypoints, write_track, write_between_tracks, for_google_maps)
 
     # Write the KML file to the ZIP archive
     out_file.writestr("base.kml", kml_fp.getvalue())
diff -dPNur HappyCamel.current/main.py HappyCamel/main.py
--- HappyCamel.current/main.py	2013-08-27 05:13:35.000000000 +0200
+++ HappyCamel/main.py	2013-09-24 19:50:50.000000000 +0200
@@ -264,7 +264,8 @@
 			  self.conf.get("url"),
                           self.conf.get("show_waypoints"),
                           self.conf.get("show_track"),
-                          self.conf.get("show_between_tracks"))
+                          self.conf.get("show_between_tracks"),
+                          self.conf.get("for_google_maps"))
 
   def getLocSources(self, input_list):
     """ Build and return a GeoSources instance with all possible sources of
@@ -533,7 +534,7 @@
   def writeKMZFile(self, gpx_files, photo_list, file_path, order, image_size, icon_size,
                    title, track_color, track_width, between_color,
                    between_width, clickable, photos_url, show_waypoints, show_track,
-                   show_between_tracks):
+                   show_between_tracks, for_google_maps):
 
     """ Write the KMZ file with the specified options. """
 
@@ -543,5 +544,5 @@
 
     kmz.writeFile(write_photos = True,
                   write_waypoints = show_waypoints, write_track = show_track,
-                  write_between_tracks = show_between_tracks)
+                  write_between_tracks = show_between_tracks, for_google_maps = for_google_maps)