[gnome-maps/wip/mlundblad/transit-plugin-gtfs-local: 13/13] WIP: Add transit plugin doing local routing on dowloaded GTFS
- From: Marcus Lundblad <mlundblad src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-maps/wip/mlundblad/transit-plugin-gtfs-local: 13/13] WIP: Add transit plugin doing local routing on dowloaded GTFS
- Date: Fri, 20 Mar 2020 23:41:09 +0000 (UTC)
commit 15092407a6fd61e5d6e32af3719c86bc64b87f03
Author: Marcus Lundblad <ml update uu se>
Date: Wed Feb 19 23:10:55 2020 +0100
WIP: Add transit plugin doing local routing on dowloaded GTFS
po/POTFILES.in | 1 +
src/org.gnome.Maps.src.gresource.xml | 1 +
src/transitplugins/gtfs.js | 63 ++++++++++++++++++++++++++++++++++++
3 files changed, 65 insertions(+)
---
diff --git a/po/POTFILES.in b/po/POTFILES.in
index 676a7a6f..6dfac517 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -62,4 +62,5 @@ src/translations.js
src/userLocationBubble.js
src/utils.js
src/transitplugins/goMetro.js
+src/transitplugins/gtfs.js
src/transitplugins/openTripPlanner.js
diff --git a/src/org.gnome.Maps.src.gresource.xml b/src/org.gnome.Maps.src.gresource.xml
index ab2e12f0..6c87c7d0 100644
--- a/src/org.gnome.Maps.src.gresource.xml
+++ b/src/org.gnome.Maps.src.gresource.xml
@@ -115,6 +115,7 @@
<file alias="geojsonvt/transform.js">transform.js</file>
<file alias="geojsonvt/wrap.js">wrap.js</file>
<file>transitplugins/goMetro.js</file>
+ <file>transitplugins/gtfs.js</file>
<file>transitplugins/opendataCH.js</file>
<file>transitplugins/openTripPlanner.js</file>
<file>transitplugins/resrobot.js</file>
diff --git a/src/transitplugins/gtfs.js b/src/transitplugins/gtfs.js
new file mode 100644
index 00000000..fd9d2f6c
--- /dev/null
+++ b/src/transitplugins/gtfs.js
@@ -0,0 +1,63 @@
+/* -*- Mode: JS2; indent-tabs-mode: nil; js2-basic-offset: 4 -*- */
+/* vim: set et ts=4 sw=4: */
+/*
+ * Copyright (c) 2020 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 _ = imports.gettext.gettext;
+
+const Maps = imports.gi.GnomeMaps;
+
+const Application = imports.application;
+const Utils = imports.utils;
+
+var GTFS = class GTFS {
+ constructor(params) {
+ // TODO: for now just read files from an unzipped GTFS file at path…
+ this._gtfs = Maps.GTFS.new(params.name);
+ this._query = Application.routeQuery;
+ this._plan = Application.routingDelegator.transitRouter.plan;
+ Utils.debug('end constructor');
+ }
+
+ fetchFirstResults() {
+ let filledPoints = this._query.filledPoints;
+ let startLat = filledPoints[0].place.location.latitude;
+ let startLon = filledPoints[0].place.location.longitude;
+ let endLat = filledPoints.last().place.location.latitude;
+ let endLon = filledPoints.last().place.location.longitude;
+
+ this._plan.progress(_("Creating database…"));
+ this._gtfs.parse((success, error) => {
+ this._plan.progress(null);
+ if (success) {
+ Utils.debug('stops near start');
+ let startStops = this._gtfs.get_nearby_stops(startLat, startLon, 2000);
+
+ Utils.debug('stops near end');
+ let endStops = this._gtfs.get_nearby_stops(endLat, endLon, 2000);
+ } else {
+ this._plan.requestFailed();
+ }
+ });
+ }
+
+ fetchMoreResults() {
+
+ }
+}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]