jsonasp.net-coregeospatialtileserver-gl

GetCapabilities Query for TileServer Returns Malformed JSON


I have installed TileServer.php. When I navigate to it, I can see my tiles (so it's working).

My issue is when I query for the getCapabilities file the resulting json file is malformed.

The json is prefixed with part of the query string at the start of the json response.

Here is the full query string:

http://<=my ip=>/tileserver/index.html?service=wmts&request=getcapabilities&version=1.0.0

Actual Json Response I Receive

(Notice wmts&request is prefixed to the otherwise valid 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": ...

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

I have tried removing part of the query string to test for the results, oddly enough it grabs the part of the query string again.

Here is the full query string I tested with:

http://<=my ip=>/tileserver/index.html?request=getcapabilities&version=1.0.0

(Actual Json Response I Receive)

====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": ...

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

I could parse this out I suppose but I would like to find the cause for this issue.

I am using ASP.Net 5.0.

Here is roughly my code:

 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"

EDIT

Opps! Turns out I was requesting the getCapabilities file from the TileServer in the completely wrong way.

I will leave this here encase it helps someone in the future.

Here is the correct URL: http://<= my url =>/tileserver/1.0.0/WMTSCapabilities.xml/wmts


Solution

  • I found the answer and I will leave this post here encase it helps someone in the future.

    In my URL I was using index.html as the index page, however I should have been using index .json instead.

    As soon as I switched to .json I received the JSON response as I was expecting.

    Full URL with query string:

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