Skip to content

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also compare across forks.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also compare across forks.
...
  • 3 commits
  • 2 files changed
  • 0 commit comments
  • 1 contributor
Commits on May 21, 2012
Alan Palazzolo Updating routino profile. 3824637
Alan Palazzolo Adding basic visualization for testing. d2d9f76
Alan Palazzolo Testing out animations. 3c54dff
Showing with 177 additions and 2 deletions.
  1. +2 −2 data-processing/routino-conf/profiles.xml
  2. +175 −0 visualizations/index.html
View
4 data-processing/routino-conf/profiles.xml
@@ -174,8 +174,8 @@
<speed highway="residential" kph="40" />
<speed highway="service" kph="20" />
<speed highway="track" kph="20" />
- <speed highway="cycleway" kph="80" />
- <speed highway="path" kph="40" />
+ <speed highway="cycleway" kph="40" />
+ <speed highway="path" kph="30" />
<speed highway="steps" kph="0" />
<speed highway="ferry" kph="10" />
</speeds>
View
175 visualizations/index.html
@@ -0,0 +1,175 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
+
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
+ <title>MinnPost</title>
+ <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
+ <link type="text/css" rel="stylesheet" media="all" href="http://www.minnpost.com/sites/default/files/css/css_bb801627df93671ec2cf2a1c9ecf4ad2.css" />
+ <link type="text/css" rel="stylesheet" media="screen" href="http://www.minnpost.com/sites/default/files/css/css_b833827e9fdb99e83e393d38c32a71fd.css" />
+ <link type="text/css" rel="stylesheet" media="print" href="http://www.minnpost.com/sites/default/files/css/css_dd48b5b093a35515052acfc42613d628.css" />
+ <!--[if IE]>
+ <link rel="stylesheet" href="http://www.minnpost.com/sites/default/themes/derma/inc/css/ie.css?j" type="text/css">
+ <![endif]-->
+ <meta name="viewport" content="width=device-width, initial-scale=1"></meta>
+</head>
+<body class="front logged-in page-home one-sidebar sidebar-right admin-nw admin-vertical admin-df one-sidebar sidebar-right">
+
+
+ <!-- Embed Start -->
+ <div class="node-body fieldlayout node-field-body">
+ <style type="text/css">
+ @import url('http://data.minnpost.s3.amazonaws.com/js/leaflet-0.3.1/leaflet.css');
+ </style>
+ <!--[if lte IE 8]>
+ <style type="text/css">
+ @import url('http://data.minnpost.s3.amazonaws.com/js/leaflet-0.3.1/leaflet.ie.css');
+ </style>
+ <![endif]-->
+ <style type="text/css">
+ .js-dependent,
+ .hide {
+ display: none;
+ }
+
+ .footnote {
+ font-size: .75em;
+ font-style: italic;
+ color: #414141;
+ margin-top: 1em;
+ }
+
+ #map {
+ width: 100%;
+ height: 400px;
+ }
+
+ /** Media queries **/
+ @media all and (max-width: 750px) {
+ }
+ </style>
+
+ <div id="map"></div>
+
+ <p class="footnote">.</p>
+
+ <script type="text/javascript">window.jQuery || document.write('<script type="text/javascript" src="https://s3.amazonaws.com/data.minnpost/js/jquery-1.7.2/jquery-1.7.2.min.js"><\/script>')</script>
+
+ <script type="text/javascript" src="https://s3.amazonaws.com/data.minnpost/js/leaflet-0.3.1/leaflet.js"></script>
+ <script type="text/javascript">
+ // Converts numeric degrees to radians
+ if (typeof(Number.prototype.toRad) === "undefined") {
+ Number.prototype.toRad = function() {
+ return this * Math.PI / 180;
+ }
+ }
+ // Converts radians to numeric (signed) degrees
+ if (typeof(Number.prototype.toDeg) === "undefined") {
+ Number.prototype.toDeg = function() {
+ return this * 180 / Math.PI;
+ }
+ }
+
+ // Object for dealing with map data
+ var mapExtender = {};
+ mapExtender.lineDistance = function(line) {
+ // Get distance of geojson object
+ var dist = 0;
+
+ if (typeof line.type != 'undefined' && line.type == 'LineString') {
+ for (var i = 1; i < line.coordinates.length; i++) {
+ dist += mapExtender.coordDistance(line.coordinates[i], line.coordinates[i - 1]);
+ }
+
+ return dist;
+ }
+ else {
+ return dist;
+ }
+ };
+ mapExtender.coordDistance = function(coord1, coord2) {
+ // Get Haversine distance between two Geojson coordinates
+ var dLat = (coord2[1] - coord1[1]).toRad();
+ var dLon = (coord2[0] - coord1[0]).toRad();
+ var lat1 = coord1[1].toRad();
+ var lat2 = coord2[1].toRad();
+
+ var a = Math.sin(dLat/2) * Math.sin(dLat/2) + Math.sin(dLon/2) * Math.sin(dLon/2) * Math.cos(lat1) * Math.cos(lat2);
+ var c = 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1-a));
+ return c;
+ };
+ mapExtender.coordAtDistance = function(line, dist) {
+ // Gets coordinate at specific place along path
+ var coord = [];
+ var distCurrent = 0;
+ var distOld = 0;
+
+ // If 0, then just give the first coordinate back.
+ if (dist == 0) {
+ return line.coordinates[0];
+ }
+
+ // Got to each coordinate and check if we need to go to next;
+ for (var i = 1; (i < line.coordinates.length && distCurrent < dist); i++) {
+ distOld = distCurrent;
+ distCurrent += mapExtender.coordDistance(line.coordinates[i], line.coordinates[i - 1]);
+ }
+
+ // Check if we did not make it
+ if (distCurrent < dist) {
+ return coord;
+ }
+ var p1 = line.coordinates[i - 2];
+ var p2 = line.coordinates[i - 1];
+ var part = (dist - distOld) / (distCurrent - distOld);
+
+ // Lon
+ coord[0] = p1[0] + (p2[0] - p1[0]) * part;
+ coord[1] = p1[1] + (p2[1] - p1[1]) * part;
+ return coord;
+ }
+ mapExtender.toKM = function(v) {
+ // Returns KM from a lat/lon distance;
+ return v * 6371;
+ };
+ mapExtender.toM = function(v) {
+ // Returns M from a lat/lon distance;
+ return v * 6371 * 1000;
+ };
+
+
+ // Namespace jQuery
+ (function($) {
+ $(document).ready(function() {
+ var example_path = {"type":"LineString","coordinates":[[-93.245688000000001,44.963118000000001],[-93.245683999999997,44.964027000000002],[-93.245097000000001,44.963470000000001],[-93.244298999999998,44.964398000000003],[-93.244095000000002,44.964900999999998],[-93.244084999999998,44.965291000000001],[-93.244084999999998,44.966616000000002],[-93.24409,44.967736000000002],[-93.244073999999998,44.968870000000003],[-93.244078999999999,44.969437999999997],[-93.244079999999997,44.969527999999997],[-93.244082000000006,44.969790000000003],[-93.244084000000001,44.969973000000003],[-93.245658000000006,44.969999999999999],[-93.245649,44.970933000000002],[-93.245665000000002,44.971127000000003],[-93.245711,44.971581999999998],[-93.245774999999995,44.972394000000001],[-93.245874999999998,44.973382999999998],[-93.245818999999997,44.973492999999998],[-93.245806000000002,44.974224999999997],[-93.245757999999995,44.975347999999997],[-93.245410000000007,44.976004000000003],[-93.244325000000003,44.977462000000003],[-93.243542000000005,44.979902000000003],[-93.242765000000006,44.980907000000002],[-93.242109999999997,44.981718999999998],[-93.241322999999994,44.982703999999998],[-93.240540999999993,44.983687000000003],[-93.239158000000003,44.983136000000002],[-93.237761000000006,44.982581000000003],[-93.236406000000002,44.982028],[-93.236795999999998,44.981535999999998],[-93.236977999999993,44.981307000000001],[-93.237182000000004,44.981050000000003],[-93.237373000000005,44.981124999999999]]};
+
+ // Start map
+ var map = new L.Map('map');
+
+ // Mapbox streets
+ mapboxStreets = new L.TileLayer('http://{s}.tiles.mapbox.com/v3/mapbox.mapbox-streets/{z}/{x}/{y}.png', {
+ attribution: 'Map imagery from <a href="http://mapbox.com">Mapbox</a>'
+ });
+ map.addLayer(mapboxStreets);
+
+ // Tilemill testing layer
+ var url ='http://localhost:20008/tile/minnpost-nice-ride-testing/{z}/{x}/{y}.png';
+ layer = new L.TileLayer(url, { maxZoom: 15, minZoom: 8, scheme: 'xyz' });
+ map.setView(new L.LatLng(44.9745, -93.2513), 13).addLayer(layer);
+
+ // Testing
+ var d = mapExtender.lineDistance(example_path);
+ console.log(mapExtender.toKM(d));
+
+ var way = mapExtender.coordAtDistance(example_path, 0.0001);
+ console.log(way);
+
+ });
+ })(jQuery);
+ </script>
+ </div>
+ <!-- Embed End -->
+
+
+</body>
+</html>

No commit comments for this range

Something went wrong with that request. Please try again.