### Clone quickmapservices_contrib Repository Source: https://github.com/nextgis/quickmapservices/wiki/Adding-data-source Clone the contribution repository to your local machine to start adding new data sources. This is the first step in the GitHub workflow. ```bash git clone https://github.com/yourgithubname/quickmapservices_contrib.git ``` -------------------------------- ### Copy Data Source to QGIS Installation Source: https://github.com/nextgis/quickmapservices/wiki/Adding-data-source After successfully configuring and testing your new data source, copy its directory to the QuickMapServices data sources folder within your QGIS user profile for local testing. ```bash cp -R mapquest_osm ~/.qgis2/QuickMapServices/Contribute/data_sources ``` -------------------------------- ### Contribute New Service via CLI Source: https://context7.com/nextgis/quickmapservices/llms.txt Guides through contributing a new service to the community catalog using git. Includes forking, cloning, editing, testing, and submitting a pull request. ```bash # Fork and clone the contributions repository git clone https://github.com/yourgithubname/quickmapservices_contrib.git cd quickmapservices_contrib/data_sources # Copy an existing service as a template cp -R osm_standard my_new_service cd my_new_service # Edit metadata.ini with the new service's details # (see INI format above) # Test locally by copying into your QGIS plugin data directory cp -R . ~/.local/share/QGIS/QGIS3/profiles/default/python/plugins/quick_map_services/data_sources/my_new_service/ # Commit and open a pull request git add . git commit -m "Add my_new_service TMS basemap" git push origin main # Open PR against https://github.com/nextgis/quickmapservices_contrib ``` -------------------------------- ### Get Localized News with ApiClient Source: https://context7.com/nextgis/quickmapservices/llms.txt Retrieve a localized news item from the static QMS endpoint using ApiClient. This is used by the search panel to display banners. ```python from quick_map_services.qms_external_api_python.api.api_base import ApiClient client = ApiClient() news = client.get_news() # Returns QmsNews or None on failure if news: en_text = news.get_text("en") ru_text = news.get_text("ru") print(en_text) # e.g. 'Download geodata for your project' ``` -------------------------------- ### Configure DataSourceInfo for Various Service Types Source: https://context7.com/nextgis/quickmapservices/llms.txt Demonstrates how to create and configure a DataSourceInfo object for different service types including TMS with subdomain switching, MVT (Vector Tiles), and WFS. Ensure correct properties are set based on the service type. ```python from quick_map_services.data_source_info import DataSourceInfo # --- TMS with subdomain switching --- ds = DataSourceInfo() ds.type = "TMS" ds.tms_url = "https://{switch:a,b,c}.tile.openstreetmap.org/{z}/{x}/{y}.png" print(ds.alt_tms_urls) # ['https://a.tile.openstreetmap.org/{z}/{x}/{y}.png', # 'https://b.tile.openstreetmap.org/{z}/{x}/{y}.png', # 'https://c.tile.openstreetmap.org/{z}/{x}/{y}.png'] # --- MVT (Vector Tiles) --- mvt_ds = DataSourceInfo() mvt_ds.type = "MVT" mvt_ds.mvt_url = "https://example.com/tiles/{z}/{x}/{y}.pbf" mvt_ds.mvt_style_url = "https://example.com/style.json" mvt_ds.mvt_zmin = 0 mvt_ds.mvt_zmax = 14 # --- WFS --- wfs_ds = DataSourceInfo() wfs_ds.type = "WFS" wfs_ds.wfs_url = "https://example.com/wfs" wfs_ds.wfs_layers = ["roads", "buildings"] wfs_ds.wfs_epsg = 4326 ``` -------------------------------- ### QmsSettings Source: https://context7.com/nextgis/quickmapservices/llms.txt Manages QuickMapServices plugin settings, allowing reading and writing preferences through `QgsSettings` and handling migration from legacy storage. ```APIDOC ## QmsSettings — Plugin Settings Management Centralized settings handler for reading and writing all QMS plugin preferences via `QgsSettings`. Handles one-time migration from legacy `QSettings` storage. Settings keys are namespaced under `NextGIS/QuickMapServices/`. ```python from quick_map_services.core.settings import QmsSettings settings = QmsSettings() # --- Read settings --- print(settings.endpoint_url) # "https://qms.nextgis.com" print(settings.enable_otf_3857) # False print(settings.is_debug_logs_enabled) # False print(settings.hidden_datasource_id_list) # ["osm_standard", ...] # --- Modify settings --- settings.endpoint_url = "https://my-qms-instance.example.com" settings.enable_otf_3857 = True settings.is_debug_logs_enabled = True settings.hidden_datasource_id_list = ["osm_standard", "google_satellite"] # --- Access recently used services (list of (dict, QByteArray) tuples) --- for svc_json, image_ba in settings.last_used_services: print(svc_json["name"], svc_json["type"]) ``` ``` -------------------------------- ### Navigate to Data Sources Directory Source: https://github.com/nextgis/quickmapservices/wiki/Adding-data-source Change the current directory to the location where all data sources are stored within the cloned repository. ```bash cd quickmapservices_contrib/data_sources ``` -------------------------------- ### Retrieve Icons with ApiClientV1 Source: https://context7.com/nextgis/quickmapservices/llms.txt Fetch icon metadata and raw image content from the QMS catalog using ApiClientV1. Icon content is returned as raw bytes. ```python from quick_map_services.qms_external_api_python.client import Client client = Client() # --- List all icons matching a name --- icons = client.get_icons(search_str="osm") for icon in icons: print(icon["id"], icon.get("name")) # --- Get icon metadata by ID --- icon_info = client.get_icon_info(icon_id=12) print(icon_info) # {"id": 12, "name": "osm", ...} # --- Download icon image bytes (PNG) at a given size --- icon_bytes = client.get_icon_content(icon_id=12, width=32, height=32) # Use in Qt: # from qgis.PyQt.QtCore import QByteArray # from qgis.PyQt.QtGui import QImage, QPixmap # qimg = QImage.fromData(QByteArray(icon_bytes)) # pixmap = QPixmap.fromImage(qimg) # --- Get the default/fallback icon --- default_bytes = client.get_default_icon(width=24, height=24) ``` -------------------------------- ### Copy and Rename Data Source Source: https://github.com/nextgis/quickmapservices/wiki/Adding-data-source Create a new data source by copying an existing one (e.g., osm_tracks) and renaming it to your desired new data source name (e.g., mapquest_osm). Then, navigate into the new data source directory. ```bash cp -R osm_tracks mapquest_osm cd mapquest_osm ``` -------------------------------- ### Manage QMS Plugin Settings Source: https://context7.com/nextgis/quickmapservices/llms.txt Provides methods for reading and modifying Quick Map Services plugin preferences using QgsSettings. Settings are namespaced under 'NextGIS/QuickMapServices/'. ```python from quick_map_services.core.settings import QmsSettings settings = QmsSettings() # --- Read settings --- print(settings.endpoint_url) # "https://qms.nextgis.com" print(settings.enable_otf_3857) # False print(settings.is_debug_logs_enabled) # False print(settings.hidden_datasource_id_list) # ["osm_standard", ...] # --- Modify settings --- settings.endpoint_url = "https://my-qms-instance.example.com" settings.enable_otf_3857 = True settings.is_debug_logs_enabled = True settings.hidden_datasource_id_list = ["osm_standard", "google_satellite"] # --- Access recently used services (list of (dict, QByteArray) tuples) --- for svc_json, image_ba in settings.last_used_services: print(svc_json["name"], svc_json["type"]) ``` -------------------------------- ### Fetch Geoservice Info and Build DataSourceInfo Source: https://context7.com/nextgis/quickmapservices/llms.txt Fetches detailed information for a given geoservice ID and deserializes it into a DataSourceInfo object. This is useful for programmatically adding remote services to the QGIS project. ```python client = Client() geoservice_info = client.get_geoservice_info(448) # OpenStreetMap Standard ds = DataSourceSerializer.read_from_json(geoservice_info) # Add the layer to the current QGIS project try: add_layer_to_map(ds) # Layer is now visible in the QGIS layer panel except Exception as e: print(f"Failed to add layer: {e}") ``` -------------------------------- ### Search Geoservices with ApiClientV1 Source: https://context7.com/nextgis/quickmapservices/llms.txt Use ApiClientV1 to search for geospatial services by name, type, EPSG, status, or geographic extent. Initialize the client with the QMS endpoint. ```python from quick_map_services.qms_external_api_python.client import Client from quick_map_services.qms_external_api_python.api.geoservice_types import GeoServiceType client = Client() # Uses endpoint from QmsSettings (default: https://qms.nextgis.com) # --- Search for geoservices by name --- results = client.get_geoservices(search_str="OpenStreetMap") for svc in results: print(svc["id"], svc["name"], svc["type"]) # Output: 448 OpenStreetMap Standard tms # --- Filter by type, EPSG, status, and extent --- tms_services = client.get_geoservices( type_filter=GeoServiceType.TMS, epsg_filter=3857, cumulative_status="works", limit=10, offset=0, ) # --- Shortcut search method --- results = client.search_geoservices( search_str="satellite", intersects_boundary="POLYGON((30 50, 40 50, 40 60, 30 60, 30 50))", # WKT filter ) # --- Retrieve full service details by ID --- info = client.get_geoservice_info(448) print(info["url"]) # e.g. https://tile.openstreetmap.org/{z}/{x}/{y}.png print(info["z_min"]) print(info["z_max"]) print(info["epsg"]) print(info["license_name"]) # --- Also accepts a geoservice dict or object --- info = client.get_geoservice_info(results[0]) # dict with "id" key ``` -------------------------------- ### Load Local Service from INI using DataSourceSerializer Source: https://context7.com/nextgis/quickmapservices/llms.txt Reads a local .ini service definition file and returns a DataSourceInfo object. This is used for bundled or contributed services stored in the plugin's data directory. ```python from quick_map_services.data_source_serializer import DataSourceSerializer # INI file defines a TMS, WMS, WFS, GeoJSON, GDAL, or MVT service ds = DataSourceSerializer.read_from_ini("/path/to/my_service/metadata.ini") print(ds.id) # "my_osm_service" print(ds.type) # "TMS" print(ds.alias) # "My OSM Layer" print(ds.tms_url) # "https://tile.openstreetmap.org/{z}/{x}/{y}.png" from quick_map_services.qgis_map_helpers import add_layer_to_map add_layer_to_map(ds) ``` -------------------------------- ### ApiClientV1 - Icon Retrieval Source: https://context7.com/nextgis/quickmapservices/llms.txt Fetches icon metadata and raw image content from the QMS catalog. Supports listing icons by name, retrieving icon metadata by ID, and downloading icon image bytes. ```APIDOC ## ApiClientV1 - Icon Retrieval ### Description Fetches icon metadata and raw image content from the QMS catalog. Icon content is returned as raw bytes suitable for use with Qt's `QByteArray` and `QPixmap`. ### Methods #### `get_icons` Lists all icons matching a search string. - **search_str** (str) - String to search for in icon names. #### `get_icon_info` Gets icon metadata by its ID. - **icon_id** (int) - The ID of the icon. #### `get_icon_content` Downloads icon image bytes (PNG) at a given size. - **icon_id** (int) - The ID of the icon. - **width** (int) - The desired width of the icon. - **height** (int) - The desired height of the icon. #### `get_default_icon` Gets the default or fallback icon image bytes. - **width** (int) - The desired width of the icon. - **height** (int) - The desired height of the icon. ### Request Example (get_icons) ```python from quick_map_services.qms_external_api_python.client import Client client = Client() icons = client.get_icons(search_str="osm") for icon in icons: print(icon["id"], icon.get("name")) ``` ### Request Example (get_icon_info) ```python client = Client() icon_info = client.get_icon_info(icon_id=12) print(icon_info) ``` ### Request Example (get_icon_content) ```python client = Client() icon_bytes = client.get_icon_content(icon_id=12, width=32, height=32) # Use in Qt: # from qgis.PyQt.QtCore import QByteArray # from qgis.PyQt.QtGui import QImage, QPixmap # qimg = QImage.fromData(QByteArray(icon_bytes)) # pixmap = QPixmap.fromImage(qimg) ``` ### Request Example (get_default_icon) ```python client = Client() default_bytes = client.get_default_icon(width=24, height=24) ``` ### Response Example (get_icons) ```json [ { "id": 12, "name": "osm", "url": "/static/icons/osm.png" } ] ``` ### Response Example (get_icon_info) ```json { "id": 12, "name": "osm", "url": "/static/icons/osm.png" } ``` ### Response Example (get_icon_content / get_default_icon) Raw PNG image bytes. ``` -------------------------------- ### Local Service INI Configuration Format Source: https://context7.com/nextgis/quickmapservices/llms.txt Defines a new local service using an INI file. This format is used for custom services and is parsed by DataSourceSerializer.read_from_ini. ```ini # ~/.local/share/QGIS/QGIS3/profiles/default/python/plugins/quick_map_services/ # Contribute/data_sources/my_service/metadata.ini [general] id = my_osm_service type = TMS [ui] group = openstreetmap alias = My OSM Tiles icon = osm.svg alias[ru] = Мои тайлы OSM [license] name = ODbL link = https://opendatacommons.org/licenses/odbl/ copyright_text = © OpenStreetMap contributors copyright_link = https://www.openstreetmap.org/copyright terms_of_use = https://www.openstreetmap.org/copyright [tms] url = https://{switch:a,b,c}.tile.openstreetmap.org/{z}/{x}/{y}.png zmin = 0 zmax = 19 y_origin_top = 1 epsg_crs_id = 3857 ``` -------------------------------- ### Save Service Definition to INI using DataSourceSerializer Source: https://context7.com/nextgis/quickmapservices/llms.txt Serializes a DataSourceInfo object to a .ini file in the standard QMS format. This is useful for programmatically creating or exporting custom user-defined services. ```python from quick_map_services.data_source_info import DataSourceInfo from quick_map_services.data_source_serializer import DataSourceSerializer ds = DataSourceInfo() ds.id = "my_custom_tms" ds.type = "TMS" ds.group = "custom" ds.alias = "My Custom Basemap" ds.tms_url = "https://tile.openstreetmap.org/{z}/{x}/{y}.png" ds.tms_zmin = 0 ds.tms_zmax = 19 ds.tms_epsg_crs_id = 3857 ds.copyright_text = "© OpenStreetMap contributors" ds.copyright_link = "https://www.openstreetmap.org/copyright" DataSourceSerializer.write_to_ini(ds, "/path/to/output/metadata.ini") # Resulting INI file: # [general] # id = my_custom_tms # type = TMS # [ui] # alias = My Custom Basemap # group = custom # [tms] # url = https://tile.openstreetmap.org/{z}/{x}/{y}.png # zmin = 0 # zmax = 19 # epsg_crs_id = 3857 ``` -------------------------------- ### ApiClientV1 - Geoservice Catalog API Source: https://context7.com/nextgis/quickmapservices/llms.txt The ApiClientV1 (Client) wraps the public QMS catalog REST API for searching and retrieving geospatial services. It supports filtering by name, type, EPSG, status, and extent, as well as retrieving detailed service information. ```APIDOC ## ApiClientV1 - Geoservice Catalog API ### Description Wraps the public QMS catalog REST API. It is initialized with the configured endpoint URL (default: `https://qms.nextgis.com`) and all requests are executed synchronously through QGIS's `QgsNetworkAccessManager`. ### Methods #### `get_geoservices` Searches for geoservices by name, type, EPSG, status, and extent. - **search_str** (str) - Optional - String to search for in service names. - **type_filter** (GeoServiceType) - Optional - Filter by service type (e.g., TMS, WMS). - **epsg_filter** (int) - Optional - Filter by EPSG code. - **cumulative_status** (str) - Optional - Filter by service status (e.g., "works"). - **limit** (int) - Optional - Maximum number of results to return. - **offset** (int) - Optional - Number of results to skip. #### `search_geoservices` A shortcut method for searching geoservices, supporting an `intersects_boundary` filter. - **search_str** (str) - Optional - String to search for in service names. - **intersects_boundary** (str) - Optional - WKT string defining a boundary to filter services by spatial intersection. #### `get_geoservice_info` Retrieves full details for a specific geoservice by its ID. - **id** (int or dict or object) - The ID of the geoservice, or a dictionary/object containing the ID. ### Request Example (get_geoservices) ```python from quick_map_services.qms_external_api_python.client import Client from quick_map_services.qms_external_api_python.api.geoservice_types import GeoServiceType client = Client() results = client.get_geoservices(search_str="OpenStreetMap") for svc in results: print(svc["id"], svc["name"], svc["type"]) ``` ### Request Example (search_geoservices) ```python client = Client() results = client.search_geoservices( search_str="satellite", intersects_boundary="POLYGON((30 50, 40 50, 40 60, 30 60, 30 50))" ) ``` ### Request Example (get_geoservice_info) ```python client = Client() info = client.get_geoservice_info(448) print(info["url"]) print(info["z_min"]) print(info["z_max"]) print(info["epsg"]) print(info["license_name"]) ``` ### Response Example (get_geoservices/search_geoservices) ```json [ { "id": 448, "name": "OpenStreetMap Standard", "type": "tms", "description": "OpenStreetMap Standard map tiles.", "url": "https://tile.openstreetmap.org/{z}/{x}/{y}.png", "attribution": "© OpenStreetMap contributors", "z_min": 0, "z_max": 19, "epsg": 3857, "license_name": "ODbL" } ] ``` ### Response Example (get_geoservice_info) ```json { "id": 448, "name": "OpenStreetMap Standard", "type": "tms", "description": "OpenStreetMap Standard map tiles.", "url": "https://tile.openstreetmap.org/{z}/{x}/{y}.png", "attribution": "© OpenStreetMap contributors", "z_min": 0, "z_max": 19, "epsg": 3857, "license_name": "ODbL" } ``` ``` -------------------------------- ### Edit Metadata for New Data Source Source: https://github.com/nextgis/quickmapservices/wiki/Adding-data-source Configure the details of your new data source by editing the metadata.ini file. Fill in general, UI, license, and specific type (e.g., TMS) information. ```ini [general] id = mapquest_osm type = TMS is_contrib = False [ui] group = mapquest alias = MapQuest OSM icon = mapquest.svg [license] name = Community Edition License link = http://developer.mapquest.com/web/info/terms-of-use copyright_text =Tiles Courtesy of MapQuest, © OpenStreetMap contributors copyright_link = http://www.mapquest.com/ terms_of_use = http://developer.mapquest.com/web/products/open/map#terms [tms] url = http://otile1.mqcdn.com/tiles/1.0.0/map/${z}/${x}/${y}.jpg zmax = 19 ``` -------------------------------- ### ApiClient.get_news Source: https://context7.com/nextgis/quickmapservices/llms.txt Retrieves a localized news item from the static QMS endpoint, used for displaying promotional or informational banners in the search panel. ```APIDOC ## ApiClient.get_news ### Description Retrieves a localized news item from the static QMS endpoint. Used by the search panel to display promotional or informational banners. ### Method `get_news()` ### Parameters None ### Request Example ```python from quick_map_services.qms_external_api_python.api.api_base import ApiClient client = ApiClient() news = client.get_news() if news: en_text = news.get_text("en") ru_text = news.get_text("ru") print(en_text) ``` ### Response #### Success Response - **QmsNews object** or **None**: Returns a `QmsNews` object if a news item is available, otherwise returns `None`. - `get_text(lang_code: str)`: Method to retrieve the news text for a specific language. ### Response Example ```python # Assuming 'news' is the QmsNews object returned by get_news() en_text = news.get_text("en") # e.g., 'Download geodata for your project' ru_text = news.get_text("ru") # e.g., 'Скачайте геоданные для вашего проекта' ``` ``` -------------------------------- ### DataSourceSerializer.read_from_ini Source: https://context7.com/nextgis/quickmapservices/llms.txt Loads a local service definition from an INI file into a DataSourceInfo object. This is useful for bundled or custom services. ```APIDOC ## DataSourceSerializer.read_from_ini — Load a Local Service from INI Reads a local `.ini` service definition file and returns a `DataSourceInfo` object ready to be passed to `add_layer_to_map`. Used for bundled/contributed services stored in the plugin's data directory. ```python from quick_map_services.data_source_serializer import DataSourceSerializer # INI file defines a TMS, WMS, WFS, GeoJSON, GDAL, or MVT service ds = DataSourceSerializer.read_from_ini("/path/to/my_service/metadata.ini") print(ds.id) # "my_osm_service" print(ds.type) # "TMS" print(ds.alias) # "My OSM Layer" print(ds.tms_url) # "https://tile.openstreetmap.org/{z}/{x}/{y}.png" from quick_map_services.qgis_map_helpers import add_layer_to_map add_layer_to_map(ds) ``` ``` -------------------------------- ### Set Tile Layer CRS by Custom PROJ String Source: https://context7.com/nextgis/quickmapservices/llms.txt Sets a custom Coordinate Reference System for a tile layer using a PROJ string. This is useful for non-standard CRS definitions. ```python set_tile_layer_proj( layer, custom_proj="+proj=merc +a=6378137 +b=6378137 +lat_ts=0 +lon_0=0 +x_0=0 +y_0=0 +k=1 +units=m +nadgrids=@null +wktext +no_defs" ) ``` -------------------------------- ### DataSourceSerializer.write_to_ini Source: https://context7.com/nextgis/quickmapservices/llms.txt Serializes a DataSourceInfo object into a standard QMS format INI file. This is useful for creating or exporting custom user-defined services programmatically. ```APIDOC ## DataSourceSerializer.write_to_ini — Save a Service Definition to INI Serializes a `DataSourceInfo` object to a `.ini` file in the standard QMS format. Useful for programmatically creating or exporting custom user-defined services. ```python from quick_map_services.data_source_info import DataSourceInfo from quick_map_services.data_source_serializer import DataSourceSerializer ds = DataSourceInfo() ds.id = "my_custom_tms" ds.type = "TMS" ds.group = "custom" ds.alias = "My Custom Basemap" ds.tms_url = "https://tile.openstreetmap.org/{z}/{x}/{y}.png" ds.tms_zmin = 0 ds.tms_zmax = 19 ds.tms_epsg_crs_id = 3857 ds.copyright_text = "© OpenStreetMap contributors" ds.copyright_link = "https://www.openstreetmap.org/copyright" DataSourceSerializer.write_to_ini(ds, "/path/to/output/metadata.ini") # Resulting INI file: # [general] # id = my_custom_tms # type = TMS # [ui] # alias = My Custom Basemap # group = custom # [tms] # url = https://tile.openstreetmap.org/{z}/{x}/{y}.png # zmin = 0 # zmax = 19 # epsg_crs_id = 3857 ``` ``` -------------------------------- ### set_tile_layer_proj Source: https://context7.com/nextgis/quickmapservices/llms.txt Configures the coordinate reference system (CRS) for a QGIS tile layer using an EPSG code, PostGIS CRS ID, or PROJ string. ```APIDOC ## set_tile_layer_proj — Configure CRS for a Tile Layer Sets the coordinate reference system on a QGIS raster or vector tile layer based on an EPSG code, PostGIS CRS ID, or a custom PROJ string. Falls back to EPSG:3857 if no valid CRS is provided. Invalid CRS definitions trigger a QGIS warning message. ```python from quick_map_services.qgis_map_helpers import set_tile_layer_proj from qgis.core import QgsRasterLayer layer = QgsRasterLayer( "type=xyz&url=https://tile.openstreetmap.org/{z}/{x}/{y}.png", "OSM", "wms", ) ``` ``` -------------------------------- ### Manage Recently Used Services Cache Source: https://context7.com/nextgis/quickmapservices/llms.txt Utilizes CachedServices to persist and retrieve recently used geoservices across QGIS sessions. Supports adding, retrieving, and removing services. ```python from quick_map_services.qms_service_toolbox import CachedServices from qgis.PyQt.QtCore import QByteArray cache = CachedServices() # --- Add a service to the cache --- geoservice_attrs = { "id": 448, "name": "OpenStreetMap Standard", "type": "tms", } cache.add_service(geoservice_attrs, QByteArray()) # --- Retrieve cached services --- for attrs, image_ba in cache.get_cached_services(): print(attrs["name"]) # --- Remove a specific service from the cache --- cache.remove_service(service_id=448) ``` -------------------------------- ### DataSourceInfo Source: https://context7.com/nextgis/quickmapservices/llms.txt The central data model for representing a single geospatial service, supporting various types like TMS, WMS, WFS, GeoJSON, GDAL, and MVT. ```APIDOC ## DataSourceInfo — Service Configuration Model The central data model holding all properties for a single geospatial service. Supports TMS, WMS, WFS, GeoJSON, GDAL, and MVT service types. The `tms_url` setter automatically expands `{switch:a,b,c}` patterns into multiple alternative URLs for load-balanced tile servers. ```python from quick_map_services.data_source_info import DataSourceInfo # --- TMS with subdomain switching --- ds = DataSourceInfo() ds.type = "TMS" ds.tms_url = "https://{switch:a,b,c}.tile.openstreetmap.org/{z}/{x}/{y}.png" print(ds.alt_tms_urls) # ['https://a.tile.openstreetmap.org/{z}/{x}/{y}.png', # 'https://b.tile.openstreetmap.org/{z}/{x}/{y}.png', # 'https://c.tile.openstreetmap.org/{z}/{x}/{y}.png'] # --- MVT (Vector Tiles) --- mvt_ds = DataSourceInfo() mvt_ds.type = "MVT" mvt_ds.mvt_url = "https://example.com/tiles/{z}/{x}/{y}.pbf" mvt_ds.mvt_style_url = "https://example.com/style.json" mvt_ds.mvt_zmin = 0 mvt_ds.mvt_zmax = 14 # --- WFS --- wfs_ds = DataSourceInfo() wfs_ds.type = "WFS" wfs_ds.wfs_url = "https://example.com/wfs" wfs_ds.wfs_layers = ["roads", "buildings"] wfs_ds.wfs_epsg = 4326 ``` ``` -------------------------------- ### Set Tile Layer CRS by EPSG Code Source: https://context7.com/nextgis/quickmapservices/llms.txt Sets the Coordinate Reference System for a tile layer using its EPSG code. Ensure the layer object is already defined. ```python set_tile_layer_proj(layer, epsg_crs_id=3857) ``` -------------------------------- ### Configure CRS for Tile Layer in QGIS Source: https://context7.com/nextgis/quickmapservices/llms.txt Sets the coordinate reference system for a QGIS raster or tile layer using an EPSG code, PostGIS CRS ID, or PROJ string. Falls back to EPSG:3857 if the CRS is invalid. Invalid CRS definitions will trigger a QGIS warning. ```python from quick_map_services.qgis_map_helpers import set_tile_layer_proj from qgis.core import QgsRasterLayer layer = QgsRasterLayer( "type=xyz&url=https://tile.openstreetmap.org/{z}/{x}/{y}.png", "OSM", "wms", ) ``` -------------------------------- ### Add Geospatial Service Layer to QGIS Source: https://context7.com/nextgis/quickmapservices/llms.txt The primary function for adding any supported service type (TMS, WMS, WFS, GeoJSON, GDAL, MVT) as a QGIS map layer. It automatically sets CRS, copyright, and layer tree position. ```python from quick_map_services.qgis_map_helpers import add_layer_to_map from quick_map_services.data_source_serializer import DataSourceSerializer from quick_map_services.qms_external_api_python.client import Client ``` -------------------------------- ### add_layer_to_map Source: https://context7.com/nextgis/quickmapservices/llms.txt The primary function for adding any supported service type as a QGIS map layer. It handles various service types and automatically configures layer properties. ```APIDOC ## add_layer_to_map ### Description The primary function for adding any supported service type as a QGIS map layer. Handles TMS, WMS, WFS, GeoJSON, GDAL, and MVT layers. Automatically sets CRS, copyright attribution, and inserts the layer at the correct position in the layer tree (raster services go to the bottom; vector layers go to the top). ### Parameters This function accepts a `DataSourceSerializer` object or a dictionary representing the data source. The exact parameters depend on the type of service being added. ### Request Example ```python from quick_map_services.qgis_map_helpers import add_layer_to_map from quick_map_services.data_source_serializer import DataSourceSerializer from quick_map_services.qms_external_api_python.client import Client # Example usage would involve obtaining a DataSourceSerializer object # or a dictionary representing a service, likely from the ApiClientV1. # For instance: # client = Client() # service_info = client.get_geoservice_info(some_service_id) # data_source = DataSourceSerializer(service_info) # add_layer_to_map(data_source) ``` ### Response This function modifies the QGIS map canvas by adding a new layer. It does not explicitly return a value indicating success or failure in this documentation snippet, but it performs the action of adding a layer. ``` -------------------------------- ### Set Tile Layer CRS by PostGIS SRID Source: https://context7.com/nextgis/quickmapservices/llms.txt Sets the Coordinate Reference System for a tile layer using a PostGIS SRID. This method is convenient when working with PostGIS databases. ```python set_tile_layer_proj(layer, postgis_crs_id=900913) ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.