Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

When filtering features by bounding box, insure bounding box CRS matches that of the layer #74

Merged
merged 1 commit into from
Mar 15, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading