diff --git a/demo_googleDistMatrix/project.json b/demo_googleDistMatrix/project.json new file mode 100644 index 0000000000000000000000000000000000000000..24e554af07230c7828ef7dc7e7ab0616ca89dbb0 --- /dev/null +++ b/demo_googleDistMatrix/project.json @@ -0,0 +1,5 @@ +{ + "title": "Google Distance Matrix", + "index": 20160425, + "type": "Demo" +} diff --git a/demo_googleDistMatrix/py/.ipynb_checkpoints/Untitled-checkpoint.ipynb b/demo_googleDistMatrix/py/.ipynb_checkpoints/Untitled-checkpoint.ipynb new file mode 100644 index 0000000000000000000000000000000000000000..66f7099d88bf996182db36c814bd971039efb5f0 --- /dev/null +++ b/demo_googleDistMatrix/py/.ipynb_checkpoints/Untitled-checkpoint.ipynb @@ -0,0 +1,70 @@ +{ + "cells": [ + { + "cell_type": "code", + "execution_count": 1, + "metadata": { + "collapsed": true + }, + "outputs": [], + "source": [ + "import urllib.request\n", + "import urllib.parse\n", + "import json\n", + "import networkx as nx\n", + "from networkx.readwrite import json_graph" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], + "source": [] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "### Write Graph to JSON\n", + "Write our graph to JSON for use in JavaScript (d3.js)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], + "source": [ + "with open(\"../res/gmatrix.json\", \"w\") as f:\n", + " graphData = json_graph.node_link_data(G)\n", + " json.dump(graphData, f, indent=2)" + ] + } + ], + "metadata": { + "kernelspec": { + "display_name": "Python 3", + "language": "python", + "name": "python3" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 3 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython3", + "version": "3.5.2" + } + }, + "nbformat": 4, + "nbformat_minor": 0 +} diff --git a/demo_googleDistMatrix/py/compute.py b/demo_googleDistMatrix/py/compute.py new file mode 100644 index 0000000000000000000000000000000000000000..81c9349fa249d0cd2ab205034e7b297abac24caa --- /dev/null +++ b/demo_googleDistMatrix/py/compute.py @@ -0,0 +1,18 @@ +import urllib.request +import urllib.parse +import json +import networkx as nx +from networkx.readwrite import json_graph + + + + + + + + + + +with open("res/gmatrix.json", "w") as f: + graphData = json_graph.node_link_data(G) + json.dump(graphData, f, indent=2) diff --git a/demo_googleDistMatrix/py/gmatrix.ipynb b/demo_googleDistMatrix/py/gmatrix.ipynb new file mode 100644 index 0000000000000000000000000000000000000000..66f7099d88bf996182db36c814bd971039efb5f0 --- /dev/null +++ b/demo_googleDistMatrix/py/gmatrix.ipynb @@ -0,0 +1,70 @@ +{ + "cells": [ + { + "cell_type": "code", + "execution_count": 1, + "metadata": { + "collapsed": true + }, + "outputs": [], + "source": [ + "import urllib.request\n", + "import urllib.parse\n", + "import json\n", + "import networkx as nx\n", + "from networkx.readwrite import json_graph" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], + "source": [] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "### Write Graph to JSON\n", + "Write our graph to JSON for use in JavaScript (d3.js)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], + "source": [ + "with open(\"../res/gmatrix.json\", \"w\") as f:\n", + " graphData = json_graph.node_link_data(G)\n", + " json.dump(graphData, f, indent=2)" + ] + } + ], + "metadata": { + "kernelspec": { + "display_name": "Python 3", + "language": "python", + "name": "python3" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 3 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython3", + "version": "3.5.2" + } + }, + "nbformat": 4, + "nbformat_minor": 0 +} diff --git a/demo_googleDistMatrix/res/.keep b/demo_googleDistMatrix/res/.keep new file mode 100644 index 0000000000000000000000000000000000000000..8d1c8b69c3fce7bea45c73efd06983e3c419a92f --- /dev/null +++ b/demo_googleDistMatrix/res/.keep @@ -0,0 +1 @@ + diff --git a/demo_googleDistMatrix/web/index.html b/demo_googleDistMatrix/web/index.html new file mode 100644 index 0000000000000000000000000000000000000000..6261bc7e4449091579f9083e096f3f237a2a5428 --- /dev/null +++ b/demo_googleDistMatrix/web/index.html @@ -0,0 +1,10 @@ +{% extends "static/templates/projectBase.html" %} +{% block projectContent %} + +<script src="web/vis.js"></script> +<script src="https://maps.googleapis.com/maps/api/js?key=AIzaSyAIxgBuB4MT9drInjsHwjWgEkMuGSgp8r8&callback=gmap_api_loaded"></script> + +<h2>Google Distance Matrix – Best Path</h2> +<div id="gmaps" style="width: 100%; height: 500px; border-top: solid 1px black; border-bottom: solid 1px black;"></div> + +{% endblock %} diff --git a/demo_googleDistMatrix/web/vis.js b/demo_googleDistMatrix/web/vis.js new file mode 100644 index 0000000000000000000000000000000000000000..14efd5b93298c2553f50aed4d664d48abb557682 --- /dev/null +++ b/demo_googleDistMatrix/web/vis.js @@ -0,0 +1,17 @@ + +function gmap_api_loaded() { + $(function() { + var requests = [ + $.getJSON("res/gmatrix.json") + ]; + + $.when.apply($, requests).done(function(data) { + showGoogleMap(data); + }); + }); +}; + + +var showGoogleMap = function(data) { + +};