Skip to content

Commit

Permalink
do not show local mbtiles as not available offline (fix #540)
Browse files Browse the repository at this point in the history
  • Loading branch information
alexbruy committed Nov 7, 2023
1 parent ac56189 commit c99488e
Showing 1 changed file with 17 additions and 2 deletions.
19 changes: 17 additions & 2 deletions Mergin/validation.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,14 @@
from enum import Enum
from collections import defaultdict

from qgis.core import QgsMapLayerType, QgsProject, QgsVectorDataProvider, QgsExpression, QgsRenderContext
from qgis.core import (
QgsMapLayerType,
QgsProject,
QgsVectorDataProvider,
QgsExpression,
QgsRenderContext,
QgsProviderRegistry,
)

from .help import MerginHelp
from .utils import (
Expand Down Expand Up @@ -193,7 +200,15 @@ def check_offline(self):
# might be vector tiles - no provider name
continue
if dp_name in QGIS_NET_PROVIDERS + QGIS_DB_PROVIDERS:
w.items.append(layer.name())
# raster mbtiles are loaded using WMS provider, so we need to
# check whether this is a local file or remote service
if dp_name.lower() == "wms":
uri = QgsProviderRegistry.instance().decodeUri("wms", layer.source())
is_local = os.path.isfile(uri["path"]) if "path" in uri else False
if not is_local:
w.items.append(layer.name())
else:
w.items.append(layer.name())

if w.items:
self.issues.append(w)
Expand Down

0 comments on commit c99488e

Please sign in to comment.