[gnome-maps/wip/mlundblad/additional-place-icons: 4/5] WIP: place: Return place icon based on osmType and osmValue
- From: Marcus Lundblad <mlundblad src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-maps/wip/mlundblad/additional-place-icons: 4/5] WIP: place: Return place icon based on osmType and osmValue
- Date: Sat, 10 Apr 2021 07:36:54 +0000 (UTC)
commit 4c813b94d204cabb55177c7d6c432834f1d23c3b
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 | 93 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 93 insertions(+)
---
diff --git a/src/place.js b/src/place.js
index 05f8dd09..799eabea 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,98 @@ 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 'cinema': return 'video-camera-symbolic';
+ case 'clinic':
+ case 'doctors':
+ return 'hospital-sign-symbolic';
+ case 'ferry_terminal': return 'route-transit-ferry-symbolic';
+ case 'fuel': return 'fuel-symbolic';
+ case 'hospital': return 'hospital-symbolic';
+ case 'parking': return 'parking-sign-symbolic';
+ case 'post_office': return 'post-box-symbolic';
+ case 'restaurant': return 'restaurant-symbolic';
+ case 'school':
+ case 'university':
+ return 'school-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 'leisure':
+ switch (this._osmValue) {
+ case 'nature_reserve':
+ case 'park':
+ return 'tree-symbolic';
+ }
+ break;
+ case 'natural':
+ switch (this._osmValue) {
+ case 'peak': return 'mountain-symbolic';
+ }
+ break;
+ case 'tourism':
+ switch (this._osmValue) {
+ case 'attraction':
+ case 'artwork':
+ return 'photo-camera-symbolic';
+ case 'alpine_hut':
+ 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]