[gnome-maps/wip/mlundblad/negative-altitudes] placeView: Format 0 and negative altitudes nicer




commit 5f19942e6a6b10f2958347602c9dd6bc7f3e965e
Author: Marcus Lundblad <ml update uu se>
Date:   Mon May 10 22:16:16 2021 +0200

    placeView: Format 0 and negative altitudes nicer
    
    Instead of just showing 0 or a value with a - sign,
    show the altitudes as "At sea level" and
    "%s below sea level" which looks a bit less
    "techichal".

 src/placeView.js | 22 +++++++++++++++++++++-
 1 file changed, 21 insertions(+), 1 deletion(-)
---
diff --git a/src/placeView.js b/src/placeView.js
index e623388b..41db0119 100644
--- a/src/placeView.js
+++ b/src/placeView.js
@@ -455,9 +455,29 @@ var PlaceView = GObject.registerClass({
          * compare to an impossibly low altitude to see if one is set */
         if (place.location.altitude > -1000000000.0) {
             let alt  = place.location.altitude;
+            let info;
+
+            if (alt > 0) {
+                info = Utils.prettyDistance(alt, true);
+            } else if (alt < 0) {
+                /**
+                 * Translators: this is a label indicating an altitude below
+                 * sea level, where the %s placeholder is the altitude relative
+                 * to mean sea level in the "negative direction"
+                 */
+                info = _("%s below sea level").
+                            format(Utils.prettyDistance(-alt, true));
+            } else {
+                /**
+                 * Translators: this indicates a place is located at (or very
+                 * close to) mean sea level
+                 */
+                info = _("At sea level");
+            }
+
             content.push({ label: _("Altitude"),
                            icon: 'mountain-symbolic',
-                           info: Utils.prettyDistance(alt, true) });
+                           info: info });
         }
 
         if (place.religion) {


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]