我已经安装了 TileServer.php。当我导航到它时,我可以看到我的图块(所以它正在工作)。
我的问题是当我查询 getCapabilities 文件时,生成的 json 文件格式错误。
json 在 json 响应的开头以部分查询字符串为前缀。
这是完整的查询字符串:
http://<=my ip=>/tileserver/index.html?service= wmts&request =getcapabilities&version=1.0.0
我收到的实际 Json 响应
(注意wmts&request以其他有效的 json 为前缀)
====JSON================================
wmts&request ([{"name":"190322","type":"overlay","description":"190322","version":"1.1","format":"png","bounds":[174.92249449474565 ,-36.991878207885335,174.93635413927785,-36.98244705946717],"maxzoom":22,"minzoom":14,"basename":"1313_190322","profile":"mercator","scale":1,"tiles": .. .
====================================================
我已经尝试删除部分查询字符串来测试结果,奇怪的是它再次抓住了查询字符串的一部分。
这是我测试的完整查询字符串:
http://<=my ip=>/tileserver/index.html?request= getcapabilities&version =1.0.0
(我收到的实际 Json 响应)
====JSON================================
getcapabilities&version ([{"name":"190322","type":"overlay","description":"190322","version":"1.1","format":"png","bounds":[174.92249449474565 ,-36.991878207885335,174.93635413927785,-36.98244705946717],"maxzoom":22,"minzoom":14,"basename":"1313_190322","profile":"mercator","scale":1,"tiles": .. .
==================================================== =====
我想我可以解析出来,但我想找到这个问题的原因。
我正在使用 ASP.Net 5.0。
这里大致是我的代码:
private static readonly string _tileserver_ip = "http://<my ip>/tileserver/";
HttpClient client = new HttpClient();
client.DefaultRequestHeaders.Accept.Clear();
client.DefaultRequestHeaders.Accept.Add(
new MediaTypeWithQualityHeaderValue("application/json"));
var query = new Dictionary<string, string>
{
["service"] = "wmts",
["request"] = "getcapabilities",
["version"] = "1.0.0"
};
var response = await client.GetAsync(QueryHelpers.AddQueryString(_tileserver_ip, query));
var capabilitiesString = await response.Content.ReadAsStringAsync();
// the result of the query string => "http://<my ip>/tileserver/?service=wmts&request=getcapabilities&version=1.0.0"
编辑
哎呀!原来我以完全错误的方式从 TileServer 请求 getCapabilities 文件。
我将把它留在这里,以防将来对某人有所帮助。
这是正确的 URL:http://<= my url =>/tileserver/1.0.0/WMTSCapabilities.xml/wmts