Skip to content

Commit

Permalink
Fix exporting of geometry-less vector layers when offlining using are…
Browse files Browse the repository at this point in the history
…a of interest
  • Loading branch information
nirvn committed Oct 30, 2023
1 parent 313f1a5 commit c84ee2d
Showing 1 changed file with 17 additions and 9 deletions.
26 changes: 17 additions & 9 deletions offline_converter.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
from typing import Dict, List, Optional, Union

from qgis.core import (
Qgis,
QgsApplication,
QgsBilinearRasterResampler,
QgsCoordinateReferenceSystem,
Expand Down Expand Up @@ -253,15 +254,22 @@ def _convert(self, project: QgsProject) -> None:

if layer_action == SyncAction.OFFLINE:
if self.project_configuration.offline_copy_only_aoi:
extent = QgsCoordinateTransform(
QgsCoordinateReferenceSystem(self.area_of_interest_crs),
layer.crs(),
QgsProject.instance(),
).transformBoundingBox(self.area_of_interest.boundingBox())
layer.selectByRect(extent)

if not layer.selectedFeatureCount():
layer.selectByIds([FID_NULL])
if (
layer.geometryType() is not Qgis.GeometryType.Null
and layer.geometryType() is not Qgis.GeometryType.Unknown
):
extent = QgsCoordinateTransform(
QgsCoordinateReferenceSystem(self.area_of_interest_crs),
layer.crs(),
QgsProject.instance(),
).transformBoundingBox(self.area_of_interest.boundingBox())
layer.selectByRect(extent)

if not layer.selectedFeatureCount():
layer.selectByIds([FID_NULL])
else:
# insure that geometry-less layers do not have selected features that would interfere with the process
layer.removeSelection()

self.__offline_layers.append(layer)
self.__offline_layer_names.append(layer.name())
Expand Down

0 comments on commit c84ee2d

Please sign in to comment.