From f785a1071fe8fbad57b725cbde640a80d1826fbd Mon Sep 17 00:00:00 2001 From: Christian Heider Nielsen Date: Fri, 22 Mar 2024 10:54:34 +0100 Subject: [PATCH] loosen numpy dep --- jord/__init__.py | 2 +- jord/gdal_utilities/context.py | 3 +- jord/geometric_analysis/degrees_of_freedom.py | 9 +- jord/qgis_utilities/categorisation.py | 6 +- jord/qgis_utilities/conversion/parsing.py | 9 +- jord/qgis_utilities/data_provider.py | 918 +++++++++--------- jord/qgis_utilities/enums.py | 4 +- .../geo_interface_serialisation.py | 2 + jord/qgis_utilities/geometry_types.py | 3 +- jord/qgis_utilities/helpers/actions.py | 4 +- jord/qgis_utilities/helpers/groups.py | 1 + jord/qgis_utilities/helpers/models.py | 1 + jord/qgis_utilities/helpers/progress_bar.py | 7 +- jord/qgis_utilities/helpers/sessions.py | 1 + jord/qgis_utilities/helpers/signals.py | 28 +- jord/qgis_utilities/styles.py | 1 + jord/qlive_utilities/clients/interfaced.py | 6 +- jord/qt_utilities/enums.py | 183 ++-- jord/shapely_utilities/mirroring.py | 3 +- jord/shapely_utilities/projection.py | 1 + requirements.txt | 2 +- samples/settings/qgis_settings.py | 7 +- tests/gdal/conversion.py | 6 +- tests/pip_parsing/piper.py | 3 +- tests/shapely/clamp.py | 3 +- tests/shapely/lines.py | 3 +- 26 files changed, 642 insertions(+), 574 deletions(-) diff --git a/jord/__init__.py b/jord/__init__.py index 2d4ceea..8ad6ab8 100755 --- a/jord/__init__.py +++ b/jord/__init__.py @@ -16,7 +16,7 @@ __project__ = "Jord" __author__ = "Christian Heider Lindbjerg" -__version__ = "0.4.8" +__version__ = "0.5.0" __doc__ = r""" .. module:: jord :platform: Unix, Windows diff --git a/jord/gdal_utilities/context.py b/jord/gdal_utilities/context.py index e604919..c36ab24 100755 --- a/jord/gdal_utilities/context.py +++ b/jord/gdal_utilities/context.py @@ -19,8 +19,7 @@ class SilenceGDALSession(AlsoDecorator): TODO: add support for having a lasting side effect or leaving last set state of error/exception handling """ - def __init__(self): - ... + def __init__(self): ... def __enter__(self) -> bool: GDAL.PushErrorHandler( diff --git a/jord/geometric_analysis/degrees_of_freedom.py b/jord/geometric_analysis/degrees_of_freedom.py index 3a04c86..a220c36 100755 --- a/jord/geometric_analysis/degrees_of_freedom.py +++ b/jord/geometric_analysis/degrees_of_freedom.py @@ -5,8 +5,7 @@ from shapely.geometry import Polygon, LineString -def is_2d_translatable(): - ... +def is_2d_translatable(): ... def has_touches_across_centroid_buffer( @@ -19,9 +18,7 @@ def has_touches_across_centroid_buffer( ... -def is_simple_shape(): - ... +def is_simple_shape(): ... -def has_3_sides_touching(): - ... +def has_3_sides_touching(): ... diff --git a/jord/qgis_utilities/categorisation.py b/jord/qgis_utilities/categorisation.py index 2d10f32..5ba3ac8 100755 --- a/jord/qgis_utilities/categorisation.py +++ b/jord/qgis_utilities/categorisation.py @@ -4,7 +4,6 @@ from itertools import cycle from typing import Callable, Generator, Iterable, Sized -import qgis from PyQt5.Qt import QColor # noinspection PyUnresolvedReferences @@ -14,6 +13,9 @@ QgsSymbol, QgsVectorLayer, ) + +# noinspection PyUnresolvedReferences +from qgis.utils import iface from warg import QuadNumber, TripleNumber, n_uint_mix_generator_builder __all__ = ["categorise_layer"] @@ -114,4 +116,4 @@ def categorise_layer( layer.setRenderer(QgsCategorizedSymbolRenderer(field_name, render_categories)) layer.triggerRepaint() - qgis.utils.iface.layerTreeView().refreshLayerSymbology(layer.id()) + iface.layerTreeView().refreshLayerSymbology(layer.id()) diff --git a/jord/qgis_utilities/conversion/parsing.py b/jord/qgis_utilities/conversion/parsing.py index 1e0820b..0a686ac 100755 --- a/jord/qgis_utilities/conversion/parsing.py +++ b/jord/qgis_utilities/conversion/parsing.py @@ -1,11 +1,8 @@ #!/usr/bin/env python3 -def sanitise_wkb() -> str: - ... +def sanitise_wkb() -> str: ... -def sanitise_wkt() -> str: - ... +def sanitise_wkt() -> str: ... -def explode_geometry_collection(): - ... +def explode_geometry_collection(): ... diff --git a/jord/qgis_utilities/data_provider.py b/jord/qgis_utilities/data_provider.py index 969edad..1d731c8 100755 --- a/jord/qgis_utilities/data_provider.py +++ b/jord/qgis_utilities/data_provider.py @@ -10,15 +10,17 @@ class CommonVectorDataProviderLibEnum(Enum): postgres = "postgres" -def auishd(iface) -> None: - """ - Some services require you to supply your own API key for the services to work. +if __name__ == "__main__": - For Esri basemaps you will need a valid ArcGIS online subscription to use the maps. - """ - from PyQt5.QtCore import QSettings + def auishd(iface) -> None: + """ + Some services require you to supply your own API key for the services to work. - """ + For Esri basemaps you will need a valid ArcGIS online subscription to use the maps. + """ + from PyQt5.QtCore import QSettings + + """ connection_type connection_name authcfg @@ -30,460 +32,462 @@ def auishd(iface) -> None: zmin """ - # Sources - sources = [] - sources.append( - [ - "connections-xyz", - "Google Maps", - "", - "", - "", - "https://mt1.google.com/vt/lyrs=m&x=%7Bx%7D&y=%7By%7D&z=%7Bz%7D", - "", - "19", - "0", - ] - ) - sources.append( - [ - "connections-xyz", - "Google Satellite", - "", - "", - "", - "https://mt1.google.com/vt/lyrs=s&x=%7Bx%7D&y=%7By%7D&z=%7Bz%7D", - "", - "19", - "0", - ] - ) - sources.append( - [ - "connections-xyz", - "Google Terrain", - "", - "", - "", - "https://mt1.google.com/vt/lyrs=t&x=%7Bx%7D&y=%7By%7D&z=%7Bz%7D", - "", - "19", - "0", - ] - ) - sources.append( - [ - "connections-xyz", - "Google Terrain Hybrid", - "", - "", - "", - "https://mt1.google.com/vt/lyrs=p&x=%7Bx%7D&y=%7By%7D&z=%7Bz%7D", - "", - "19", - "0", - ] - ) - sources.append( - [ - "connections-xyz", - "Google Satellite Hybrid", - "", - "", - "", - "https://mt1.google.com/vt/lyrs=y&x=%7Bx%7D&y=%7By%7D&z=%7Bz%7D", - "", - "19", - "0", - ] - ) - sources.append( - [ - "connections-xyz", - "Stamen Terrain", - "", - "", - "Map tiles by Stamen Design, under CC BY 3.0. Data by OpenStreetMap, under ODbL", - "http://tile.stamen.com/terrain/%7Bz%7D/%7Bx%7D/%7By%7D.png", - "", - "20", - "0", - ] - ) - sources.append( - [ - "connections-xyz", - "Stamen Toner", - "", - "", - "Map tiles by Stamen Design, under CC BY 3.0. Data by OpenStreetMap, under ODbL", - "http://tile.stamen.com/toner/%7Bz%7D/%7Bx%7D/%7By%7D.png", - "", - "20", - "0", - ] - ) - sources.append( - [ - "connections-xyz", - "Stamen Toner Light", - "", - "", - "Map tiles by Stamen Design, under CC BY 3.0. Data by OpenStreetMap, under ODbL", - "http://tile.stamen.com/toner-lite/%7Bz%7D/%7Bx%7D/%7By%7D.png", - "", - "20", - "0", - ] - ) - sources.append( - [ - "connections-xyz", - "Stamen Watercolor", - "", - "", - "Map tiles by Stamen Design, under CC BY 3.0. Data by OpenStreetMap, under ODbL", - "http://tile.stamen.com/watercolor/%7Bz%7D/%7Bx%7D/%7By%7D.jpg", - "", - "18", - "0", - ] - ) - sources.append( - [ - "connections-xyz", - "Wikimedia Map", - "", - "", - "OpenStreetMap contributors, under ODbL", - "https://maps.wikimedia.org/osm-intl/%7Bz%7D/%7Bx%7D/%7By%7D.png", - "", - "20", - "1", - ] - ) - sources.append( - [ - "connections-xyz", - "Wikimedia Hike Bike Map", - "", - "", - "OpenStreetMap contributors, under ODbL", - "http://tiles.wmflabs.org/hikebike/%7Bz%7D/%7Bx%7D/%7By%7D.png", - "", - "17", - "1", - ] - ) - sources.append( - [ - "connections-xyz", - "Esri Boundaries Places", - "", - "", - "Requires ArcGIS Onlinesubscription", - "https://server.arcgisonline.com/ArcGIS/rest/services/Reference/World_Boundaries_and_Places/MapServer/tile/%7Bz%7D/%7By%7D/%7Bx%7D", - "", - "20", - "0", - ] - ) - sources.append( - [ - "connections-xyz", - "Esri Gray (dark)", - "", - "", - "Requires ArcGIS Onlinesubscription", - "http://services.arcgisonline.com/ArcGIS/rest/services/Canvas/World_Dark_Gray_Base/MapServer/tile/%7Bz%7D/%7By%7D/%7Bx%7D", - "", - "16", - "0", - ] - ) - sources.append( - [ - "connections-xyz", - "Esri Gray (light)", - "", - "", - "Requires ArcGIS Onlinesubscription", - "http://services.arcgisonline.com/ArcGIS/rest/services/Canvas/World_Light_Gray_Base/MapServer/tile/%7Bz%7D/%7By%7D/%7Bx%7D", - "", - "16", - "0", - ] - ) - sources.append( - [ - "connections-xyz", - "Esri National Geographic", - "", - "", - "Requires ArcGIS Onlinesubscription", - "http://services.arcgisonline.com/ArcGIS/rest/services/NatGeo_World_Map/MapServer/tile/%7Bz%7D/%7By%7D/%7Bx%7D", - "", - "12", - "0", - ] - ) - sources.append( - [ - "connections-xyz", - "Esri Ocean", - "", - "", - "Requires ArcGIS Onlinesubscription", - "https://services.arcgisonline.com/ArcGIS/rest/services/Ocean/World_Ocean_Base/MapServer/tile/%7Bz%7D/%7By%7D/%7Bx%7D", - "", - "10", - "0", - ] - ) - sources.append( - [ - "connections-xyz", - "Esri Satellite", - "", - "", - "Requires ArcGIS Onlinesubscription", - "https://server.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer/tile/%7Bz%7D/%7By%7D/%7Bx%7D", - "", - "17", - "0", - ] - ) - sources.append( - [ - "connections-xyz", - "Esri Standard", - "", - "", - "Requires ArcGIS Onlinesubscription", - "https://server.arcgisonline.com/ArcGIS/rest/services/World_Street_Map/MapServer/tile/%7Bz%7D/%7By%7D/%7Bx%7D", - "", - "17", - "0", - ] - ) - sources.append( - [ - "connections-xyz", - "Esri Terrain", - "", - "", - "Requires ArcGIS Onlinesubscription", - "https://server.arcgisonline.com/ArcGIS/rest/services/World_Terrain_Base/MapServer/tile/%7Bz%7D/%7By%7D/%7Bx%7D", - "", - "13", - "0", - ] - ) - sources.append( - [ - "connections-xyz", - "Esri Transportation", - "", - "", - "Requires ArcGIS Onlinesubscription", - "https://server.arcgisonline.com/ArcGIS/rest/services/Reference/World_Transportation/MapServer/tile/%7Bz%7D/%7By%7D/%7Bx%7D", - "", - "20", - "0", - ] - ) - sources.append( - [ - "connections-xyz", - "Esri Topo World", - "", - "", - "Requires ArcGIS Onlinesubscription", - "http://services.arcgisonline.com/ArcGIS/rest/services/World_Topo_Map/MapServer/tile/%7Bz%7D/%7By%7D/%7Bx%7D", - "", - "20", - "0", - ] - ) - sources.append( - [ - "connections-xyz", - "OpenStreetMap Standard", - "", - "", - "OpenStreetMap contributors, under ODbL", - "http://tile.openstreetmap.org/%7Bz%7D/%7Bx%7D/%7By%7D.png", - "", - "19", - "0", - ] - ) - sources.append( - [ - "connections-xyz", - "OpenStreetMap H.O.T.", - "", - "", - "OpenStreetMap contributors, under ODbL", - "http://tile.openstreetmap.fr/hot/%7Bz%7D/%7Bx%7D/%7By%7D.png", - "", - "19", - "0", - ] - ) - sources.append( - [ - "connections-xyz", - "OpenStreetMap Monochrome", - "", - "", - "OpenStreetMap contributors, under ODbL", - "http://tiles.wmflabs.org/bw-mapnik/%7Bz%7D/%7Bx%7D/%7By%7D.png", - "", - "19", - "0", - ] - ) - sources.append( - [ - "connections-xyz", - "OpenTopoMap", - "", - "", - "Kartendaten: © OpenStreetMap-Mitwirkende, SRTM | Kartendarstellung: © OpenTopoMap (CC-BY-SA)", - "https://tile.opentopomap.org/%7Bz%7D/%7Bx%7D/%7By%7D.png", - "", - "17", - "1", - ] - ) - sources.append( - [ - "connections-xyz", - "Strava All", - "", - "", - "OpenStreetMap contributors, under ODbL", - "https://heatmap-external-b.strava.com/tiles/all/bluered/%7Bz%7D/%7Bx%7D/%7By%7D.png", - "", - "15", - "0", - ] - ) - sources.append( - [ - "connections-xyz", - "Strava Run", - "", - "", - "OpenStreetMap contributors, under ODbL", - "https://heatmap-external-b.strava.com/tiles/run/bluered/%7Bz%7D/%7Bx%7D/%7By%7D.png?v=19", - "", - "15", - "0", - ] - ) - sources.append( - [ - "connections-xyz", - "Open Weather Map Temperature", - "", - "", - "Map tiles by OpenWeatherMap, under CC BY-SA 4.0", - "http://tile.openweathermap.org/map/temp_new/%7Bz%7D/%7Bx%7D/%7By%7D.png?APPID={your_API_key}", - "", - "19", - "0", - ] - ) - sources.append( - [ - "connections-xyz", - "Open Weather Map Clouds", - "", - "", - "Map tiles by OpenWeatherMap, under CC BY-SA 4.0", - "http://tile.openweathermap.org/map/clouds_new/%7Bz%7D/%7Bx%7D/%7By%7D.png?APPID={your_API_key}", - "", - "19", - "0", - ] - ) - sources.append( - [ - "connections-xyz", - "Open Weather Map Wind Speed", - "", - "", - "Map tiles by OpenWeatherMap, under CC BY-SA 4.0", - "http://tile.openweathermap.org/map/wind_new/%7Bz%7D/%7Bx%7D/%7By%7D.png?APPID={your_API_key}", - "", - "19", - "0", - ] - ) - sources.append( - [ - "connections-xyz", - "CartoDb Dark Matter", - "", - "", - "Map tiles by CartoDB, under CC BY 3.0. Data by OpenStreetMap, under ODbL.", - "http://basemaps.cartocdn.com/dark_all/%7Bz%7D/%7Bx%7D/%7By%7D.png", - "", - "20", - "0", - ] - ) - sources.append( - [ - "connections-xyz", - "CartoDb Positron", - "", - "", - "Map tiles by CartoDB, under CC BY 3.0. Data by OpenStreetMap, under ODbL.", - "http://basemaps.cartocdn.com/light_all/%7Bz%7D/%7Bx%7D/%7By%7D.png", - "", - "20", - "0", - ] - ) - sources.append( - [ - "connections-xyz", - "Bing VirtualEarth", - "", - "", - "", - "http://ecn.t3.tiles.virtualearth.net/tiles/a{q}.jpeg?g=1", - "", - "19", - "1", - ] - ) - - for source in sources: # Add sources to browser - connection_type = source[0] - connection_name = source[1] - - QSettings().setValue( - f"qgis/{connection_type}/{connection_name}/authcfg", source[2] + # Sources + sources = [] + sources.append( + [ + "connections-xyz", + "Google Maps", + "", + "", + "", + "https://mt1.google.com/vt/lyrs=m&x=%7Bx%7D&y=%7By%7D&z=%7Bz%7D", + "", + "19", + "0", + ] + ) + sources.append( + [ + "connections-xyz", + "Google Satellite", + "", + "", + "", + "https://mt1.google.com/vt/lyrs=s&x=%7Bx%7D&y=%7By%7D&z=%7Bz%7D", + "", + "19", + "0", + ] + ) + sources.append( + [ + "connections-xyz", + "Google Terrain", + "", + "", + "", + "https://mt1.google.com/vt/lyrs=t&x=%7Bx%7D&y=%7By%7D&z=%7Bz%7D", + "", + "19", + "0", + ] + ) + sources.append( + [ + "connections-xyz", + "Google Terrain Hybrid", + "", + "", + "", + "https://mt1.google.com/vt/lyrs=p&x=%7Bx%7D&y=%7By%7D&z=%7Bz%7D", + "", + "19", + "0", + ] + ) + sources.append( + [ + "connections-xyz", + "Google Satellite Hybrid", + "", + "", + "", + "https://mt1.google.com/vt/lyrs=y&x=%7Bx%7D&y=%7By%7D&z=%7Bz%7D", + "", + "19", + "0", + ] + ) + sources.append( + [ + "connections-xyz", + "Stamen Terrain", + "", + "", + "Map tiles by Stamen Design, under CC BY 3.0. Data by OpenStreetMap, under ODbL", + "http://tile.stamen.com/terrain/%7Bz%7D/%7Bx%7D/%7By%7D.png", + "", + "20", + "0", + ] + ) + sources.append( + [ + "connections-xyz", + "Stamen Toner", + "", + "", + "Map tiles by Stamen Design, under CC BY 3.0. Data by OpenStreetMap, under ODbL", + "http://tile.stamen.com/toner/%7Bz%7D/%7Bx%7D/%7By%7D.png", + "", + "20", + "0", + ] + ) + sources.append( + [ + "connections-xyz", + "Stamen Toner Light", + "", + "", + "Map tiles by Stamen Design, under CC BY 3.0. Data by OpenStreetMap, under ODbL", + "http://tile.stamen.com/toner-lite/%7Bz%7D/%7Bx%7D/%7By%7D.png", + "", + "20", + "0", + ] + ) + sources.append( + [ + "connections-xyz", + "Stamen Watercolor", + "", + "", + "Map tiles by Stamen Design, under CC BY 3.0. Data by OpenStreetMap, under ODbL", + "http://tile.stamen.com/watercolor/%7Bz%7D/%7Bx%7D/%7By%7D.jpg", + "", + "18", + "0", + ] + ) + sources.append( + [ + "connections-xyz", + "Wikimedia Map", + "", + "", + "OpenStreetMap contributors, under ODbL", + "https://maps.wikimedia.org/osm-intl/%7Bz%7D/%7Bx%7D/%7By%7D.png", + "", + "20", + "1", + ] + ) + sources.append( + [ + "connections-xyz", + "Wikimedia Hike Bike Map", + "", + "", + "OpenStreetMap contributors, under ODbL", + "http://tiles.wmflabs.org/hikebike/%7Bz%7D/%7Bx%7D/%7By%7D.png", + "", + "17", + "1", + ] + ) + sources.append( + [ + "connections-xyz", + "Esri Boundaries Places", + "", + "", + "Requires ArcGIS Onlinesubscription", + "https://server.arcgisonline.com/ArcGIS/rest/services/Reference/World_Boundaries_and_Places/MapServer/tile/%7Bz%7D/%7By%7D/%7Bx%7D", + "", + "20", + "0", + ] + ) + sources.append( + [ + "connections-xyz", + "Esri Gray (dark)", + "", + "", + "Requires ArcGIS Onlinesubscription", + "http://services.arcgisonline.com/ArcGIS/rest/services/Canvas/World_Dark_Gray_Base/MapServer/tile/%7Bz%7D/%7By%7D/%7Bx%7D", + "", + "16", + "0", + ] + ) + sources.append( + [ + "connections-xyz", + "Esri Gray (light)", + "", + "", + "Requires ArcGIS Onlinesubscription", + "http://services.arcgisonline.com/ArcGIS/rest/services/Canvas/World_Light_Gray_Base/MapServer/tile/%7Bz%7D/%7By%7D/%7Bx%7D", + "", + "16", + "0", + ] ) - QSettings().setValue( - f"qgis/{connection_type}/{connection_name}/password", source[3] + sources.append( + [ + "connections-xyz", + "Esri National Geographic", + "", + "", + "Requires ArcGIS Onlinesubscription", + "http://services.arcgisonline.com/ArcGIS/rest/services/NatGeo_World_Map/MapServer/tile/%7Bz%7D/%7By%7D/%7Bx%7D", + "", + "12", + "0", + ] ) - QSettings().setValue( - f"qgis/{connection_type}/{connection_name}/referer", source[4] + sources.append( + [ + "connections-xyz", + "Esri Ocean", + "", + "", + "Requires ArcGIS Onlinesubscription", + "https://services.arcgisonline.com/ArcGIS/rest/services/Ocean/World_Ocean_Base/MapServer/tile/%7Bz%7D/%7By%7D/%7Bx%7D", + "", + "10", + "0", + ] ) - QSettings().setValue(f"qgis/{connection_type}/{connection_name}/url", source[5]) - QSettings().setValue( - f"qgis/{connection_type}/{connection_name}/username", source[6] + sources.append( + [ + "connections-xyz", + "Esri Satellite", + "", + "", + "Requires ArcGIS Onlinesubscription", + "https://server.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer/tile/%7Bz%7D/%7By%7D/%7Bx%7D", + "", + "17", + "0", + ] ) - QSettings().setValue( - f"qgis/{connection_type}/{connection_name}/zmax", source[7] + sources.append( + [ + "connections-xyz", + "Esri Standard", + "", + "", + "Requires ArcGIS Onlinesubscription", + "https://server.arcgisonline.com/ArcGIS/rest/services/World_Street_Map/MapServer/tile/%7Bz%7D/%7By%7D/%7Bx%7D", + "", + "17", + "0", + ] ) - QSettings().setValue( - f"qgis/{connection_type}/{connection_name}/zmin", source[8] + sources.append( + [ + "connections-xyz", + "Esri Terrain", + "", + "", + "Requires ArcGIS Onlinesubscription", + "https://server.arcgisonline.com/ArcGIS/rest/services/World_Terrain_Base/MapServer/tile/%7Bz%7D/%7By%7D/%7Bx%7D", + "", + "13", + "0", + ] ) + sources.append( + [ + "connections-xyz", + "Esri Transportation", + "", + "", + "Requires ArcGIS Onlinesubscription", + "https://server.arcgisonline.com/ArcGIS/rest/services/Reference/World_Transportation/MapServer/tile/%7Bz%7D/%7By%7D/%7Bx%7D", + "", + "20", + "0", + ] + ) + sources.append( + [ + "connections-xyz", + "Esri Topo World", + "", + "", + "Requires ArcGIS Onlinesubscription", + "http://services.arcgisonline.com/ArcGIS/rest/services/World_Topo_Map/MapServer/tile/%7Bz%7D/%7By%7D/%7Bx%7D", + "", + "20", + "0", + ] + ) + sources.append( + [ + "connections-xyz", + "OpenStreetMap Standard", + "", + "", + "OpenStreetMap contributors, under ODbL", + "http://tile.openstreetmap.org/%7Bz%7D/%7Bx%7D/%7By%7D.png", + "", + "19", + "0", + ] + ) + sources.append( + [ + "connections-xyz", + "OpenStreetMap H.O.T.", + "", + "", + "OpenStreetMap contributors, under ODbL", + "http://tile.openstreetmap.fr/hot/%7Bz%7D/%7Bx%7D/%7By%7D.png", + "", + "19", + "0", + ] + ) + sources.append( + [ + "connections-xyz", + "OpenStreetMap Monochrome", + "", + "", + "OpenStreetMap contributors, under ODbL", + "http://tiles.wmflabs.org/bw-mapnik/%7Bz%7D/%7Bx%7D/%7By%7D.png", + "", + "19", + "0", + ] + ) + sources.append( + [ + "connections-xyz", + "OpenTopoMap", + "", + "", + "Kartendaten: © OpenStreetMap-Mitwirkende, SRTM | Kartendarstellung: © OpenTopoMap (CC-BY-SA)", + "https://tile.opentopomap.org/%7Bz%7D/%7Bx%7D/%7By%7D.png", + "", + "17", + "1", + ] + ) + sources.append( + [ + "connections-xyz", + "Strava All", + "", + "", + "OpenStreetMap contributors, under ODbL", + "https://heatmap-external-b.strava.com/tiles/all/bluered/%7Bz%7D/%7Bx%7D/%7By%7D.png", + "", + "15", + "0", + ] + ) + sources.append( + [ + "connections-xyz", + "Strava Run", + "", + "", + "OpenStreetMap contributors, under ODbL", + "https://heatmap-external-b.strava.com/tiles/run/bluered/%7Bz%7D/%7Bx%7D/%7By%7D.png?v=19", + "", + "15", + "0", + ] + ) + sources.append( + [ + "connections-xyz", + "Open Weather Map Temperature", + "", + "", + "Map tiles by OpenWeatherMap, under CC BY-SA 4.0", + "http://tile.openweathermap.org/map/temp_new/%7Bz%7D/%7Bx%7D/%7By%7D.png?APPID={your_API_key}", + "", + "19", + "0", + ] + ) + sources.append( + [ + "connections-xyz", + "Open Weather Map Clouds", + "", + "", + "Map tiles by OpenWeatherMap, under CC BY-SA 4.0", + "http://tile.openweathermap.org/map/clouds_new/%7Bz%7D/%7Bx%7D/%7By%7D.png?APPID={your_API_key}", + "", + "19", + "0", + ] + ) + sources.append( + [ + "connections-xyz", + "Open Weather Map Wind Speed", + "", + "", + "Map tiles by OpenWeatherMap, under CC BY-SA 4.0", + "http://tile.openweathermap.org/map/wind_new/%7Bz%7D/%7Bx%7D/%7By%7D.png?APPID={your_API_key}", + "", + "19", + "0", + ] + ) + sources.append( + [ + "connections-xyz", + "CartoDb Dark Matter", + "", + "", + "Map tiles by CartoDB, under CC BY 3.0. Data by OpenStreetMap, under ODbL.", + "http://basemaps.cartocdn.com/dark_all/%7Bz%7D/%7Bx%7D/%7By%7D.png", + "", + "20", + "0", + ] + ) + sources.append( + [ + "connections-xyz", + "CartoDb Positron", + "", + "", + "Map tiles by CartoDB, under CC BY 3.0. Data by OpenStreetMap, under ODbL.", + "http://basemaps.cartocdn.com/light_all/%7Bz%7D/%7Bx%7D/%7By%7D.png", + "", + "20", + "0", + ] + ) + sources.append( + [ + "connections-xyz", + "Bing VirtualEarth", + "", + "", + "", + "http://ecn.t3.tiles.virtualearth.net/tiles/a{q}.jpeg?g=1", + "", + "19", + "1", + ] + ) + + for source in sources: # Add sources to browser + connection_type = source[0] + connection_name = source[1] + + QSettings().setValue( + f"qgis/{connection_type}/{connection_name}/authcfg", source[2] + ) + QSettings().setValue( + f"qgis/{connection_type}/{connection_name}/password", source[3] + ) + QSettings().setValue( + f"qgis/{connection_type}/{connection_name}/referer", source[4] + ) + QSettings().setValue( + f"qgis/{connection_type}/{connection_name}/url", source[5] + ) + QSettings().setValue( + f"qgis/{connection_type}/{connection_name}/username", source[6] + ) + QSettings().setValue( + f"qgis/{connection_type}/{connection_name}/zmax", source[7] + ) + QSettings().setValue( + f"qgis/{connection_type}/{connection_name}/zmin", source[8] + ) - iface.reloadConnections() # Update GUI + iface.reloadConnections() # Update GUI diff --git a/jord/qgis_utilities/enums.py b/jord/qgis_utilities/enums.py index aa9b0ed..6a67515 100755 --- a/jord/qgis_utilities/enums.py +++ b/jord/qgis_utilities/enums.py @@ -11,10 +11,10 @@ QgsSingleBandPseudoColorRenderer, ) -__all__ = ["QgisRendererEnum"] - from jord.geojson_utilities import GeoJsonGeometryTypesEnum +__all__ = ["QgisRendererEnum", "QgisLayerTypeEnum"] + class QgisRendererEnum(Enum): multi_band = QgsMultiBandColorRenderer diff --git a/jord/qgis_utilities/geo_interface_serialisation.py b/jord/qgis_utilities/geo_interface_serialisation.py index 02a7766..b576533 100644 --- a/jord/qgis_utilities/geo_interface_serialisation.py +++ b/jord/qgis_utilities/geo_interface_serialisation.py @@ -2,6 +2,8 @@ from typing import List, Union import shapely + +# noinspection PyUnresolvedReferences from qgis.core import QgsFeature, QgsGeometry, QgsPointXY from jord.shapely_utilities import is_multi diff --git a/jord/qgis_utilities/geometry_types.py b/jord/qgis_utilities/geometry_types.py index 397543f..5c4ca29 100755 --- a/jord/qgis_utilities/geometry_types.py +++ b/jord/qgis_utilities/geometry_types.py @@ -10,8 +10,7 @@ ] -def QgisWkbToVectorGeometryType(): - ... # QgsWkbTypes.LineGeometry +class QgisWkbToVectorGeometryType(Enum): ... # QgsWkbTypes.LineGeometry class VectorGeometryTypeEnum(Enum): diff --git a/jord/qgis_utilities/helpers/actions.py b/jord/qgis_utilities/helpers/actions.py index fba713e..4a68e7d 100755 --- a/jord/qgis_utilities/helpers/actions.py +++ b/jord/qgis_utilities/helpers/actions.py @@ -2,8 +2,8 @@ from typing import Any -from PyQt5.QtGui import QIcon -from PyQt5.QtWidgets import QAction, QWidget +from qgis.PyQt.QtGui import QIcon +from qgis.PyQt.QtWidgets import QAction, QWidget from jord.qgis_utilities.helpers.signals import reconnect_signal diff --git a/jord/qgis_utilities/helpers/groups.py b/jord/qgis_utilities/helpers/groups.py index 800a9fc..6ad14bf 100644 --- a/jord/qgis_utilities/helpers/groups.py +++ b/jord/qgis_utilities/helpers/groups.py @@ -1,5 +1,6 @@ from typing import Optional, Any +# noinspection PyUnresolvedReferences from qgis.core import QgsLayerTreeGroup __all__ = ["duplicate_groups"] diff --git a/jord/qgis_utilities/helpers/models.py b/jord/qgis_utilities/helpers/models.py index 443766c..c20a294 100755 --- a/jord/qgis_utilities/helpers/models.py +++ b/jord/qgis_utilities/helpers/models.py @@ -28,6 +28,7 @@ def __init__(self, data: Tuple = (()), parent: Any = None): super().__init__(parent) self.data = data + # noinspection PyMethodMayBeStatic def headerData( self, section: int, orientation: QtCore.Qt.Orientation, role: int ) -> str: # Do not rename diff --git a/jord/qgis_utilities/helpers/progress_bar.py b/jord/qgis_utilities/helpers/progress_bar.py index 5f0d997..991197e 100755 --- a/jord/qgis_utilities/helpers/progress_bar.py +++ b/jord/qgis_utilities/helpers/progress_bar.py @@ -10,6 +10,9 @@ # noinspection PyUnresolvedReferences from qgis.PyQt import QtWidgets +from warg import AlsoDecorator, passes_kws_to + +from jord.qt_utilities import WindowModalityEnum __all__ = [ "make_dialog_progress_bar", @@ -18,10 +21,6 @@ "InjectedProgressBar", ] -from warg import AlsoDecorator, passes_kws_to - -from jord.qt_utilities import WindowModalityEnum - def make_progress_bar( *, diff --git a/jord/qgis_utilities/helpers/sessions.py b/jord/qgis_utilities/helpers/sessions.py index d818ecb..c0bfe51 100755 --- a/jord/qgis_utilities/helpers/sessions.py +++ b/jord/qgis_utilities/helpers/sessions.py @@ -1,5 +1,6 @@ #!/usr/bin/env python3 +# noinspection PyUnresolvedReferences from qgis.core import QgsMapLayer, QgsRasterDataProvider from warg import AlsoDecorator diff --git a/jord/qgis_utilities/helpers/signals.py b/jord/qgis_utilities/helpers/signals.py index 8d94375..7eca28f 100755 --- a/jord/qgis_utilities/helpers/signals.py +++ b/jord/qgis_utilities/helpers/signals.py @@ -1,5 +1,12 @@ #!/usr/bin/env python3 + +from logging import warning +from typing import Optional + +# noinspection PyUnresolvedReferences +from qgis.PyQt import QtCore + __author__ = "Christian Heider Lindbjerg" __doc__ = r""" @@ -8,15 +15,12 @@ __all__ = ["disconnect_signal", "connect_signal", "reconnect_signal"] -from logging import warning - -# noinspection PyUnresolvedReferences -from qgis.PyQt import QtCore - IS_DEBUGGING = False -def connect_signal(signal: QtCore.pyqtSignal, new_handler: callable = None) -> None: +def connect_signal( + signal: QtCore.pyqtSignal, new_handler: Optional[callable] = None +) -> None: """ :param signal: @@ -31,7 +35,9 @@ def connect_signal(signal: QtCore.pyqtSignal, new_handler: callable = None) -> N warning("new_handler is None") -def disconnect_signal(signal: QtCore.pyqtSignal, old_handler: callable = None) -> None: +def disconnect_signal( + signal: QtCore.pyqtSignal, old_handler: Optional[callable] = None +) -> None: """ :param signal: @@ -55,17 +61,17 @@ def disconnect_signal(signal: QtCore.pyqtSignal, old_handler: callable = None) - def reconnect_signal( signal: QtCore.pyqtSignal, - new_handler: callable = None, - old_handler: callable = None, + new_handler: Optional[callable] = None, + old_handler: Optional[callable] = None, ) -> None: """ :param signal: :type signal: QtCore.pyqtSignal :param new_handler: - :type new_handler: callable + :type new_handler: Optional[callable] :param old_handler: - :type old_handler: callable + :type old_handler: Optional[callable] :return: :rtype: None """ diff --git a/jord/qgis_utilities/styles.py b/jord/qgis_utilities/styles.py index 05e1c3a..9f151ff 100644 --- a/jord/qgis_utilities/styles.py +++ b/jord/qgis_utilities/styles.py @@ -4,6 +4,7 @@ def add_xml_style(iface, path: Path = "styles/my_directional_lines.xml") -> None: + # noinspection PyUnresolvedReferences from qgis.core import QgsStyle if not isinstance(path, Path): diff --git a/jord/qlive_utilities/clients/interfaced.py b/jord/qlive_utilities/clients/interfaced.py index e563171..48f15ce 100755 --- a/jord/qlive_utilities/clients/interfaced.py +++ b/jord/qlive_utilities/clients/interfaced.py @@ -13,8 +13,6 @@ class InterfacedQliveClient(QliveClient): def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) - def raster(self): - ... + def raster(self): ... - def geometry(self): - ... + def geometry(self): ... diff --git a/jord/qt_utilities/enums.py b/jord/qt_utilities/enums.py index 5b4c8d2..e068081 100755 --- a/jord/qt_utilities/enums.py +++ b/jord/qt_utilities/enums.py @@ -1,4 +1,6 @@ #!/usr/bin/env python3 +from enum import Flag, Enum +from typing import Any __all__ = [ "DockWidgetAreaFlag", @@ -17,27 +19,137 @@ "FocusReasonEnum", "ColorEnum", "WindowModalityEnum", + "AlignmentFlag", ] -from enum import Flag, Enum -from typing import Any +try: + from PyQt6.QtCore import Qt + + class AlignmentFlag(Flag): + """ + Alignment + """ + + left = Qt.AlignmentFlag.AlignLeft + right = Qt.AlignmentFlag.AlignRight + bottom = Qt.AlignmentFlag.AlignBottom + top = Qt.AlignmentFlag.AlignTop + center = Qt.AlignmentFlag.AlignCenter + horizontal_center = Qt.AlignmentFlag.AlignHCenter + vertical_center = Qt.AlignmentFlag.AlignVCenter + + class WindowModalityEnum(Enum): + """ + + PySide2.QtCore.Qt.WindowModality¶ + This enum specifies the behavior of a modal window. A modal window is one that blocks input to other windows. Note that windows that are children of a modal window are not blocked. + + The values are: + + Constant + + Description + + Qt.NonModal + + The window is not modal and does not block input to other windows. + + Qt.WindowModal + + The window is modal to a single window hierarchy and blocks input to its parent window, all grandparent windows, and all siblings of its parent and grandparent windows. + + Qt.ApplicationModal + + The window is modal to the application and blocks input to all windows.""" + + non_modal = Qt.WindowModality.NonModal + application = Qt.WindowModality.ApplicationModal + window = Qt.WindowModality.WindowModal + + class DockWidgetAreaFlag(Flag): + left = ( + Qt.DockWidgetArea.LeftDockWidgetArea + ) # 0x1 The left dock area of a QMainWindow. + right = ( + Qt.DockWidgetArea.RightDockWidgetArea + ) # 0x2 The right dock area of a QMainWindow. + top = ( + Qt.DockWidgetArea.TopDockWidgetArea + ) # 0x4 The top dock area of a QMainWindow. + bottom = ( + Qt.DockWidgetArea.BottomDockWidgetArea + ) # 0x8 The bottom dock area of a QMainWindow. + all = ( + Qt.DockWidgetArea.AllDockWidgetAreas + ) # DockWidgetArea_Mask All dock widget areas (default). + none = Qt.DockWidgetArea.NoDockWidgetArea # 0 No dock widget areas. + + class CheckStateEnum(Enum): + unchecked = Qt.CheckState.Unchecked + partial = Qt.CheckState.PartiallyChecked + checked = Qt.CheckState.Checked + +except: + try: + from PyQt5.QtCore import Qt + except: + from qgis.PyQt.QtCore import Qt + + class AlignmentFlag(Flag): + """ + Alignment + """ + + left = Qt.AlignLeft + right = Qt.AlignRight + bottom = Qt.AlignBottom + top = Qt.AlignTop + center = Qt.AlignCenter + horizontal_center = Qt.AlignHCenter + vertical_center = Qt.AlignVCenter + + class WindowModalityEnum(Enum): + """ + + PySide2.QtCore.Qt.WindowModality¶ + This enum specifies the behavior of a modal window. A modal window is one that blocks input to other windows. Note that windows that are children of a modal window are not blocked. -from qgis.PyQt.QtCore import Qt # TODO: Should not be qgis import + The values are: + Constant -class DockWidgetAreaFlag(Flag): - left = Qt.LeftDockWidgetArea # 0x1 The left dock area of a QMainWindow. - right = Qt.RightDockWidgetArea # 0x2 The right dock area of a QMainWindow. - top = Qt.TopDockWidgetArea # 0x4 The top dock area of a QMainWindow. - bottom = Qt.BottomDockWidgetArea # 0x8 The bottom dock area of a QMainWindow. - all = Qt.AllDockWidgetAreas # DockWidgetArea_Mask All dock widget areas (default). - none = Qt.NoDockWidgetArea # 0 No dock widget areas. + Description + Qt.NonModal -class CheckStateEnum(Enum): - unchecked = Qt.Unchecked - partial = Qt.PartiallyChecked - checked = Qt.Checked + The window is not modal and does not block input to other windows. + + Qt.WindowModal + + The window is modal to a single window hierarchy and blocks input to its parent window, all grandparent windows, and all siblings of its parent and grandparent windows. + + Qt.ApplicationModal + + The window is modal to the application and blocks input to all windows.""" + + non_modal = Qt.NonModal + application = Qt.ApplicationModal + window = Qt.WindowModal + + class DockWidgetAreaFlag(Flag): + left = Qt.LeftDockWidgetArea # 0x1 The left dock area of a QMainWindow. + right = Qt.RightDockWidgetArea # 0x2 The right dock area of a QMainWindow. + top = Qt.TopDockWidgetArea # 0x4 The top dock area of a QMainWindow. + bottom = Qt.BottomDockWidgetArea # 0x8 The bottom dock area of a QMainWindow. + all = ( + Qt.AllDockWidgetAreas + ) # DockWidgetArea_Mask All dock widget areas (default). + none = Qt.NoDockWidgetArea # 0 No dock widget areas. + + class CheckStateEnum(Enum): + unchecked = Qt.Unchecked + partial = Qt.PartiallyChecked + checked = Qt.Checked INT_TO_CHECK_STATE = { @@ -611,46 +723,3 @@ class KeyEnum(Enum): Qt::Key_Exit 0x0102000a Qt::Key_Cancel 0x01020001 """ - - -class AlignmentFlag(Flag): - """ - Alignment - """ - - left = Qt.AlignLeft - right = Qt.AlignRight - bottom = Qt.AlignBottom - top = Qt.AlignTop - center = Qt.AlignCenter - horizontal_center = Qt.AlignHCenter - vertical_center = Qt.AlignVCenter - - -class WindowModalityEnum(Enum): - """ - - PySide2.QtCore.Qt.WindowModality¶ - This enum specifies the behavior of a modal window. A modal window is one that blocks input to other windows. Note that windows that are children of a modal window are not blocked. - - The values are: - - Constant - - Description - - Qt.NonModal - - The window is not modal and does not block input to other windows. - - Qt.WindowModal - - The window is modal to a single window hierarchy and blocks input to its parent window, all grandparent windows, and all siblings of its parent and grandparent windows. - - Qt.ApplicationModal - - The window is modal to the application and blocks input to all windows.""" - - non_modal = Qt.NonModal - application = Qt.ApplicationModal - window = Qt.WindowModal diff --git a/jord/shapely_utilities/mirroring.py b/jord/shapely_utilities/mirroring.py index 0e84122..a816451 100755 --- a/jord/shapely_utilities/mirroring.py +++ b/jord/shapely_utilities/mirroring.py @@ -14,8 +14,7 @@ # display(Polygon(pts.dot([[1,0],[0,-1]]))) -def principal_axis(): - ... +def principal_axis(): ... def reflection(x0: Number) -> Callable: diff --git a/jord/shapely_utilities/projection.py b/jord/shapely_utilities/projection.py index 1c1f953..9ce3439 100755 --- a/jord/shapely_utilities/projection.py +++ b/jord/shapely_utilities/projection.py @@ -69,6 +69,7 @@ def project_point_to_line_points( Source: http://gis.stackexchange.com/a/438/19627 + :param must_be_orthogonal: :param point: a shapely Point object :param line_start: the line starting point as a shapely Point :param line_end: the line end point as a shapely Point diff --git a/requirements.txt b/requirements.txt index 8c8680e..bfbf4d2 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,6 +1,6 @@ apppath>=1.0.2 draugr>=1.0.9 -numpy>=1.20.2 +numpy>=1.20.0 pyzmq sorcery sympy diff --git a/samples/settings/qgis_settings.py b/samples/settings/qgis_settings.py index 0a1bb62..afd5146 100755 --- a/samples/settings/qgis_settings.py +++ b/samples/settings/qgis_settings.py @@ -8,12 +8,9 @@ from typing import Any -from PyQt5.QtCore import ( - QSettings, -) - __all__ = ["add_settings"] +# noinspection PyUnresolvedReferences from qgis.core import QgsProject, QgsSettings, QgsVectorLayer @@ -67,7 +64,7 @@ def vector_layer_settings(name: str) -> None: def add_settings(settings, key: str, value: Any) -> None: if settings is None: - settings = QSettings() + settings = QgsSettings() settings.beginGroup("PostgreSQL/connections") # self.cmb_db_connections.addItem('------------') # self.cmb_db_connections.addItems(settings.childGroups()) diff --git a/tests/gdal/conversion.py b/tests/gdal/conversion.py index c98facd..1cd14e0 100755 --- a/tests/gdal/conversion.py +++ b/tests/gdal/conversion.py @@ -9,12 +9,10 @@ __all__ = [] -def test_tiff_to_geotiff(): - ... +def test_tiff_to_geotiff(): ... -def test_geotiff_to_tiff(): - ... +def test_geotiff_to_tiff(): ... if __name__ == "__main__": diff --git a/tests/pip_parsing/piper.py b/tests/pip_parsing/piper.py index befb613..11067c0 100755 --- a/tests/pip_parsing/piper.py +++ b/tests/pip_parsing/piper.py @@ -334,8 +334,7 @@ def get_versions_from_index( return None -def pip_freeze_list() -> List: - ... +def pip_freeze_list() -> List: ... def is_requirement_updatable(requirement_name: str) -> bool: diff --git a/tests/shapely/clamp.py b/tests/shapely/clamp.py index ecb6267..2632652 100755 --- a/tests/shapely/clamp.py +++ b/tests/shapely/clamp.py @@ -9,8 +9,7 @@ __all__ = [] -def _main(): - ... +def _main(): ... if __name__ == "__main__": diff --git a/tests/shapely/lines.py b/tests/shapely/lines.py index ecb6267..2632652 100755 --- a/tests/shapely/lines.py +++ b/tests/shapely/lines.py @@ -9,8 +9,7 @@ __all__ = [] -def _main(): - ... +def _main(): ... if __name__ == "__main__":