[gnome-maps/wip/mlundblad/transit-routing: 2/21] Add module to delegate routing requests.
- From: Marcus Lundblad <mlundblad src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-maps/wip/mlundblad/transit-routing: 2/21] Add module to delegate routing requests.
- Date: Thu, 9 Feb 2017 20:47:18 +0000 (UTC)
commit f06d81000f41e893e0093b866f45d432a3841998
Author: Marcus Lundblad <ml update uu se>
Date: Wed Feb 8 22:26:20 2017 +0100
Add module to delegate routing requests.
Adds a new module implementing a delegator that
delegates routing requests to either GraphHopper
or OpenTripPlanner based on the selected mode.
https://bugzilla.gnome.org/show_bug.cgi?id=755808
src/application.js | 17 +++++----
src/mapBubble.js | 2 +-
src/mapView.js | 2 +-
src/org.gnome.Maps.src.gresource.xml | 1 +
src/placePopover.js | 2 +-
src/routingDelegator.js | 66 ++++++++++++++++++++++++++++++++++
6 files changed, 79 insertions(+), 11 deletions(-)
---
diff --git a/src/application.js b/src/application.js
index 46c5f87..ca9c559 100644
--- a/src/application.js
+++ b/src/application.js
@@ -39,7 +39,7 @@ const NotificationManager = imports.notificationManager;
const OSMEdit = imports.osmEdit;
const OSMTypeSearchEntry = imports.osmTypeSearchEntry;
const PlaceStore = imports.placeStore;
-const RouteService = imports.routeService;
+const RoutingDelegator = imports.routingDelegator;
const RouteQuery = imports.routeQuery;
const Settings = imports.settings;
const Utils = imports.utils;
@@ -49,7 +49,7 @@ let application = null;
let settings = null;
let placeStore = null;
let notificationManager = null;
-let routeService = null;
+let routingDelegator = null;
let geoclue = null;
let geocodeService = null;
let networkMonitor = null;
@@ -245,12 +245,13 @@ const Application = new Lang.Class({
},
_initServices: function() {
- settings = Settings.getSettings('org.gnome.Maps');
- routeQuery = new RouteQuery.RouteQuery();
- routeService = new RouteService.GraphHopper();
- geoclue = new Geoclue.Geoclue();
- geocodeService = new GeocodeService.GeocodeService();
- networkMonitor = Gio.NetworkMonitor.get_default();
+ settings = Settings.getSettings('org.gnome.Maps');
+ routeQuery = new RouteQuery.RouteQuery();
+ routingDelegator = new RoutingDelegator.RoutingDelegator(
+ { query: routeQuery });
+ geoclue = new Geoclue.Geoclue();
+ geocodeService = new GeocodeService.GeocodeService();
+ networkMonitor = Gio.NetworkMonitor.get_default();
networkMonitor.connect('network-changed',
this._checkNetwork.bind(this));
checkInManager = new CheckIn.CheckInManager();
diff --git a/src/mapBubble.js b/src/mapBubble.js
index 0851655..6aa587d 100644
--- a/src/mapBubble.js
+++ b/src/mapBubble.js
@@ -151,7 +151,7 @@ const MapBubble = new Lang.Class({
_initRouteButton: function(button, routeFrom) {
let query = Application.routeQuery;
- let route = Application.routeService.route;
+ let route = Application.routingDelegator.graphHopper.route;
let from = query.points[0];
let to = query.points[query.points.length - 1];
diff --git a/src/mapView.js b/src/mapView.js
index f38553b..23473b2 100644
--- a/src/mapView.js
+++ b/src/mapView.js
@@ -470,7 +470,7 @@ const MapView = new Lang.Class({
},
_showDestinationTurnpoints: function() {
- let route = Application.routeService.route;
+ let route = Application.routingDelegator.graphHopper.route;
let query = Application.routeQuery;
let pointIndex = 0;
diff --git a/src/org.gnome.Maps.src.gresource.xml b/src/org.gnome.Maps.src.gresource.xml
index d57e83c..dbf82a5 100644
--- a/src/org.gnome.Maps.src.gresource.xml
+++ b/src/org.gnome.Maps.src.gresource.xml
@@ -62,6 +62,7 @@
<file>route.js</file>
<file>routeEntry.js</file>
<file>routeQuery.js</file>
+ <file>routingDelegator.js</file>
<file>searchPopover.js</file>
<file>serviceBackend.js</file>
<file>settings.js</file>
diff --git a/src/placePopover.js b/src/placePopover.js
index fbe94fb..78923d3 100644
--- a/src/placePopover.js
+++ b/src/placePopover.js
@@ -63,7 +63,7 @@ const PlacePopover = new Lang.Class({
this._mode = Mode.ACTIVATED;
}).bind(this));
- Application.routeService.route.connect('updated', (function() {
+ Application.routingDelegator.graphHopper.route.connect('updated', (function() {
this._mode = Mode.ACTIVATED;
}).bind(this));
diff --git a/src/routingDelegator.js b/src/routingDelegator.js
new file mode 100644
index 0000000..0a546c6
--- /dev/null
+++ b/src/routingDelegator.js
@@ -0,0 +1,66 @@
+/* -*- Mode: JS2; indent-tabs-mode: nil; js2-basic-offset: 4 -*- */
+/* vim: set et ts=4 sw=4: */
+/*
+ * Copyright (c) 2017 Marcus Lundblad
+ *
+ * GNOME Maps is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by the
+ * Free Software Foundation; either version 2 of the License, or (at your
+ * option) any later version.
+ *
+ * GNOME Maps is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with GNOME Maps; if not, see <http://www.gnu.org/licenses/>.
+ *
+ * Author: Marcus Lundblad <ml update uu se>
+ */
+
+ const Lang = imports.lang;
+
+ const GraphHopper = imports.graphHopper;
+ const OpenTripPlanner = imports.openTripPlanner;
+
+ const RoutingDelegator = new Lang.Class({
+ Name: 'RoutingDelegator',
+
+ _init: function(params) {
+ this._query = params.query;
+ delete params.query;
+
+ this.parent(params);
+
+ this._transitRouting = false;
+ this._graphHopper = new GraphHopper.GraphHopper({ query: this._query });
+ this._openTripPlanner = new OpenTripPlanner.OpenTripPlanner(
+ { query: this._query,
+ graphHopper: this._graphHopper });
+ this._query.connect('notify::points', this._onQueryChanged.bind(this));
+ },
+
+ get graphHopper() {
+ return this._graphHopper;
+ },
+
+ get openTripPlanner() {
+ return this._openTripPlanner;
+ },
+
+ set useTransit(useTransit) {
+ this._transitRouting = useTransit;
+ },
+
+ _onQueryChanged: function() {
+ if (this._query.isValid()) {
+ if (this._transitRouting) {
+ this._openTripPlanner.fetchFirstResults();
+ } else {
+ this._graphHopper.fetchRoute(this._query.filledPoints,
+ this._query.transportation);
+ }
+ }
+ }
+ });
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]