Merge lp:~elementary-apps/pantheon-photos/sidebar-geo into lp:~pantheon-photos/pantheon-photos/trunk

Proposed by Danielle Foré
Status: Merged
Approved by: Felipe Escoto
Approved revision: 3053
Merged at revision: 3059
Proposed branch: lp:~elementary-apps/pantheon-photos/sidebar-geo
Merge into: lp:~pantheon-photos/pantheon-photos/trunk
Diff against target: 163 lines (+52/-16)
3 files modified
CMakeLists.txt (+2/-0)
src/sidebar/metadata/BasicProperties.vala (+50/-0)
src/sidebar/metadata/ExtendedProperties.vala (+0/-16)
To merge this branch: bzr merge lp:~elementary-apps/pantheon-photos/sidebar-geo
Reviewer Review Type Date Requested Status
Felipe Escoto (community) Approve
Review via email: mp+310153@code.launchpad.net

Commit message

Metadata Sidebar: Get a human-readable location from gps data

Description of the change

This needs to be tested for locations that might not have town or state fields and we need to figure out smart fallbacks

To post a comment you must log in.
3052. By Felipe Escoto

Add County layer between town and state

3053. By Felipe Escoto

Add testing location

Revision history for this message
Danielle Foré (danrabbit) wrote :

Felipe's change works for me :)

Revision history for this message
Felipe Escoto (philip.scott) wrote :

