Skip to content

Commit

Permalink
Removed unused code
Browse files Browse the repository at this point in the history
  • Loading branch information
benvanbasten-ns committed Sep 22, 2023
1 parent 5edc1d9 commit 24887fd
Showing 1 changed file with 0 additions and 29 deletions.
29 changes: 0 additions & 29 deletions utils/geo_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,6 @@
from qgis.core import QgsCoordinateReferenceSystem
from qgis.core import QgsCoordinateTransform
from qgis.core import QgsProject
from qgis.core import QgsVectorLayer
from qgis.core import QgsField
from qgis.core import QgsWkbTypes


def get_coord_transformation_instance(src_epsg, dest_epsg):
Expand All @@ -16,29 +13,3 @@ def get_coord_transformation_instance(src_epsg, dest_epsg):
src_crs = QgsCoordinateReferenceSystem(int(src_epsg))
dest_crs = QgsCoordinateReferenceSystem(int(dest_epsg))
return QgsCoordinateTransform(src_crs, dest_crs, QgsProject.instance())


def copy_vectorlayer_attributes(source_layer: QgsVectorLayer, layer_name: str, additional_attributes) -> QgsVectorLayer:
"""
Create a new QgsVectorLayer containing the attributes of the base_layer plus the list
of additional attributes.
"""
source_provider = source_layer.dataProvider()

uri = "{0}?crs=EPSG:{1}".format(
QgsWkbTypes.displayString(source_provider.wkbType()).lstrip("WKB"),
str(source_provider.crs().postgisSrid()),
)

dest_layer = QgsVectorLayer(uri, layer_name, "memory")
dest_provider = dest_layer.dataProvider()
dest_provider.addAttributes(source_provider.fields())

new_attributes = []
for name, type in additional_attributes.items():
new_attributes.append(QgsField(name, type))

dest_provider.addAttributes(new_attributes)
dest_layer.updateFields()

return dest_layer

0 comments on commit 24887fd

Please sign in to comment.