[gnome-maps/wip/mlundblad/transit-routing: 11/32] 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: 11/32] Add module to delegate routing requests.
- Date: Tue, 14 Feb 2017 21:13:04 +0000 (UTC)
commit b2dd34346eb7519367ee635b69027b816489e4fa
Author: Marcus Lundblad <ml update uu se>
Date: Wed Feb 8 21:45:31 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.
Also change the name of the RouteService module
to GraphHopper to make it more clear that these
are different service interfaces.
https://bugzilla.gnome.org/show_bug.cgi?id=755808
po/POTFILES.in | 2 +-
src/application.js | 16 ++++----
src/{routeService.js => graphHopper.js} | 0
src/mapBubble.js | 2 +-
src/mapView.js | 6 +-
src/org.gnome.Maps.src.gresource.xml | 3 +-
src/placePopover.js | 2 +-
src/printOperation.js | 2 +-
src/routingDelegator.js | 66 +++++++++++++++++++++++++++++++
9 files changed, 83 insertions(+), 16 deletions(-)
---
diff --git a/po/POTFILES.in b/po/POTFILES.in
index 4da0060..83eef5f 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -35,6 +35,7 @@ src/contextMenu.js
src/exportViewDialog.js
src/geoclue.js
src/geoJSONSource.js
+src/graphHopper.js
src/layersPopover.js
src/mainWindow.js
src/mapView.js
@@ -46,7 +47,6 @@ src/placeEntry.js
src/place.js
src/printLayout.js
src/printOperation.js
-src/routeService.js
src/sendToDialog.js
src/shapeLayer.js
src/sidebar.js
diff --git a/src/application.js b/src/application.js
index 46c5f87..fe43c72 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,12 @@ 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/routeService.js b/src/graphHopper.js
similarity index 100%
rename from src/routeService.js
rename to src/graphHopper.js
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..30d078e 100644
--- a/src/mapView.js
+++ b/src/mapView.js
@@ -418,9 +418,9 @@ const MapView = new Lang.Class({
_showStoredRoute: function(stored) {
let query = Application.routeQuery;
- let route = Application.routeService.route;
+ let route = Application.routingDelegator.graphHopper.route;
- Application.routeService.storedRoute = stored.route;
+ Application.routingDelegator.graphHopper.storedRoute = stored.route;
let resetId = route.connect('reset', function() {
route.disconnect(resetId);
@@ -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 9353b7d..dbf82a5 100644
--- a/src/org.gnome.Maps.src.gresource.xml
+++ b/src/org.gnome.Maps.src.gresource.xml
@@ -20,6 +20,7 @@
<file>geoJSONSource.js</file>
<file>geoJSONStyle.js</file>
<file>gpxShapeLayer.js</file>
+ <file>graphHopper.js</file>
<file>hvt.js</file>
<file>http.js</file>
<file>instructionRow.js</file>
@@ -61,7 +62,7 @@
<file>route.js</file>
<file>routeEntry.js</file>
<file>routeQuery.js</file>
- <file>routeService.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/printOperation.js b/src/printOperation.js
index 74b38b8..e90c158 100644
--- a/src/printOperation.js
+++ b/src/printOperation.js
@@ -56,7 +56,7 @@ const PrintOperation = new Lang.Class({
},
_beginPrint: function(operation, context, data) {
- let route = Application.routeService.route;
+ let route = Application.routingDelegator.graphHopper.route;
let width = context.get_width();
let height = context.get_height();
diff --git a/src/routingDelegator.js b/src/routingDelegator.js
new file mode 100644
index 0000000..0032da7
--- /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]