1

I use 9 base map layers from .SHP, .SLD, .DBF and etc. files. Their common HDD-size is 134 MB. And I faced with a perfomance issue on my PC. It takes aboout 20-25 seconds to zoom or to move the map, App holds for this period and it's not good at all. Also I want to note that the larger the scale, the more the App slows down. I think it's because it has to calculate more different elements and features and when we zoom their number reduces. At the city-building zoom level it works pretty fast.

So is there some tricks or approaches for performance improvments?

Now for temporal solution I hide\show 8 of 9 layers and it reacts quicker but all the same it takes the same time to redraw the map. Of course I use the parallel thread for my draw method to avoid the other App's GUI and scenes holds. For now I didn't try to use the tiles funcs yet.

  1. May be tiles will be some kind of solution or maybe there are other aprroaches?

  2. Can you suggest articles or code examples for this topic?

Except these ones: - doc1 - doc2

Here is my code

This method draws the map:

public void drawMap(GraphicsContext gc) {
    if (repaint) {
        repaint = false;
        StreamingRenderer draw = new StreamingRenderer();
        draw.setMapContent(map);
        FXGraphics2D graphics = new FXGraphics2D(gc);
        graphics.setBackground(colorBackground);
        graphics.clearRect(0, 0, (int) canvas.getWidth(), (int) canvas.getHeight());
        Rectangle rectangle = new Rectangle((int) canvas.getWidth(), (int) canvas.getHeight());

        draw.paint(graphics, rectangle, map.getViewport().getBounds());
    }
    else {return;}
}

This method sets new display area:

public void doSetDisplayArea(ReferencedEnvelope envelope) {
    map.getViewport().setBounds(envelope);
    repaint = true;
}

Here is my hide method's code:

public void hideLayers(int indexFrom) {
    //Hide layers for performance achievments
    java.util.List<Layer> layers;
    layers = map.layers();
    for (indexFrom = indexFrom; indexFrom < layers.size(); indexFrom++){
        layers.get(indexFrom).setVisible(false);
        Layer l = layers.get(indexFrom);
        System.out.println("SYSTEM: layer " + l.toString() + " was hidden. ");
    }
}

and here is the show method's code:

public void showLayers(int indexFrom, ReferencedEnvelope envelope) {
    //Show layers for performance achievments
    java.util.List<Layer> layers;
    layers = map.layers();
    for (indexFrom = indexFrom; indexFrom < layers.size(); indexFrom++){
        layers.get(indexFrom).setVisible(true);
        doSetDisplayArea(envelope);
        Layer l = layers.get(indexFrom);
        System.out.println("SYSTEM: layer " + l.toString() + " was shown. ");
    }
}
2

The main way to make your map draw faster is to draw fewer things, try adding scale dependencies to your SLD files.

Next, if you have complex SLD move to a PostGIS database and add indexes on the attributes that are used in the styles as well as a spatial index (of course).

Then, if you are trying to use parallelism to speed things up you probably need the Marlin renderer as the default JVM renderer has a syncronised block in it. You might also benefit from the JVM settings recommended for GeoServer.

If it still isn't fast enough you may well want to consider using a double buffer and cached tiles to help speed things up. That's going to take considerable work.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.