Painting route following road between points

Hiya,

So far I’ve got a Java application to load in dependencies so that Graphhopper can route points using PBF file, calculate distance and time. This is built from GEOM points from national address databases.
I use JXMapviewer2 to paint the map background (offline and online) and currently it is drawing waypoints and lines between those points, but I’m really needing those lines to follow the road.

I’ve taken a look at https://gist.github.com/ibaaj/f44f2fdf90daf0b3d5fcb9fefdea894c#file-minigraphui_alt-java using minigraphui but have not able to implement it, there is a comment around how dependence’s references are outdated, which is probably why I’m having no luck.

Can someone please point me in the right direction to either have JXMapviewer2 to paint to the road between points or another method to get this to work?

Maybe this the most recent version is helpful: https://github.com/graphhopper/graphhopper/blob/master/tools/src/main/java/com/graphhopper/ui/MiniGraphUI.java

Other than this: we do not officially support this or Java UI stuff and I have no experience with JXMapviewer2

Thanks Karussell, I’ll take a look.
I tried to cast a broad net to see if someone else had success with doing it :slight_smile:

@karussell Hi Peter, hopefully a quick question.
I’ve added tools, ui, dependencies but get the following when running MiniGraphUI,java;

If no graph.location is provided you need to specify an OSM file.
at com.graphhopper.GraphHopper.init(GraphHopper.java:503)
at com.graphhopper.ui.MiniGraphUI.main(MiniGraphUI.java:383)

Where do I specify the pbf file to use and I’m presuming I declare from and to coords within

public MiniGraphUI(GraphHopper hopper, boolean debug) {

Things I’ve tried

  • I’ve looked within CHMeasurement.java and updated

String osmFile = cmdArgs.get(“map”, “C:/Program Files/ETL Data Load Processes/new-zealand-latest.osm.pbf”);

  • Within measurement.java

final String graphLocation = args.get(“graph.location”, “C:/Program Files/ETL Data Load Processes/new-zealand-latest.osm.pbf”);

If you start MiniGraphUI you can specify the arguments via command line option like:

java -cp path/to/tools/graphhopper-tools.jar graph.location=graph-location

Or use datareader.file to specify the pbf file.

Things I’ve tried

*Measurement has nothing to do with painting things in swing UI.

Why not use the new MVT debug via instead of the MiniGraphUI? It will directly visualize roads in the browser and MiniGraphUI might be removed in later versions.

Thanks for the tips Peter.
The initial issues I was facing was parsing the args from within the java project instead of the command prompt.

Although I got it all working I ended up implementing mapsforge to draw the tiles and route for the final solution.

Thanks for taking the time to respond.

1 Like
Powered by Discourse