[gnome-maps/wip/routing] WIP: Add route classes



commit 0272194fe4b62a0291e621d246ba1df5a1d14646
Author: Mattias Bengtsson <mattias jc bengtsson gmail com>
Date:   Thu Aug 22 08:25:04 2013 +0200

    WIP: Add route classes

 src/route.js |   81 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 81 insertions(+), 0 deletions(-)
---
diff --git a/src/route.js b/src/route.js
new file mode 100644
index 0000000..59a4b67
--- /dev/null
+++ b/src/route.js
@@ -0,0 +1,81 @@
+/* -*- Mode: JS2; indent-tabs-mode: nil; js2-basic-offset: 4 -*- */
+/* vim: set et ts=4 sw=4: */
+/*
+ * Copyright (c) 2013 Mattias Bengtsson.
+ *
+ * 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, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+ *
+ * Author: Mattias Bengtsson <mattias jc bengtsson gmail com>
+ */
+
+const Lang = imports.lang;
+const Champlain = imports.gi.Champlain;
+
+const PointType = {
+    START:  0,
+    END:    1,
+    NORMAL: 2,
+    VIA:    3
+};
+
+const Direction = {
+    LEFT:         0,
+    SHARP_LEFT:   1,
+    SLIGHT_LEFT:  2,
+    RIGHT:        3,
+    SHARP_RIGHT:  4,
+    SLIGHT_RIGHT: 5,
+    FORWARD:      6,
+    U_TURN:       7,
+    ROUNDABOUT:   8
+};
+
+const Route = new Lang.Class({
+    Name: 'Route',
+
+    _init: function({ points, polyLine, distance, time, bbox }) {
+        this.points = points;
+        this.polyLine = polyLine;
+        this.distance = distance;
+        this.time = time;
+        this.bbox = bbox || this._calculateBbox(polyLine);
+    },
+
+    _calculateBbox: function(polyLine) {
+        let bbox = new Champlain.BoundingBox();
+        polyLine.forEach(function(coordinate) {
+            bbox.extend(coordinate.latitude, coordinate.longitude);
+        });
+        return bbox;
+    }
+});
+
+// TODO:
+//  - inherit from a new class Location that has abstract getMarker()-method
+//  - port *Location to this
+//  - make mapView.showLocation take a Location and show the marker at the
+//    position the Location has
+// OR: come up with something better
+const Point = new Lang.Class({
+    Name: 'Point',
+
+    _init: function(coordinate, { type, direction, distance, description }) {
+        this.coordinate = coordinate;
+        this.type = type;
+        this.direction = direction;
+        this.distance = distance;
+        this.description = description;
+    }
+});


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