def CornerEstimationWithOffsets(packet): ''' Corner estimation using Offsets ''' try: OffsetLat1 = packet.OffsetCornerLatitudePoint1 OffsetLon1 = packet.OffsetCornerLongitudePoint1 OffsetLat2 = packet.OffsetCornerLatitudePoint2 OffsetLon2 = packet.OffsetCornerLongitudePoint2 OffsetLat3 = packet.OffsetCornerLatitudePoint3 OffsetLon3 = packet.OffsetCornerLongitudePoint3 OffsetLat4 = packet.OffsetCornerLatitudePoint4 OffsetLon4 = packet.OffsetCornerLongitudePoint4 frameCenterLat = packet.FrameCenterLatitude frameCenterLon = packet.FrameCenterLongitude # Lat,Lon cornerPointUL = (OffsetLat1 + frameCenterLat, OffsetLon1 + frameCenterLon) cornerPointUR = (OffsetLat2 + frameCenterLat, OffsetLon2 + frameCenterLon) cornerPointLR = (OffsetLat3 + frameCenterLat, OffsetLon3 + frameCenterLon) cornerPointLL = (OffsetLat4 + frameCenterLat, OffsetLon4 + frameCenterLon) if hasElevationModel(): pCornerPointUL = GetLine3DIntersectionWithDEM( GetSensor(), cornerPointUL) pCornerPointUR = GetLine3DIntersectionWithDEM( GetSensor(), cornerPointUR) pCornerPointLR = GetLine3DIntersectionWithDEM( GetSensor(), cornerPointLR) pCornerPointLL = GetLine3DIntersectionWithDEM( GetSensor(), cornerPointLL) UpdateFootPrintData(packet, pCornerPointUL, pCornerPointUR, pCornerPointLR, pCornerPointLL, hasElevationModel()) UpdateBeamsData(packet, pCornerPointUL, pCornerPointUR, pCornerPointLR, pCornerPointLL, hasElevationModel()) else: UpdateFootPrintData(packet, cornerPointUL, cornerPointUR, cornerPointLR, cornerPointLL, hasElevationModel()) UpdateBeamsData(packet, cornerPointUL, cornerPointUR, cornerPointLR, cornerPointLL, hasElevationModel()) SetGCPsToGeoTransform(cornerPointUL, cornerPointUR, cornerPointLR, cornerPointLL, frameCenterLon, frameCenterLat) except Exception: return False return True
def CornerEstimationWithoutOffsets(packet): ''' Corner estimation without Offsets ''' try: sensorLatitude = packet.SensorLatitude sensorLongitude = packet.SensorLongitude sensorTrueAltitude = packet.SensorTrueAltitude frameCenterLat = packet.FrameCenterLatitude frameCenterLon = packet.FrameCenterLongitude frameCenterElevation = packet.FrameCenterElevation sensorVerticalFOV = packet.SensorVerticalFieldOfView sensorHorizontalFOV = packet.SensorHorizontalFieldOfView headingAngle = packet.PlatformHeadingAngle sensorRelativeAzimut = packet.SensorRelativeAzimuthAngle targetWidth = packet.targetWidth slantRange = packet.SlantRange # If target width = 0 (occurs on some platforms), compute it with the slate range. # Otherwise it leaves the footprint as a point. # In some case targetWidth don't have value then equal to 0 if targetWidth is None: targetWidth = 0 if targetWidth == 0 and slantRange != 0: targetWidth = 2.0 * slantRange * \ tan(radians(sensorHorizontalFOV / 2.0)) elif targetWidth == 0 and slantRange == 0: # default target width to not leave footprint as a point. targetWidth = defaultTargetWidth qgsu.showUserAndLogMessage( QCoreApplication.translate( "QgsFmvUtils", "Target width unknown, defaults to: " + str(targetWidth) + "m.")) # compute distance to ground if frameCenterElevation != 0: sensorGroundAltitude = sensorTrueAltitude - frameCenterElevation else: qgsu.showUserAndLogMessage( QCoreApplication.translate( "QgsFmvUtils", "Sensor ground elevation narrowed to true altitude: " + str(sensorTrueAltitude) + "m.")) sensorGroundAltitude = sensorTrueAltitude if sensorLatitude == 0: return False if sensorLongitude is None or sensorLatitude is None: return False initialPoint = (sensorLongitude, sensorLatitude) if frameCenterLon is None or frameCenterLat is None: return False destPoint = (frameCenterLon, frameCenterLat) distance = sphere.distance(initialPoint, destPoint) if distance == 0: return False if sensorVerticalFOV > 0 and sensorHorizontalFOV > sensorVerticalFOV: aspectRatio = sensorVerticalFOV / sensorHorizontalFOV else: aspectRatio = 0.75 value2 = (headingAngle + sensorRelativeAzimut) % 360.0 # Heading value3 = targetWidth / 2.0 value5 = sqrt(pow(distance, 2.0) + pow(sensorGroundAltitude, 2.0)) value6 = targetWidth * aspectRatio / 2.0 degrees = rad2deg(atan(value3 / distance)) value8 = rad2deg(atan(distance / sensorGroundAltitude)) value9 = rad2deg(atan(value6 / value5)) value10 = value8 + value9 value11 = sensorGroundAltitude * tan(radians(value10)) value12 = value8 - value9 value13 = sensorGroundAltitude * tan(radians(value12)) value14 = distance - value13 value15 = value11 - distance value16 = value3 - value14 * tan(radians(degrees)) value17 = value3 + value15 * tan(radians(degrees)) distance2 = sqrt(pow(value14, 2.0) + pow(value16, 2.0)) value19 = sqrt(pow(value15, 2.0) + pow(value17, 2.0)) value20 = rad2deg(atan(value16 / value14)) value21 = rad2deg(atan(value17 / value15)) # CP Up Left bearing = (value2 + 360.0 - value21) % 360.0 cornerPointUL = list( reversed(sphere.destination(destPoint, value19, bearing))) # CP Up Right bearing = (value2 + value21) % 360.0 cornerPointUR = list( reversed(sphere.destination(destPoint, value19, bearing))) # CP Low Right bearing = (value2 + 180.0 - value20) % 360.0 cornerPointLR = list( reversed(sphere.destination(destPoint, distance2, bearing))) # CP Low Left bearing = (value2 + 180.0 + value20) % 360.0 cornerPointLL = list( reversed(sphere.destination(destPoint, distance2, bearing))) if hasElevationModel(): pCornerPointUL = GetLine3DIntersectionWithDEM( GetSensor(), cornerPointUL) pCornerPointUR = GetLine3DIntersectionWithDEM( GetSensor(), cornerPointUR) pCornerPointLR = GetLine3DIntersectionWithDEM( GetSensor(), cornerPointLR) pCornerPointLL = GetLine3DIntersectionWithDEM( GetSensor(), cornerPointLL) UpdateFootPrintData(packet, pCornerPointUL, pCornerPointUR, pCornerPointLR, pCornerPointLL, hasElevationModel()) UpdateBeamsData(packet, pCornerPointUL, pCornerPointUR, pCornerPointLR, pCornerPointLL, hasElevationModel()) else: UpdateFootPrintData(packet, cornerPointUL, cornerPointUR, cornerPointLR, cornerPointLL, hasElevationModel()) UpdateBeamsData(packet, cornerPointUL, cornerPointUR, cornerPointLR, cornerPointLL, hasElevationModel()) SetGCPsToGeoTransform(cornerPointUL, cornerPointUR, cornerPointLR, cornerPointLL, frameCenterLon, frameCenterLat) except Exception as e: qgsu.showUserAndLogMessage( QCoreApplication.translate( "QgsFmvUtils", "CornerEstimationWithoutOffsets failed! : "), str(e)) return False return True
def UpdateLayers(packet, parent=None, mosaic=False): ''' Update Layers Values ''' global frameCenterElevation, sensorLatitude, sensorLongitude, sensorTrueAltitude frameCenterLat = packet.FrameCenterLatitude frameCenterLon = packet.FrameCenterLongitude frameCenterElevation = packet.FrameCenterElevation sensorLatitude = packet.SensorLatitude sensorLongitude = packet.SensorLongitude sensorTrueAltitude = packet.SensorTrueAltitude OffsetLat1 = packet.OffsetCornerLatitudePoint1 LatitudePoint1Full = packet.CornerLatitudePoint1Full UpdatePlatformData(packet, hasElevationModel()) UpdateTrajectoryData(packet, hasElevationModel()) UpdateFrameCenterData(packet, hasElevationModel()) UpdateFrameAxisData(packet, hasElevationModel()) if OffsetLat1 is not None and LatitudePoint1Full is None: CornerEstimationWithOffsets(packet) if mosaic: georeferencingVideo(parent) elif OffsetLat1 is None and LatitudePoint1Full is None: CornerEstimationWithoutOffsets(packet) if mosaic: georeferencingVideo(parent) else: cornerPointUL = [ packet.CornerLatitudePoint1Full, packet.CornerLongitudePoint1Full ] if None in cornerPointUL: return cornerPointUR = [ packet.CornerLatitudePoint2Full, packet.CornerLongitudePoint2Full ] if None in cornerPointUR: return cornerPointLR = [ packet.CornerLatitudePoint3Full, packet.CornerLongitudePoint3Full ] if None in cornerPointLR: return cornerPointLL = [ packet.CornerLatitudePoint4Full, packet.CornerLongitudePoint4Full ] if None in cornerPointLL: return UpdateFootPrintData(packet, cornerPointUL, cornerPointUR, cornerPointLR, cornerPointLL, hasElevationModel()) UpdateBeamsData(packet, cornerPointUL, cornerPointUR, cornerPointLR, cornerPointLL, hasElevationModel()) SetGCPsToGeoTransform(cornerPointUL, cornerPointUR, cornerPointLR, cornerPointLL, frameCenterLon, frameCenterLat) if mosaic: georeferencingVideo(parent) # recenter map on platform if centerMode == 1: lyr = qgsu.selectLayerByName(Platform_lyr) iface.mapCanvas().setExtent(lyr.extent()) # recenter map on footprint elif centerMode == 2: lyr = qgsu.selectLayerByName(Footprint_lyr) iface.mapCanvas().setExtent(lyr.extent()) # recenter map on target elif centerMode == 3: lyr = qgsu.selectLayerByName(FrameCenter_lyr) iface.mapCanvas().setExtent(lyr.extent()) iface.mapCanvas().refresh() return
def UpdateLayers(packet, parent=None, mosaic=False): ''' Update Layers Values ''' global frameCenterElevation global sensorLatitude global sensorLongitude global sensorTrueAltitude frameCenterLat = packet.GetFrameCenterLatitude() frameCenterLon = packet.GetFrameCenterLongitude() frameCenterElevation = packet.GetFrameCenterElevation() sensorLatitude = packet.GetSensorLatitude() sensorLongitude = packet.GetSensorLongitude() sensorTrueAltitude = packet.GetSensorTrueAltitude() UpdatePlatformData(packet) UpdateTrajectoryData(packet) UpdateFrameCenterData(packet) OffsetLat1 = packet.GetOffsetCornerLatitudePoint1() LatitudePoint1Full = packet.GetCornerLatitudePoint1Full() if OffsetLat1 is not None and LatitudePoint1Full is None: CornerEstimationWithOffsets(packet) if mosaic: georeferencingVideo(parent) return if OffsetLat1 is None and LatitudePoint1Full is None: CornerEstimationWithoutOffsets(packet) if mosaic: georeferencingVideo(parent) return cornerPointUL = [ packet.GetCornerLatitudePoint1Full(), packet.GetCornerLongitudePoint1Full() ] if None in cornerPointUL: return cornerPointUR = [ packet.GetCornerLatitudePoint2Full(), packet.GetCornerLongitudePoint2Full() ] if None in cornerPointUR: return cornerPointLR = [ packet.GetCornerLatitudePoint3Full(), packet.GetCornerLongitudePoint3Full() ] if None in cornerPointLR: return cornerPointLL = [ packet.GetCornerLatitudePoint4Full(), packet.GetCornerLongitudePoint4Full() ] if None in cornerPointLL: return UpdateFootPrintData(packet, cornerPointUL, cornerPointUR, cornerPointLR, cornerPointLL) UpdateBeamsData(packet, cornerPointUL, cornerPointUR, cornerPointLR, cornerPointLL) SetGCPsToGeoTransform(cornerPointUL, cornerPointUR, cornerPointLR, cornerPointLL, frameCenterLon, frameCenterLat) if mosaic: georeferencingVideo(parent) return
def CornerEstimationWithOffsets(packet): ''' Corner estimation using Offsets :param packet: Metada packet ''' try: OffsetLat1 = packet.OffsetCornerLatitudePoint1 OffsetLon1 = packet.OffsetCornerLongitudePoint1 OffsetLat2 = packet.OffsetCornerLatitudePoint2 OffsetLon2 = packet.OffsetCornerLongitudePoint2 OffsetLat3 = packet.OffsetCornerLatitudePoint3 OffsetLon3 = packet.OffsetCornerLongitudePoint3 OffsetLat4 = packet.OffsetCornerLatitudePoint4 OffsetLon4 = packet.OffsetCornerLongitudePoint4 frameCenterLat = packet.FrameCenterLatitude frameCenterLon = packet.FrameCenterLongitude # Lat,Lon cornerPointUL = (OffsetLat1 + frameCenterLat, OffsetLon1 + frameCenterLon) cornerPointUR = (OffsetLat2 + frameCenterLat, OffsetLon2 + frameCenterLon) cornerPointLR = (OffsetLat3 + frameCenterLat, OffsetLon3 + frameCenterLon) cornerPointLL = (OffsetLat4 + frameCenterLat, OffsetLon4 + frameCenterLon) frameCenterPoint = [ packet.FrameCenterLatitude, packet.FrameCenterLongitude, packet.FrameCenterElevation ] # If no framcenter (f.i. horizontal target) don't comptute footprint, # beams and frame center if (frameCenterPoint[0] is None and frameCenterPoint[1] is None): gv.setTransform(None) return True if hasElevationModel(): cornerPointUL = GetLine3DIntersectionWithDEM( GetSensor(), cornerPointUL) cornerPointUR = GetLine3DIntersectionWithDEM( GetSensor(), cornerPointUR) cornerPointLR = GetLine3DIntersectionWithDEM( GetSensor(), cornerPointLR) cornerPointLL = GetLine3DIntersectionWithDEM( GetSensor(), cornerPointLL) frameCenterPoint = GetLine3DIntersectionWithDEM( GetSensor(), frameCenterPoint) UpdateFootPrintData(packet, cornerPointUL, cornerPointUR, cornerPointLR, cornerPointLL, hasElevationModel()) UpdateBeamsData(packet, cornerPointUL, cornerPointUR, cornerPointLR, cornerPointLL, hasElevationModel()) SetGCPsToGeoTransform(cornerPointUL, cornerPointUR, cornerPointLR, cornerPointLL, frameCenterPoint[1], frameCenterPoint[0], hasElevationModel()) except Exception: return False return True
def UpdateLayers(packet, parent=None, mosaic=False, group=None): ''' Update Layers Values ''' gv.setGroupName(group) groupName = group # frameCenterLat = packet.FrameCenterLatitude # frameCenterLon = packet.FrameCenterLongitude gv.setFrameCenterElevation(packet.FrameCenterElevation) gv.setSensorLatitude(packet.SensorLatitude) gv.setSensorLongitude(packet.SensorLongitude) sensorTrueAltitude = packet.SensorTrueAltitude gv.setSensorTrueAltitude(sensorTrueAltitude) sensorRelativeElevationAngle = packet.SensorRelativeElevationAngle slantRange = packet.SlantRange OffsetLat1 = packet.OffsetCornerLatitudePoint1 LatitudePoint1Full = packet.CornerLatitudePoint1Full UpdatePlatformData(packet, hasElevationModel()) UpdateTrajectoryData(packet, hasElevationModel()) frameCenterPoint = [ packet.FrameCenterLatitude, packet.FrameCenterLongitude, packet.FrameCenterElevation ] # If no framcenter (f.i. horizontal target) don't comptute footprint, # beams and frame center if (frameCenterPoint[0] is None and frameCenterPoint[1] is None): gv.setTransform(None) return True # No framecenter altitude if (frameCenterPoint[2] is None): if (sensorRelativeElevationAngle is not None and slantRange is not None): frameCenterPoint[2] = sensorTrueAltitude - \ sin(sensorRelativeElevationAngle) * slantRange else: frameCenterPoint[2] = 0.0 # qgsu.showUserAndLogMessage("", "FC Alt:"+str(frameCenterPoint[2]), onlyLog=True) if OffsetLat1 is not None and LatitudePoint1Full is None: if hasElevationModel(): frameCenterPoint = GetLine3DIntersectionWithDEM( GetSensor(), frameCenterPoint) CornerEstimationWithOffsets(packet) if mosaic: georeferencingVideo(parent) elif OffsetLat1 is None and LatitudePoint1Full is None: if hasElevationModel(): frameCenterPoint = GetLine3DIntersectionWithDEM( GetSensor(), frameCenterPoint) CornerEstimationWithoutOffsets(packet) if mosaic: georeferencingVideo(parent) else: cornerPointUL = [ packet.CornerLatitudePoint1Full, packet.CornerLongitudePoint1Full ] if None in cornerPointUL: return False cornerPointUR = [ packet.CornerLatitudePoint2Full, packet.CornerLongitudePoint2Full ] if None in cornerPointUR: return False cornerPointLR = [ packet.CornerLatitudePoint3Full, packet.CornerLongitudePoint3Full ] if None in cornerPointLR: return False cornerPointLL = [ packet.CornerLatitudePoint4Full, packet.CornerLongitudePoint4Full ] if None in cornerPointLL: return False UpdateFootPrintData(packet, cornerPointUL, cornerPointUR, cornerPointLR, cornerPointLL, hasElevationModel()) UpdateBeamsData(packet, cornerPointUL, cornerPointUR, cornerPointLR, cornerPointLL, hasElevationModel()) SetGCPsToGeoTransform(cornerPointUL, cornerPointUR, cornerPointLR, cornerPointLL, frameCenterPoint[1], frameCenterPoint[0], hasElevationModel()) if mosaic: georeferencingVideo(parent) UpdateFrameCenterData(frameCenterPoint, hasElevationModel()) UpdateFrameAxisData(packet.ImageSourceSensor, GetSensor(), frameCenterPoint, hasElevationModel()) # detect if we need a recenter or not. If Footprint and Platform fits in # 80% of the map, do not trigger recenter. f_lyr = qgsu.selectLayerByName(Footprint_lyr, groupName) p_lyr = qgsu.selectLayerByName(Platform_lyr, groupName) t_lyr = qgsu.selectLayerByName(FrameCenter_lyr, groupName) iface = gv.getIface() centerMode = gv.getCenterMode() if f_lyr is not None and p_lyr is not None and t_lyr is not None: f_lyr_out_extent = f_lyr.extent() p_lyr_out_extent = p_lyr.extent() t_lyr_out_extent = t_lyr.extent() # Default EPSG is 4326, f_lyr.crs().authid () # Disable transform if we have the same projection wit layers anf # canvas epsg4326 = "EPSG:4326" curAuthId = iface.mapCanvas().mapSettings().destinationCrs().authid() if (curAuthId != epsg4326): xform = QgsCoordinateTransform( QgsCoordinateReferenceSystem(epsg4326), QgsCoordinateReferenceSystem(curAuthId), QgsProject().instance()) transP = xform.transform( QgsPointXY( list(p_lyr.getFeatures())[0].geometry().asPoint().x(), list(p_lyr.getFeatures())[0].geometry().asPoint().y())) transT = xform.transform( QgsPointXY( list(t_lyr.getFeatures())[0].geometry().asPoint().x(), list(t_lyr.getFeatures())[0].geometry().asPoint().y())) rect = list(f_lyr.getFeatures())[0].geometry().boundingBox() rectLL = xform.transform( QgsPointXY(rect.xMinimum(), rect.yMinimum())) rectUR = xform.transform( QgsPointXY(rect.xMaximum(), rect.yMaximum())) f_lyr_out_extent = QgsRectangle(rectLL, rectUR) t_lyr_out_extent = QgsRectangle(transT.x(), transT.y(), transT.x(), transT.y()) p_lyr_out_extent = QgsRectangle(transP.x(), transP.y(), transP.x(), transP.y()) bValue = iface.mapCanvas().extent().xMaximum() - iface.mapCanvas( ).center().x() # create a detection buffer map_detec_buffer = iface.mapCanvas().extent().buffered(bValue * -0.7) # recenter map on platform if not map_detec_buffer.contains(p_lyr_out_extent) and centerMode == 1: # recenter map on platform iface.mapCanvas().setExtent(p_lyr_out_extent) # recenter map on footprint elif not map_detec_buffer.contains( f_lyr_out_extent) and centerMode == 2: # zoom a bit wider than the footprint itself iface.mapCanvas().setExtent( f_lyr_out_extent.buffered(f_lyr_out_extent.width() * 0.5)) # recenter map on target elif not map_detec_buffer.contains( t_lyr_out_extent) and centerMode == 3: iface.mapCanvas().setExtent(t_lyr_out_extent) # Refresh Canvas iface.mapCanvas().refresh() return True
def CornerEstimationWithoutOffsets(packet=None, sensor=None, frameCenter=None, FOV=None, others=None): """ Corner estimation without Offsets """ try: if packet is not None: sensorLatitude = packet.SensorLatitude sensorLongitude = packet.SensorLongitude sensorTrueAltitude = packet.SensorTrueAltitude frameCenterLat = packet.FrameCenterLatitude frameCenterLon = packet.FrameCenterLongitude frameCenterElevation = packet.FrameCenterElevation sensorVerticalFOV = packet.SensorVerticalFieldOfView sensorHorizontalFOV = packet.SensorHorizontalFieldOfView headingAngle = packet.PlatformHeadingAngle sensorRelativeAzimut = packet.SensorRelativeAzimuthAngle targetWidth = packet.targetWidth slantRange = packet.SlantRange else: sensorLatitude = sensor[1] sensorLongitude = sensor[0] sensorTrueAltitude = sensor[2] frameCenterLat = frameCenter[1] frameCenterLon = frameCenter[0] frameCenterElevation = frameCenter[2] sensorVerticalFOV = FOV[0] sensorHorizontalFOV = FOV[1] headingAngle = others[0] sensorRelativeAzimut = others[1] targetWidth = others[2] slantRange = others[3] # If target width = 0 (occurs on some platforms), compute it with the slate range. # Otherwise it leaves the footprint as a point. # In some case targetWidth don't have value then equal to 0 if targetWidth is None: targetWidth = 0 if slantRange is None: slantRange = 0 if targetWidth == 0 and slantRange != 0: targetWidth = 2.0 * slantRange * tan( radians(sensorHorizontalFOV / 2.0)) elif targetWidth == 0 and slantRange == 0: # default target width to not leave footprint as a point. targetWidth = defaultTargetWidth # qgsu.showUserAndLogMessage(QCoreApplication.translate( # "QgsFmvUtils", "Target width unknown, defaults to: " + str(targetWidth) + "m.")) # compute distance to ground if (frameCenterElevation != 0 and sensorTrueAltitude is not None and frameCenterElevation is not None): sensorGroundAltitude = sensorTrueAltitude - frameCenterElevation elif frameCenterElevation == 0 and sensorTrueAltitude is not None: sensorGroundAltitude = sensorTrueAltitude else: # can't compute footprint without sensorGroundAltitude return False if sensorLatitude == 0: return False if sensorLongitude is None or sensorLatitude is None: return False if frameCenterLon is None or frameCenterLat is None: return False initialPoint = QgsPointXY(sensorLongitude, sensorLatitude) destPoint = QgsPointXY(frameCenterLon, frameCenterLat) da = QgsDistanceArea() da.setEllipsoid(WGS84String) distance = da.measureLine(initialPoint, destPoint) if distance == 0: return False if sensorVerticalFOV > 0 and sensorHorizontalFOV > sensorVerticalFOV: aspectRatio = sensorVerticalFOV / sensorHorizontalFOV else: aspectRatio = 0.75 value2 = (headingAngle + sensorRelativeAzimut) % 360.0 # Heading value3 = targetWidth / 2.0 value5 = sqrt(pow(distance, 2.0) + pow(sensorGroundAltitude, 2.0)) value6 = targetWidth * aspectRatio / 2.0 degrees_value = degrees(atan(value3 / distance)) value8 = degrees(atan(distance / sensorGroundAltitude)) value9 = degrees(atan(value6 / value5)) value10 = value8 + value9 value11 = sensorGroundAltitude * tan(radians(value10)) value12 = value8 - value9 value13 = sensorGroundAltitude * tan(radians(value12)) value14 = distance - value13 value15 = value11 - distance value16 = value3 - value14 * tan(radians(degrees_value)) value17 = value3 + value15 * tan(radians(degrees_value)) distance2 = sqrt(pow(value14, 2.0) + pow(value16, 2.0)) value19 = sqrt(pow(value15, 2.0) + pow(value17, 2.0)) value20 = degrees(atan(value16 / value14)) value21 = degrees(atan(value17 / value15)) # CP Up Left bearing = (value2 + 360.0 - value21) % 360.0 cornerPointUL = list( reversed(QgsGeoUtils.destination(destPoint, value19, bearing))) # CP Up Right bearing = (value2 + value21) % 360.0 cornerPointUR = list( reversed(QgsGeoUtils.destination(destPoint, value19, bearing))) # CP Low Right bearing = (value2 + 180.0 - value20) % 360.0 cornerPointLR = list( reversed(QgsGeoUtils.destination(destPoint, distance2, bearing))) # CP Low Left bearing = (value2 + 180.0 + value20) % 360.0 cornerPointLL = list( reversed(QgsGeoUtils.destination(destPoint, distance2, bearing))) frameCenterPoint = [ frameCenterLat, frameCenterLon, frameCenterElevation ] # If no frame center (f.i. horizontal target) don't compute footprint, # beams and frame center if frameCenterPoint[0] is None and frameCenterPoint[1] is None: gv.setTransform(None) return True if hasElevationModel(): cornerPointUL = GetLine3DIntersectionWithDEM( GetSensor(), cornerPointUL) cornerPointUR = GetLine3DIntersectionWithDEM( GetSensor(), cornerPointUR) cornerPointLR = GetLine3DIntersectionWithDEM( GetSensor(), cornerPointLR) cornerPointLL = GetLine3DIntersectionWithDEM( GetSensor(), cornerPointLL) frameCenterPoint = GetLine3DIntersectionWithDEM( GetSensor(), frameCenterPoint) if sensor is not None: return cornerPointUL, cornerPointUR, cornerPointLR, cornerPointLL UpdateFootPrintData( packet, cornerPointUL, cornerPointUR, cornerPointLR, cornerPointLL, hasElevationModel(), ) UpdateBeamsData( packet, cornerPointUL, cornerPointUR, cornerPointLR, cornerPointLL, hasElevationModel(), ) SetGCPsToGeoTransform( cornerPointUL, cornerPointUR, cornerPointLR, cornerPointLL, frameCenterPoint[1], frameCenterPoint[0], hasElevationModel(), ) except Exception as e: qgsu.showUserAndLogMessage( QCoreApplication.translate( "QgsFmvUtils", "CornerEstimationWithoutOffsets failed! : "), str(e), ) return False return True