【问题标题】:GetCapabilities Query for TileServer Returns Malformed JSONTileServer 的 GetCapabilities 查询返回格式错误的 JSON
【发布时间】:2021-06-16 20:43:07
【问题描述】:

我已经安装了 TileServer.php。当我导航到它时,我可以看到我的图块(所以它正在工作)。

我的问题是,当我查询 getCapabilities 文件时,生成的 json 文件格式不正确。

json 以 json 响应开头的部分查询字符串为前缀。

这是完整的查询字符串:

http:///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":"mer ":1,"tiles": ...

================================================ ===

我已经尝试删除部分查询字符串来测试结果,奇怪的是它再次抓取了查询字符串的一部分。

这是我测试过的完整查询字符串:

http:///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":"mer ":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:///tileserver/1.0.0/WMTSCapabilities.xml/wmts

【问题讨论】:

    标签: json asp.net-core geospatial tileserver-gl


    【解决方案1】:

    我找到了答案,我将把这篇文章留在这里,以便将来对某人有所帮助。

    在我的 URL 中,我使用 index.html 作为索引页面,但是我应该使用 index .json

    切换到 .json 后,我收到了预期的 JSON 响应。

    带有查询字符串的完整 URL:

    http:///tileserver/index.json?service=wmts&request=getcapabilities&version=1.0.0

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-02-19
      • 1970-01-01
      • 2018-02-08
      • 2020-06-12
      相关资源
      最近更新 更多