mapbox - 为什么 Geoserver 返回带有覆盖范围限制的 404 响应?
问题描述
我刚刚安装了 geoserver,但我在让它工作时遇到了一些麻烦。我正在使用安装时提供的示例进行一些测试,特别是tiger:tiger_roads
. 尽管我可以得到瓷砖,但当我在地图上移动时,它会404
在 chrome 控制台上抛出错误,并且下一个响应:
Coverage [minx,miny,maxx,maxy] is [2411, 5111, 2414, 5116, 13], index [x,y,z] is [2410, 5113, 13]
我希望 geoserver 返回 204(没有数据也可以),因为在该范围内没有任何内容可以显示。
这是正常的行为吗?如果没有,我要设置什么来防止该错误?
这是一个完整的index.html
,您可以在其中重现问题。只需打开它,然后沿着地图移动,或更改缩放。
<html>
<head>
<title>Vector tiles</title>
<script src="https://cdn.jsdelivr.net/gh/openlayers/openlayers.github.io@master/en/v6.1.1/build/ol.js"></script>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/gh/openlayers/openlayers.github.io@master/en/v6.1.1/css/ol.css" type="text/css">
<style>
html, body {
font-family: sans-serif;
width: 100%;
}
.map {
height: 500px;
width: 100%;
}
</style>
</head>
<body>
<h3>Mapbox Protobuf - vector tiles</h3>
<div id="map" class="map"></div>
<script>
var style_simple = new ol.style.Style({
fill: new ol.style.Fill({
color: '#ADD8E6'
}),
stroke: new ol.style.Stroke({
color: '#880000',
width: 1
})
});
function simpleStyle(feature) {
return style_simple;
}
var layer = 'tiger:tiger_roads';
var projection_epsg_no = '900913';
var map = new ol.Map({
target: 'map',
view: new ol.View({
center: ol.proj.fromLonLat([-73.985130, 40.758896]),
zoom: 13
}),
layers: [new ol.layer.VectorTile({
style:simpleStyle,
source: new ol.source.VectorTile({
tilePixelRatio: 1, // oversampling when > 1
tileGrid: ol.tilegrid.createXYZ({maxZoom: 19}),
format: new ol.format.MVT(),
url: 'http://ec2-34-242-255-134.eu-west-1.compute.amazonaws.com:8080/geoserver/gwc/service/tms/1.0.0/' + layer +
'@EPSG%3A'+projection_epsg_no+'@pbf/{z}/{x}/{-y}.pbf'
})
})]
});
</script>
</body>
</html>
解决方案
TMS 规范很清楚,当客户端请求不存在的图块时,将返回 404 响应。
错误处理 当服务器发生错误时,重要的是客户端能够容易地注意到发生了错误,并确定错误发生的原因,以便在必要时通知用户。
瓦片地图服务器使用 HTTP 错误代码来传递错误条件的一般原因,并使用 XML 有效负载以人类可读的语言传达失败的具体原因。
仅应使用本规范中给出的 HTTP 错误代码向客户端返回错误。
客户端请求一个不存在的资源 URL。返回 HTTP 错误代码 404(未找到)
服务器无法处理对有效资源 URL 的响应。返回 HTTP 错误代码 500(内部服务器错误)
推荐阅读
- javascript - 需要按多选值数组分组
- eclipse - 未能在项目 giraph-gora 上执行目标 org.apache.rat:apache-rat-plugin:0.8:check(默认):未批准的许可证太多:56
- c++ - opencv如何创建hsv格式垫
- html - 删除网格项目时关闭网格布局中的间隙
- reactive-programming - RxJava 主题与处理器
- cakephp - 找不到 Cakephp 类
- node.js - npm start 今天失败,出现以下错误
- api - Slate 无法显示来自 swagger 2.0 的示例值
- java - GSON 应为字符串,但在第 1 行第 14 列路径 $.dCharg 处为 BEGIN_OBJECT
- python - 如何从 github python 安装“sparse_dot_topn”