|
28 | 28 | from qgis.core import ( |
29 | 29 | Qgis, |
30 | 30 | QgsApplication, |
31 | | - QgsBilinearRasterResampler, |
32 | 31 | QgsCoordinateReferenceSystem, |
33 | 32 | QgsCoordinateTransform, |
34 | | - QgsCubicRasterResampler, |
35 | 33 | QgsEditorWidgetSetup, |
36 | 34 | QgsField, |
37 | 35 | QgsFields, |
@@ -564,69 +562,6 @@ def _export_basemap(self) -> bool: |
564 | 562 |
|
565 | 563 | return exported_mbtiles |
566 | 564 |
|
567 | | - def _export_basemap_as_tiff( |
568 | | - self, extent: QgsRectangle, base_map_type: ProjectProperties.BaseMapType |
569 | | - ) -> bool: |
570 | | - """ |
571 | | - Exports a basemap to TIFF format. |
572 | | - This method does not handle several zoom levels. |
573 | | - This should not be used, actually. |
574 | | -
|
575 | | - Args: |
576 | | - extent (QgsRectangle): extent of the area of interest |
577 | | - base_map_type (ProjectProperties.BaseMapType): basemap type (layer or theme) |
578 | | -
|
579 | | - Returns: |
580 | | - bool: if basemap layer could be exported as tiff |
581 | | - """ |
582 | | - extent_string = "{},{},{},{}".format( |
583 | | - extent.xMinimum(), |
584 | | - extent.xMaximum(), |
585 | | - extent.yMinimum(), |
586 | | - extent.yMaximum(), |
587 | | - ) |
588 | | - |
589 | | - alg = ( |
590 | | - QgsApplication.instance() |
591 | | - .processingRegistry() |
592 | | - .createAlgorithmById("native:rasterize") |
593 | | - ) |
594 | | - |
595 | | - params = { |
596 | | - "EXTENT": extent_string, |
597 | | - "EXTENT_BUFFER": 0, |
598 | | - "TILE_SIZE": self.project_configuration.base_map_tile_size, |
599 | | - "MAP_UNITS_PER_PIXEL": self.project_configuration.base_map_mupp, |
600 | | - "MAKE_BACKGROUND_TRANSPARENT": False, |
601 | | - "OUTPUT": str(self._export_filename.with_name("basemap.gpkg")), |
602 | | - } |
603 | | - |
604 | | - if base_map_type == ProjectProperties.BaseMapType.SINGLE_LAYER: |
605 | | - params["LAYERS"] = [self.project_configuration.base_map_layer] |
606 | | - elif base_map_type == ProjectProperties.BaseMapType.MAP_THEME: |
607 | | - params["MAP_THEME"] = self.project_configuration.base_map_theme |
608 | | - |
609 | | - feedback = QgsProcessingFeedback() |
610 | | - context = QgsProcessingContext() |
611 | | - context.setProject(QgsProject.instance()) |
612 | | - |
613 | | - results, ok = alg.run(params, context, feedback) |
614 | | - |
615 | | - if not ok: |
616 | | - self.warning.emit(self.tr("Failed to create basemap"), feedback.textLog()) |
617 | | - return False |
618 | | - |
619 | | - new_layer = QgsRasterLayer(results["OUTPUT"], self.tr("Basemap")) |
620 | | - |
621 | | - resample_filter = new_layer.resampleFilter() |
622 | | - resample_filter.setZoomedInResampler(QgsCubicRasterResampler()) |
623 | | - resample_filter.setZoomedOutResampler(QgsBilinearRasterResampler()) |
624 | | - self.project_configuration.project.addMapLayer(new_layer, False) |
625 | | - layer_tree = QgsProject.instance().layerTreeRoot() |
626 | | - layer_tree.insertLayer(len(layer_tree.children()), new_layer) |
627 | | - |
628 | | - return True |
629 | | - |
630 | 565 | def _export_basemap_as_mbtiles( |
631 | 566 | self, extent: QgsRectangle, base_map_type: ProjectProperties.BaseMapType |
632 | 567 | ) -> bool: |
|
0 commit comments