And i'm happy with the rest of it!

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'CMakeLists.txt'
2--- CMakeLists.txt 2016-08-28 20:08:59 +0000
3+++ CMakeLists.txt 2016-11-18 18:10:38 +0000
4@@ -21,6 +21,7 @@
5 set (DEPS_PKG
6 gee-0.8>=0.8.5
7 gexiv2>=0.4.90
8+ geocode-glib-1.0
9 gio-unix-2.0>=2.20
10 glib-2.0>=2.30.0
11 gmodule-2.0>=2.24.0
12@@ -46,6 +47,7 @@
13 atk
14 gdk-3.0
15 gee-0.8
16+ geocode-glib-1.0
17 gexiv2
18 gio-unix-2.0
19 glib-2.0
20
21=== modified file 'src/sidebar/metadata/BasicProperties.vala'
22--- src/sidebar/metadata/BasicProperties.vala 2016-11-11 22:18:54 +0000
23+++ src/sidebar/metadata/BasicProperties.vala 2016-11-18 18:10:38 +0000
24@@ -10,6 +10,7 @@
25 private Dimensions dimensions;
26 private EditableTitle title_entry;
27 private MediaSource? source;
28+ private Gtk.Label place_label;
29 private int photo_count;
30 private int event_count;
31 private int video_count;
32@@ -19,6 +20,11 @@
33 private string exposure_bias;
34 private string flash;
35 private string focal_length;
36+ private double gps_lat;
37+ private string gps_lat_ref;
38+ private double gps_long;
39+ private string gps_long_ref;
40+ private double gps_alt;
41 private string title;
42 private string aperture;
43 private string iso;
44@@ -45,6 +51,10 @@
45 flash = "";
46 filesize = 0;
47 focal_length = "";
48+ gps_lat = -1;
49+ gps_lat_ref = "";
50+ gps_long = -1;
51+ gps_long_ref = "";
52 photo_count = -1;
53 event_count = -1;
54 video_count = -1;
55@@ -98,6 +108,8 @@
56 Dimensions (0, 0);
57
58 focal_length = metadata.get_focal_length_string ();
59+
60+ metadata.get_gps (out gps_long, out gps_long_ref, out gps_lat, out gps_lat_ref, out gps_alt);
61 }
62
63 if (source is PhotoSource)
64@@ -280,6 +292,19 @@
65 }
66 }
67
68+ if (gps_lat != -1 && gps_long != -1) {
69+ place_label = new Gtk.Label ("");
70+ place_label.no_show_all = true;
71+ place_label.visible = false;
72+ place_label.xalign = 0;
73+
74+ create_place_label (gps_lat, gps_long);
75+
76+ attach (place_label, 0, (int) line_count, 2, 1);
77+
78+ line_count++;
79+ }
80+
81 if (dimensions.has_area ()) {
82 var size_label = new Gtk.Label ("%s — %d × %d".printf (format_size ((int64) filesize), dimensions.width, dimensions.height));
83 size_label.use_markup = true;
84@@ -367,6 +392,31 @@
85 }
86 }
87
88+ // Unit test: https://github.com/Philip-Scott/misc/blob/master/GeolocationTest.vala
89+ private async void create_place_label (double lat, double long) {
90+ var location = new Geocode.Location (lat, long);
91+ var reverse = new Geocode.Reverse.for_location (location);
92+
93+ try {
94+ Geocode.Place place = yield reverse.resolve_async ();
95+
96+ if (place.get_state () != null) {
97+ if (place.get_town () != null) {
98+ place_label.label = place.get_town () + ", " + place.get_state ();
99+ } else if (place.get_county () != null) {
100+ place_label.label = place.get_county () + ", " + place.get_state ();
101+ } else {
102+ place_label.label = place.get_state () + ", " + place.get_country ();
103+ }
104+
105+ place_label.no_show_all = false;
106+ place_label.visible = true;
107+ }
108+ } catch (Error e) {
109+ warning ("Failed to obtain place: %s", e.message);
110+ }
111+ }
112+
113 private void title_entry_changed () {
114 title = title_entry.text;
115 }
116
117=== modified file 'src/sidebar/metadata/ExtendedProperties.vala'
118--- src/sidebar/metadata/ExtendedProperties.vala 2016-11-06 18:37:03 +0000
119+++ src/sidebar/metadata/ExtendedProperties.vala 2016-11-18 18:10:38 +0000
120@@ -8,11 +8,6 @@
121 private const string NO_VALUE = "";
122 // Photo stuff
123 private string file_path;
124- private double gps_lat;
125- private string gps_lat_ref;
126- private double gps_long;
127- private string gps_long_ref;
128- private double gps_alt;
129 private string artist;
130 private string copyright;
131 private string exposure_date;
132@@ -37,10 +32,6 @@
133 file_path = "";
134 development_path = "";
135 is_raw = false;
136- gps_lat = -1;
137- gps_lat_ref = "";
138- gps_long = -1;
139- gps_long_ref = "";
140 artist = "";
141 copyright = "";
142 exposure_date = "";
143@@ -91,7 +82,6 @@
144 metadata.set_exposure_date_time (new MetadataDateTime (photo.get_timestamp ()));
145
146 is_raw = (photo.get_master_file_format () == PhotoFileFormat.RAW);
147- metadata.get_gps (out gps_long, out gps_long_ref, out gps_lat, out gps_lat_ref, out gps_alt);
148 artist = metadata.get_artist ();
149 copyright = metadata.get_copyright ();
150 time_t exposure_time_obj = metadata.get_exposure_date_time ().get_timestamp ();
151@@ -121,12 +111,6 @@
152 add_line (_ ("Exposure time:"), (exposure_time != "" && exposure_time != null) ?
153 exposure_time : NO_VALUE);
154
155- add_line (_ ("GPS latitude:"), (gps_lat != -1 && gps_lat_ref != "" &&
156- gps_lat_ref != null) ? "%f °%s".printf (gps_lat, gps_lat_ref) : NO_VALUE);
157-
158- add_line (_ ("GPS longitude:"), (gps_long != -1 && gps_long_ref != "" &&
159- gps_long_ref != null) ? "%f °%s".printf (gps_long, gps_long_ref) : NO_VALUE);
160-
161 add_line (_ ("Artist:"), (artist != "" && artist != null) ? artist : NO_VALUE);
162
163 add_line (_ ("Copyright:"), (copyright != "" && copyright != null) ? copyright : NO_VALUE);

Subscribers

People subscribed via source and target branches