qgis / QGIS

QGIS is a free, open source, cross platform (lin/win/mac) geographical information system (GIS)
https://qgis.org
GNU General Public License v2.0
10.68k stars 3.02k forks source link

XYZ Tiles support full HTTP (specifically 302 redirects) #37956

Open four43 opened 4 years ago

four43 commented 4 years ago

Feature description. The XYZ Tile support in QGIS works fairly well but doesn't seem to fully support HTTP. Querying a tile that results in a 302 redirect isn't handled properly and silently fails. Logging around which tiles are being loaded and where would be useful as well.

rduivenvoorde commented 4 years ago

@four43 do you have an example of such an service? It's not easy for developers to setup such service.

Which QGIS are you using on which platform? About logging, try F12

Screenshot-20200804125544-1239x813 Recent versions have the NetworkLogger build in. (older versions can use the Network Logger Plugin)

four43 commented 4 years ago

@rduivenvoorde - Thanks for your response - I appreciate it.

Our service at AerisWeather, our weather mapping platform, allows users to pick arbitrary times, then forwards them to an actual time that we have data using 302 redirects. I can hack around on this a bit.

Edit: On second glance through - lots of cpp in here. This is a bit over my skiis!

rduivenvoorde commented 4 years ago

Ok, looked at one of your demo services:

https://www.aerisweather.com/support/docs/aeris-maps/examples/animations-with-mapbox-gl/

and found this (not) working xyz base uri (to be used in the xyz dialog to create one)

https://maps2.aerisapi.com/Dm03vP5oguuuoHKQi2tS1_LkghluSKwVkLLPg07tg4kXE02Kj2uA2amLZYP9dY/radar/{z}/{x}/{y}/-12min.png256

Zooming in to the USA in a OSM map, I see:

https://maps2.aerisapi.com/Dm03vP5oguuuoHKQi2tS1_LkghluSKwVkLLPg07tg4kXE02Kj2uA2amLZYP9dY/radar/6/18/24/-12min.png256

sending a HTTP 302 pointing to (maybe not exactly, but one of the missing images):

/Dm03vP5oguuuoHKQi2tS1_LkghluSKwVkLLPg07tg4kXE02Kj2uA2amLZYP9dY/radar/6/14/23/20200804135636_20200804135636.png256

Which combined with the base url creates this (working image/tile):

https://maps2.aerisapi.com//Dm03vP5oguuuoHKQi2tS1_LkghluSKwVkLLPg07tg4kXE02Kj2uA2amLZYP9dY/radar/6/14/23/20200804135636_20200804135636.png256

Screenshot-20200804161547-1388x998

Googling around QNetworkAccessManager (of which QgsNetworkAccessManager is parent) and (302) redirects, is that Qt chooses to NOT automagically follow redirects, but you have to code this yourself.

I know of a python implementations which does: https://github.com/planetfederal/lib-qgis-commons/blob/master/qgiscommons2/network/networkaccessmanager.py#L326

I'll ask on the dev list (https://lists.osgeo.org/pipermail/qgis-developer/2020-August/061960.html). (As I think I'm looking at a commercial service, maybe you could offer some funding if it is safe to implement, Note that I also lack the thorough cpp knowledge to implement this...)

four43 commented 4 years ago

Thanks for taking a look. I think even in curl you have to opt-in to follow 302s. I was hoping this would be a super quick "oh yeah we just need to pass this flag" and it would work.

github-actions[bot] commented 3 years ago

The QGIS project highly values your report and would love to see it addressed. However, this issue has been left in feedback mode for the last 14 days and is being automatically marked as "stale". If you would like to continue with this issue, please provide any missing information or answer any open questions. If you could resolve the issue yourself meanwhile, please leave a note for future readers with the same problem and close the issue. In case you should have any uncertainty, please leave a comment and we will be happy to help you proceed with this issue. If there is no further activity on this issue, it will be closed in a week.

robertwood62 commented 1 year ago

Any chance we could get 'follow redirects' enabled by default for Virtual Point Cloud files? It's hard to understand why support for following redirects would be disabled in the first place. It's a pretty common pattern to use.

In our case, we host all the data in Azure Blob Storage and generate a SAS token for access.

We provide users the following download URL (example below) https://dev-fri-downloads.azurewebsites.net/api/Download/laz/utm16/1kmZ163220535402021L.copc.laz

This URL checks various access conditions before redirecting to our Azure Storage with a SAS Token on the URL.

We are now stuck, as QGIS doesn't follow redirects.

image

nyalldawson commented 1 year ago

@robertwood62 has the redirect been removed from that site? I can't reproduce

robertwood62 commented 1 year ago

I ended up changing my API to proxy range queries to Azure Storage to support this feature and work around the issue. If you omit the range query in the header, it will redirect to storage. But with a range query is proxies the request.