Repository navigation
Open
Labels
Description
This bites me very often and I create graphs on paper or via inkscape but viewing, creating or editing them is too costly. Therefor it would be nice to have a simple JavaScript map where I can create a sample graph and the app would export very simplified Java code. The trick is here to export into simple Java code, which is then readable from the JavaScript app back to display it too. Another option would be to export into some JSON which is then easily copy&pastable into a unit test (e.g. via Helper.createGraphFromJson("{some: json}")). But I prefer Java code if it is more compact.
Main purposes
- visualize graphs in unit tests
- visualize calculated routes
- create graphs for unit tests to avoid full or partial OSM import
Requirements
- lightweight JS client
- should run locally too, internet only required for fetching tiles. Or copy pasting to http://jsfiddle.net or http://jsbin.com?
- no DB or server necessary
- you can create polylines and connect them to graphs -> some leaflet plugins: http://makinacorpus.github.io/Leaflet.Snap/ and https://github.com/Leaflet/Leaflet.draw/ or https://www.mapbox.com/mapbox.js/example/v1.0.0/leaflet-draw/
- one can further edit the graph even after export etc
- export points as lat,lng list and Java code, Later: geoJson or gpx or to something like this
- print existing graph from unit test somehow
- import previously exported data or even 'Java' code
- embed this data directly in an URL to avoid copy or paste? or just use json and copy&paste or another good idea how to link from unit tests to this UI (could be hosted e.g. on graphhopper.com/maps/creator)
- Later: upload button for gpx file via leaflet plugin -> https://github.com/makinacorpus/Leaflet.FileLayer
Activity
easbar commentedon Nov 18, 2016
I made a little in-browser app to draw graphs and display very simple corresponding java code here:
https://github.com/ammagamma/graphhopper-creator .
It uses the d3 force simulation (not Leaflet). This makes it possible to draw the graph in a reasonable way even if only the edges (but not the actual node positions) are given. For example you can specify the edges of a graph on the right and quickly see how it looks on the left. It can also be used to create a graph visually and export "source code" that can be copy&pasted to a unit test. There are two buttons that can be used to sync between the graph visualization and the source representation (see the readme file and the instructions displayed inside the app). Because the app does not use Leaflet it does not support real node coordinates, but only shows the graph schematically (with the edge costs being displayed as numbers). There are a few features that would be helpful that I have not yet implemented but probably would make sense:
Not sure if this app is exactly what you were looking for, but it was a fun project that I would like to share ;)
devemux86 commentedon Nov 18, 2016
Are there any screenshots available to understand the concept?
karussell commentedon Nov 18, 2016
Nice & thanks - will have a look!
easbar commentedon Nov 19, 2016
Here is a screenshot:
I guess it is pretty self-explanatory, the arrow buttons at the bottom of the image can be used to synchronize the graph and source view. Right now only source code lines of the form
graph.edge(0, 3).setDistance(344);are supported.karussell commentedon Nov 19, 2016
Works really nice and the moving of the graph makes it a bit hard to 'catch' nodes but at the same time also a bit more fun :)
But due to the bidirectional update at least changing edge weights and removing edges&nodes is easy and simple :)
karussell commentedon Nov 19, 2016
Can we include it in GH? E.g. under core/src/test/javascript and add a bit documentation (prominently) for the developers?
easbar commentedon Nov 28, 2016
Of course you can include it in GH! If catching the nodes is too hard we could either require some key-press for dragging nodes (e.g. shift+drag) or reduce the velocity of the simulation a bit. I thought it is fun to move the nodes as well and it can be quite useful to disentangle the graph if there are many edges. Yes, the edge weights and node labels can be changed using the source view, it is just not supported by the graph view so far.
karussell commentedon Aug 29, 2017
Another idea would be to draw the graphs as ascii like OSRM does: https://github.com/Project-OSRM/osrm-backend/wiki/Cucumber-Test-Suite#node-maps
boldtrn commentedon Aug 31, 2017
This looks very interesting as well. I am not sure if we can also specify more complex situations, like roundabouts or something like this with the ASCII style, but this looks interesting.
karussell commentedon Sep 24, 2020
There is already something like we want ... just for the generic case:
https://marketplace.visualstudio.com/items?itemName=hediet.debug-visualizer
This Java example should work with it already.
easbar commentedon Sep 26, 2020
Valhalla took this a bit further and even creates some kind of end-to-end tests from ascii:
https://github.com/valhalla/valhalla/blob/master/test/gurka/README.md