[gnome-maps/wip/mlundblad/additional-place-icons: 4/5] WIP: place: Return place icon based on osmType and osmValue




commit 70e4537686c549fedc35f15d2ca14056f4a28a46
Author: Marcus Lundblad <ml update uu se>
Date:   Tue Apr 6 22:02:03 2021 +0200

    WIP: place: Return place icon based on osmType and osmValue

 src/place.js | 68 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 68 insertions(+)
---
diff --git a/src/place.js b/src/place.js
index 05f8dd09..f49577d1 100644
--- a/src/place.js
+++ b/src/place.js
@@ -22,6 +22,7 @@
 const _ = imports.gettext.gettext;
 
 const Geocode = imports.gi.GeocodeGlib;
+const Gio = imports.gi.Gio;
 const GLib = imports.gi.GLib;
 const GObject = imports.gi.GObject;
 
@@ -249,6 +250,73 @@ class Place extends Geocode.Place {
         this._nativeName = nativeName;
     }
 
+    get icon() {
+        return Gio.Icon.new_for_string(this._getIconName());
+    }
+
+    _getIconName() {
+        // TODO: select icon name based on osmKey/osmValue
+        switch (this._osmKey) {
+            case 'amenity':
+                switch (this._osmValue) {
+                    case 'bus_station':    return 'route-transit-bus-symbolic';
+                    case 'charging_station': return 'electric-car-symbolic';
+                    case 'ferry_terminal': return 'route-transit-ferry-symbolic';
+                    case 'fuel':           return 'fuel-symbolic';
+                    case 'parking':        return 'parking-sign-symbolic';
+                    case 'restaurant':     return 'restaurant-symbolic';
+                }
+                break;
+            case 'highway':
+                switch (this._osmValue) {
+                    case 'bus_stop': return 'route-transit-bus-symbolic';
+                    case 'motorway':
+                    case 'motorway_link':
+                    case 'trunk':
+                    case 'trunk_link':
+                    case 'primary':
+                    case 'primary_link':
+                    case 'secondary':
+                    case 'secondary_link':
+                    case 'tertiary':
+                    case 'tertiary_link':
+                    case 'unclassified':
+                    case 'residential':
+                    case 'living_street':
+                    case 'service':
+                    case 'track':
+                        return 'route-car-symbolic';
+                    case 'cycleway':
+                        return 'route-bike-symbolic';
+                    case 'footway':
+                    case 'pedestrian':
+                    case 'steps':
+                    case 'path':
+                        return 'route-pedestrian-symbolic';
+                }
+                break;
+            case 'tourism':
+                switch (this._osmValue) {
+                    case 'hotel':
+                    case 'hostel':
+                        return 'bed-symbolic';
+                }
+                break;
+            case 'railway':
+                switch (this._osmValue) {
+                    case 'halt':
+                    case 'station':
+                        return 'route-transit-train-symbolic';
+                    case 'tram_stop':
+                        return 'route-transit-tram-symbolic';
+                }
+                break;
+            case 'shop':
+                return 'shopping-cart-symbolic';
+        }
+        return 'map-marker-symbolic';
+    }
+
     toJSON() {
         let bounding_box = null;
 


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