如何从 Openlayer 请求优化 GeoWebcache 的响应速度或性能
how to Optimize response speed or performance of GeoWebcache from Openlayer Request
我有 TileLayer,其中包含 GeoServer2.13 上的大量数据,并使用 OpenLayers v4.1 API 从浏览器客户端发出请求。
所做的一切是:
1.Openlayer 带投影的地图:
var map: any = new ol.Map({
layers: [
new ol.layer.Tile({
source: new ol.source.OSM()
})
],
target: 'Map',
projection: 'EPSG:900913',
controls: ol.control.defaults({
attributionOptions: {
collapsible: false
}
}),
view: new ol.View({
center: [0, 0],
zoom: 2
})
});
2.WMS 请求为平铺 True:
layer: new ol.layer.Tile({
source: new ol.source.TileWMS({
url: _GESERVER_URL +'geo/wms',
params: {
'FORMAT': 'image/png',
'VERSION': '1.1.1',
'TILED': true,
'LAYERS': 'geo':myTileLayer'
},
projection: 'EPSG:4326'
})
})
3.On地理服务器:
-Layer Data tab SRS:4326
-Http Setting response header 3600
-Seeding Executing task 1
-ZoomLevel 15
-GridSet:EPSG:900913 and EPSG:4326
-Metatiling factors 4 by 4
-Image Format image/jpeg and image/png
-DiskQuata:3GB
-TileDimensions:256 x 256
我也尝试过 image/png8 但仍然无法加速。
是否需要任何其他配置来使 GeoWebcache 具有更高的性能?
您正在请求与您的地图显示不同投影的图块,这会强制 OpenLayers 重新投影图块。这需要时间并降低质量。
从您的 WMS 图层中删除行 projection: 'EPSG:4326'
。
另外,为了确保您正在访问您的切片缓存,请使用切片端点(例如 WMTS),而不是希望您的切片最终访问缓存(不太可能,因为您没有在 WMS 中指定 origin
).有关详细信息,请参阅 OpenLayers WMTS example。
var parser = new ol.format.WMTSCapabilities();
var map;
fetch('https://openlayers.org/en/v4.6.5/examples/data/WMTSCapabilities.xml').then(function(response) {
return response.text();
}).then(function(text) {
var result = parser.read(text);
var options = ol.source.WMTS.optionsFromCapabilities(result, {
layer: 'layer-7328',
matrixSet: 'EPSG:3857'
});
map = new ol.Map({
layers: [
new ol.layer.Tile({
source: new ol.source.OSM(),
opacity: 0.7
}),
new ol.layer.Tile({
opacity: 1,
source: new ol.source.WMTS(/** @type {!olx.source.WMTSOptions} */ (options))
})
],
target: 'map',
view: new ol.View({
center: [19412406.33, -5050500.21],
zoom: 5
})
});
});
我有 TileLayer,其中包含 GeoServer2.13 上的大量数据,并使用 OpenLayers v4.1 API 从浏览器客户端发出请求。 所做的一切是:
1.Openlayer 带投影的地图:
var map: any = new ol.Map({
layers: [
new ol.layer.Tile({
source: new ol.source.OSM()
})
],
target: 'Map',
projection: 'EPSG:900913',
controls: ol.control.defaults({
attributionOptions: {
collapsible: false
}
}),
view: new ol.View({
center: [0, 0],
zoom: 2
})
});
2.WMS 请求为平铺 True:
layer: new ol.layer.Tile({
source: new ol.source.TileWMS({
url: _GESERVER_URL +'geo/wms',
params: {
'FORMAT': 'image/png',
'VERSION': '1.1.1',
'TILED': true,
'LAYERS': 'geo':myTileLayer'
},
projection: 'EPSG:4326'
})
})
3.On地理服务器:
-Layer Data tab SRS:4326
-Http Setting response header 3600
-Seeding Executing task 1
-ZoomLevel 15
-GridSet:EPSG:900913 and EPSG:4326
-Metatiling factors 4 by 4
-Image Format image/jpeg and image/png
-DiskQuata:3GB
-TileDimensions:256 x 256
我也尝试过 image/png8 但仍然无法加速。 是否需要任何其他配置来使 GeoWebcache 具有更高的性能?
您正在请求与您的地图显示不同投影的图块,这会强制 OpenLayers 重新投影图块。这需要时间并降低质量。
从您的 WMS 图层中删除行 projection: 'EPSG:4326'
。
另外,为了确保您正在访问您的切片缓存,请使用切片端点(例如 WMTS),而不是希望您的切片最终访问缓存(不太可能,因为您没有在 WMS 中指定 origin
).有关详细信息,请参阅 OpenLayers WMTS example。
var parser = new ol.format.WMTSCapabilities();
var map;
fetch('https://openlayers.org/en/v4.6.5/examples/data/WMTSCapabilities.xml').then(function(response) {
return response.text();
}).then(function(text) {
var result = parser.read(text);
var options = ol.source.WMTS.optionsFromCapabilities(result, {
layer: 'layer-7328',
matrixSet: 'EPSG:3857'
});
map = new ol.Map({
layers: [
new ol.layer.Tile({
source: new ol.source.OSM(),
opacity: 0.7
}),
new ol.layer.Tile({
opacity: 1,
source: new ol.source.WMTS(/** @type {!olx.source.WMTSOptions} */ (options))
})
],
target: 'map',
view: new ol.View({
center: [19412406.33, -5050500.21],
zoom: 5
})
});
});