# Path: lrs/lrs/utils.py
# def crsString(crs):
#     crs_string = crs.authid()
#     if not crs_string.lower().startswith('epsg'):
#         crs_string = 'internal:%s' % crs.srsid()
#     return crs_string
# 
# def isProjectCrsEnabled():
#     return QgsProject().instance().crs().isValid()
# 
# def getProjectCrs():
#     return QgsProject().instance().crs()


from PyQt5.QtCore import Qt
from qgis.core import QgsVectorLayer, QgsGeometry, QgsCoordinateTransform, QgsProject, QgsWkbTypes, QgsRectangle
from qgis.gui import QgsHighlight
from ..utils import crsString, isProjectCrsEnabled, getProjectCrs
            del self.errorHighlight

    def clearHighlight(self):
        if self.errorHighlight:
            del self.errorHighlight
            self.errorHighlight = None

    def highlight(self, error, crs):
        self.clearHighlight()
        if not error: return

        # QgsHighlight does reprojection from layer CRS
        layer = QgsVectorLayer('Point?crs=' + crsString(crs), 'LRS error highlight', 'memory')
        self.errorHighlight = QgsHighlight(self.mapCanvas, error.geo, layer)
        # highlight point size is hardcoded in QgsHighlight
        self.errorHighlight.setWidth(2)
        self.errorHighlight.setColor(Qt.yellow)
        self.errorHighlight.show()

    def zoom(self, error, crs):
        if not error: return
        geo = error.geo
        mapSettings = self.mapCanvas.mapSettings()
        if isProjectCrsEnabled() and getProjectCrs() != crs:
            geo = QgsGeometry(error.geo)
            transform = QgsCoordinateTransform(crs, QgsProject().instance().crs(), QgsProject.instance())
            geo.transform(transform)

        if geo.type() == QgsWkbTypes.PointGeometry:
            p = geo.asPoint()

# Path: lrs/lrs/utils.py
# def crsString(crs):
#     crs_string = crs.authid()
#     if not crs_string.lower().startswith('epsg'):
#         crs_string = 'internal:%s' % crs.srsid()
#     return crs_string
# 
# def isProjectCrsEnabled():
#     return QgsProject().instance().crs().isValid()
# 
# def getProjectCrs():
#     return QgsProject().instance().crs()


# Path: lrs/lrs/error/lrserrorvisualizer.py
from PyQt5.QtCore import Qt
from qgis.core import QgsVectorLayer, QgsGeometry, QgsCoordinateTransform, QgsProject, QgsWkbTypes, QgsRectangle
from qgis.gui import QgsHighlight
from ..utils import crsString, isProjectCrsEnabled, getProjectCrs

            del self.errorHighlight

    def clearHighlight(self):
        if self.errorHighlight:
            del self.errorHighlight
            self.errorHighlight = None

    def highlight(self, error, crs):
        self.clearHighlight()
        if not error: return

        # QgsHighlight does reprojection from layer CRS
        layer = QgsVectorLayer('Point?crs=' + crsString(crs), 'LRS error highlight', 'memory')
        self.errorHighlight = QgsHighlight(self.mapCanvas, error.geo, layer)
        # highlight point size is hardcoded in QgsHighlight
        self.errorHighlight.setWidth(2)
        self.errorHighlight.setColor(Qt.yellow)
        self.errorHighlight.show()

    def zoom(self, error, crs):
        if not error: return
        geo = error.geo
        mapSettings = self.mapCanvas.mapSettings()
        if isProjectCrsEnabled() and getProjectCrs() != crs:
            geo = QgsGeometry(error.geo)
            transform = QgsCoordinateTransform(crs, QgsProject().instance().crs(), QgsProject.instance())
            geo.transform(transform)

        if geo.type() == QgsWkbTypes.PointGeometry:
            p = geo.asPoint()

            bufferCrs = getProjectCrs() if isProjectCrsEnabled() else crs