Exemple #1
0
    def drawMeasureAreaOnVideo(values, painter, surface, gt):
        ''' Draw Measure Area on Video '''

        a_value = sphere.polygon_area([values])
        
        poly = []
        lat = []
        long = []
        for pt in values:
            if hasElevationModel():
                pt = GetLine3DIntersectionWithPlane(
                    GetSensor(), pt, GetFrameCenter()[2])
            scr_x, scr_y = vut.GetInverseMatrix(
                pt[1], pt[0], gt, surface)
            center = QPoint(scr_x, scr_y)
            poly.append(center)
            
            lat.append(pt[0])
            long.append(pt[1])

#         Fix: Temporary correction
#         mousePressEvent calls after mouseMoveEvent.
#         A problem occurs because the centroid is miscalculated.
#         We remove duplicates values
        lat = list(dict.fromkeys(lat))
        long = list(dict.fromkeys(long))

        # Calculate Centroid Position
        scr_x, scr_y = vut.GetInverseMatrix(
                sum(long)/len(long), sum(lat)/len(lat), gt, surface)
        
        centroid = QPoint(scr_x, scr_y)
        
        # Create Poligon
        polygon = QPolygonF(poly)
        
        path = QPainterPath()
        path.addPolygon(polygon)
        
        painter.setFont(DrawToolBar.bold_12)

        painter.setPen(MeasurePen)
        painter.drawPolygon(polygon)
        painter.fillPath(path, MeasureBrush)
        painter.setPen(DrawToolBar.white_pen)
        painter.drawPoints(polygon)
        
        # Area
        if a_value >= 10000:
            painter.drawText(centroid , str(round(a_value/1000000, 2)) + " km²")
        else:
            painter.drawText(centroid , str(round(a_value, 2)) + " m²")
        return
Exemple #2
0
    def drawMeasureAreaOnVideo(values, painter, surface, gt):
        ''' Draw Measure Area on Video '''
        a_value = sphere.polygon_area([values])

        poly = []
        lat = []
        long = []
        for pt in values:
            scr_x, scr_y = vut.GetInverseMatrix(pt[1], pt[0], gt, surface)
            center = QPoint(scr_x, scr_y)
            poly.append(center)

            lat.append(pt[0])
            long.append(pt[1])

        lat = list(dict.fromkeys(lat))
        long = list(dict.fromkeys(long))

        # Calculate Centroid Position
        scr_x, scr_y = vut.GetInverseMatrix(
            sum(long) / len(long),
            sum(lat) / len(lat), gt, surface)

        centroid = QPoint(scr_x, scr_y)

        # Create Poligon
        polygon = QPolygonF(poly)

        path = QPainterPath()
        path.addPolygon(polygon)

        painter.setFont(DrawToolBar.bold_12)

        painter.setPen(MeasurePen)
        painter.drawPolygon(polygon)
        painter.fillPath(path, MeasureBrush)
        painter.setPen(DrawToolBar.white_pen)
        painter.drawPoints(polygon)

        # Area
        if a_value >= 10000:
            painter.drawText(centroid,
                             str(round(a_value / 1000000, 2)) + " km²")
        else:
            painter.drawText(centroid, str(round(a_value, 2)) + " m²")
        return