Skip to content

Recording a rendering session and using it in mapbench

Andrea Aime edited this page Mar 1, 2014 · 1 revision

MapBench benchmarks work off a list of serialized map rendering command, that can be recorded from any application that uses a Java Graphics2D object, provided you can make a minor modification to its code.

In order to record the commands you'll have to catch the point in which the Graphics2D object is created, and wrap it within a ShapeDumpingGraphics2D object:

// Graphics2D gets created
Graphics2D graphics = ...; 
// Prepare an output file, including the date/time helps to avoid overwriting the same file over and over
File dumpFile = new File("/tmp/dc_" + request.getRawKvp().get("LAYERS") + "_" +  new SimpleDateFormat("yyyy-mm-dd-hh-mm-ss", Locale.ENGLISH).format(new Date()) + ".ser");
// wrap
graphic = new ShapeDumpingGraphics2D(graphic, mapContent.getMapWidth(), mapContent.getMapHeight(), dumpFile);

Every operation using the graphics will record commands, and the moment the graphics gets disposed the file will be finalized and closed. Just add the generated .ser file to the MapBench input directory and it will be included in your next benchmarking run.

Clone this wiki locally