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.
May be tiles will be some kind of solution or maybe there are other aprroaches?
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. ");
}
}