AmonRaNet / QGeoView

QGeoView is a Qt / C ++ widget for visualizing geographic data.
GNU Lesser General Public License v3.0
155 stars 60 forks source link

Add WMS capabilities #32

Closed leonardooyama closed 1 year ago

leonardooyama commented 1 year ago

Some of the servers that I need to use, such as "https://bdgex.eb.mil.br/mapcache", provide the maps using the WMS protocol (https://en.wikipedia.org/wiki/Web_Map_Service). Is it possible to use (or adapt) your API to visualize data from these kind of servers?

AmonRaNet commented 1 year ago

QGV by default not provides any solutions to handle external data. Exceptions is only background maps as raster tiles like OSM. It mean is no support of WMS by default. There was small sub-projects to introduce some vector data support over GDAL, but till now nothing official.

What kind of data from WMS you plan to show? When it should be simple rendered as raster maybe you can use proxy layer, like with https://mapserver.org/introduction.html#mapserver-overview ?

leonardooyama commented 1 year ago

There is an YouTube video that teaches how to do such task in QGIS: https://www.youtube.com/watch?v=zgIs-8ZG4_c.

AmonRaNet commented 1 year ago

I know about QGIS :)

QGIS and QGeoView in different leagues, where QGIS is standalone solution to load/convert/render big set of cartographic data sources. QGeoView is light-weighted render library to create geo-view in Qt app. It mean theoretically you can render any kind of data, but only if you implement yourself converter of your data to QGeoView model.

As I said above: by default QGeoView can work with XYZ scheme. As long your data source is accessible over http/ftp/file in XYZ scheme - you can easy add this with few method calls (please check in demo: BackgroundDemo + CUSTOM_OSM).

Anything which is not TMS (XYZ model):

this is too large topic to answer here and probably not needed for you at all.

For example here you can find example how to convert XYZ request to bounding box, which can be later used to request more or less single tile from WMS. It mean you will need to implement custom QGVLayerTilesOnline with override for virtual QString tilePosToUrl(const QGV::GeoTilePos& tilePos) const = 0. Input is XYZ coordinates, return should be WMS URL (GetMap) to request single tile as image.

Very random pick-up for WMS request: https://wms.geo.admin.ch/?SERVICE=WMS&REQUEST=GetMap&VERSION=1.3.0&LAYERS=ch.bafu.bundesinventare-bln&STYLES=default&CRS=EPSG:2056&BBOX=2550000,1060000,2660000,1140000&WIDTH=800&HEIGHT=582&FORMAT=image/png

There is several solutions. One of them is MapServer

leonardooyama commented 1 year ago

Got it. I will try to implement this and make a pull request

leonardooyama commented 1 year ago

In order to avoid ssl verification, I added the following lines to the file QGVLayerTilesOnline.cpp, after line 43:

QSslConfiguration conf = request.sslConfiguration(); conf.setPeerVerifyMode(QSslSocket::VerifyNone); request.setSslConfiguration(conf);

AmonRaNet commented 1 year ago

PR merged