""" *************************************************************************** TestData.py --------------------- Date : March 2013 Copyright : (C) 2013 by Victor Olaya Email : volayaf at gmail dot com *************************************************************************** * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * *************************************************************************** """ __author__ = "Victor Olaya" __date__ = "March 2013" __copyright__ = "(C) 2013, Victor Olaya" import os.path import tempfile from qgis.core import QgsRasterLayer from qgis.testing import QgisTestCase testDataPath = os.path.join(os.path.dirname(__file__), "testdata") def table(): return os.path.join(testDataPath, "table.dbf") def points(): return os.path.join(testDataPath, "points.gml") def invalid_geometries(): return os.path.join(testDataPath, "invalidgeometries.gml") def wms_layer_1_1_1(test_id: str, crs: str) -> QgsRasterLayer: basetestpath = tempfile.mkdtemp().replace("\\", "/") endpoint = basetestpath + f"/{test_id}_fake_qgis_http_endpoint" with open( QgisTestCase.sanitize_local_url( endpoint, "?SERVICE=WMS&REQUEST=GetCapabilities" ), "wb", ) as f: f.write( b""" OGC:WMS OpenStreetMap WMS OpenStreetMap WMS, bereitgestellt durch terrestris GmbH und Co. KG. Beschleunigt mit MapProxy (http://mapproxy.org/) (c) OpenStreetMap contributors (http://www.openstreetmap.org/copyright) (c) OpenStreetMap Data (http://openstreetmapdata.com) (c) Natural Earth Data (http://www.naturalearthdata.com) (c) GEBCO Compilation Group (2021) GEBCO 2021 Grid (doi:10.5285/c6612cbe-50b3-0cff-e053-6c86abc09f8f) (c) SRTM 450m by ViewfinderPanoramas (http://viewfinderpanoramas.org/) (c) Great Lakes Bathymetry by NGDC (http://www.ngdc.noaa.gov/mgg/greatlakes/) (c) SRTM 30m by NASA EOSDIS Land Processes Distributed Active Archive Center (LP DAAC, https://lpdaac.usgs.gov/) by using this service you agree to the privacy policy mentioned at https://www.terrestris.de/en/datenschutzerklaerung/ application/vnd.ogc.wms_xml image/jpeg image/png text/plain text/html application/vnd.ogc.gml image/jpeg image/png application/vnd.ogc.se_xml application/vnd.ogc.se_inimage application/vnd.ogc.se_blank OpenStreetMap WMS EPSG:3857 EPSG:4326 EPSG:4686 OSM-WMS OpenStreetMap WMS - by terrestris """ ) return QgsRasterLayer( f"crs={crs}&layers=OSM-WMS&styles&url=file://" + QgisTestCase.sanitize_local_url( endpoint, "?SERVICE=WMS&REQUEST=GetCapabilities" ), "test", "wms", ) def wms_layer_1_3_0(test_id: str, crs: str) -> QgsRasterLayer: basetestpath = tempfile.mkdtemp().replace("\\", "/") endpoint = basetestpath + f"/{test_id}_fake_qgis_http_endpoint" with open( QgisTestCase.sanitize_local_url( endpoint, "?SERVICE=WMS&REQUEST=GetCapabilities" ), "wb", ) as f: f.write( b""" WMS GeoServer Web Map Service A compliant implementation of WMS plus most of the SLD extension (dynamic styling). Can also generate PDF, SVG, KML, GeoRSS text/xml image/png image/jpeg image/gif image/GeoTIFF image/tiff text/plain text/html text/xml XML INIMAGE BLANK de_basemapde_web_raster_farbe basemap.de Web Raster Farbe Der Layer enthaelt eine kombinierte Darstellung von ATKIS(c)- Landschaftsmodellen, der Hauskoordinaten und der Hausumringe, die nach basemap.de WebSK in der jeweils aktuellen Version eine Kartensignatur haben, inklusive ihrer Beschriftung. EPSG:3857 CRS:84 0.1059467424056892 20.448891294525627 45.2375427360256 56.84787345153812 """ ) return QgsRasterLayer( f"crs={crs}&layers=de_basemapde_web_raster_farbe&styles&url=file://" + QgisTestCase.sanitize_local_url( endpoint, "?SERVICE=WMS&REQUEST=GetCapabilities" ), "test", "wms", ) def wms_layer_1_3_0_frankfurt(test_id: str, crs: str) -> QgsRasterLayer: basetestpath = tempfile.mkdtemp().replace("\\", "/") endpoint = basetestpath + f"/{test_id}_fake_qgis_http_endpoint" with open( QgisTestCase.sanitize_local_url( endpoint, "?SERVICE=WMS&REQUEST=GetCapabilities" ), "wb", ) as f: f.write( b""" WMS MapProxy-WMS Rasterbilder Bebauungsplaene rv auf Basiskarte grau WMS mit Rasterbilder der rechtsverbindlichen Bebauungsplaene auf grauer Basiskarte ueber MapProxy 4000 4000 text/xml image/png image/jpeg image/gif image/GeoTIFF image/tiff text/plain text/html text/xml XML INIMAGE BLANK bplan_stadtkarte Bebauungsplaene Rasterbilder auf grauer Basiskarte EPSG:25832 EPSG:4326 8.471329688231897 8.801042621684477 50.01482739264088 50.22734893698391 """ ) return QgsRasterLayer( f"crs={crs}&layers=bplan_stadtkarte&styles&url=file://" + QgisTestCase.sanitize_local_url( endpoint, "?SERVICE=WMS&REQUEST=GetCapabilities" ), "test", "wms", )