Skip to content

Commit

Permalink
When filtering features by bounding box, insure bounding box CRS matc…
Browse files Browse the repository at this point in the history
…hes that of the layer
  • Loading branch information
nirvn committed Mar 15, 2024
1 parent 3b078e8 commit b6bb151
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion libqfieldsync/offliners.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ def convert_to_offline(
layers: List[QgsMapLayer],
bbox: Optional[QgsRectangle],
) -> bool:
project = QgsProject.instance()
offline_db_path = Path(offline_db_filename).parent
layer_ids = [layer.id() for layer in layers]

Expand All @@ -112,7 +113,9 @@ def convert_to_offline(
# ensure that geometry-less layers do not have selected features that would interfere with the process
layer.removeSelection()
else:
layer.selectByRect(bbox)
tr = QgsCoordinateTransform(project.crs(), layer.crs(), project)
layer_bbox = tr.transform(bbox)
layer.selectByRect(layer_bbox)

# If the selection by BBOX did not select anything, make sure we fool `QgsOfflineEditing` something is selected.
# Otherwise when `layer.selectedFeatureIds().isEmpty()`, `QgsOfflineEditing` dumps all features.
Expand Down

0 comments on commit b6bb151

Please sign in to comment.