Reputation: 109
I'm facing a performance issue to load a layer fastly. I'm working with OpenLayers 5.3, GeoServer 2.10 and an Oracle 12 database. I have some (3-4) WMS layers for information and background, and a WFS layer that can be edited. This last one has more than 30000 polylines and is slow to load.
So I was looking for some solutions, and I wanted some advices :
Finally, I think that the better way is to work with a simple WMS layer, and switch only needed polylines in features in a WFS layer when I have to edit them. But, I have to filter the data of the WMS layer. I found that it is possible with the CQL filter in the parameters. It works, but the filter is limited in size because of the GET request. So I found sample to change the request in a POST on. It works again, but this time I noticed that the layer generation becomes very slow according of the number of items in my WHERE clause "ID in (1,2,3,4...999,1000,1001...)".
Here is where I am right now, and I was expecting : what is the best approach for my "issue" ?
Right now, I figure out to simplify the CQL filter by adding more columns in the layer to build filters better than a simple "ID in (...)" and continue in this way : replacing my WFS layer with a WMS one and adding some custom code to manage it in the way I want.
If someone has a better proposal for my situation, I'm all ears :-)
Best regards.
Upvotes: 1
Views: 2489
Reputation: 1235
I think it can be usefull to see how do you instantiate the map. I had a similar problem with a layer with 1000 markers, and the loading problem was due of the istantiation.
Let's assume i have my array of features markers
var markers = [];
If i create the marker's layer passing the features, it's really slow to load the map.
var vectorSource = new ol.source.Vector({
features: markers
});
var vectorLayer = new ol.layer.Vector({
source: vectorSource
});
Otherwise, if i create the layer and then dinamically add every feature to the layer, the loading time it's good.
var vectorSource = new ol.source.Vector();
var vectorLayer = new ol.layer.Vector({
source: vectorSource
});
// Add each marker individually
markers.forEach(function (feature) {
vectorSource.addFeature(feature);
});
Maybe you can apply a similiar solution, but with polylines instead of points.
Upvotes: 1
Reputation: 24096
What I used to do is show WMS tiles, and when the user clicked on a "line", retrieve the relevant information to the browser, paint the retrieved geometry as an overlay, and edit whatever is needed.
The only disadvantage is that you then cannot have things like changing the color of -all- lines when you hover the mouse, but from the user's point of view it can be quite smooth and fast.
Besides that, the Geoserver's rendering options for WMS are much more powerful than what's built into OpenLayers.
There is of course a delay between updating the underlaying WMS because you'll send an update to the server, and only after you get a confirmation, you can start a refresh of the WMS layer (else your change might not have been processed yet, and refreshing will just give you the old state). So you might have to think of something to indicate to the user that a visual update is pending after you send an update.
Upvotes: 0