Esempio n. 1
0
    def calculateTraverse(self, traverse, x1, y1, x2, y2, adjust, addLine):

        # Azimuth Startingpoint to Endpoint
        referenceAzimuth = cadutils.azimuth(QgsPoint(x1, y1), QgsPoint(x2, y2))

        # Create the line in a local coordinatesystem:
        # - origin is the starting point
        # - azimuth is 0

        line = OrthogonalTraverse.traverse(traverse, 0, 1)
        if line == None:
            print "Line is None!"
        else:
            points = line.asPolyline()

            # Azimuth of the new line (first to last point of the line)
            actualAzimuth = cadutils.azimuth(points[0], points[-1])

            # Difference of reference distance and actual distance
            diff = 100 * (cadutils.distance(QgsPoint(x1, y1), QgsPoint(x2, y2))
                          - cadutils.distance(points[0], points[-1]))

            # number of characters to show as "Fs"
            if diff > 10:
                digit = math.ceil(math.log10(abs(diff)))
            else:
                digit = 1
            digit += 3
            if diff < 0:
                digit += 1

            # update the difference ("Fs") text in the GUI
            self.ctrl.lineEditFs.setText(
                str(diff)[:int(digit)] + str(" [cm]"))

            # If the OK button was clicked we will rotate and if desired scale/adjust
            # the line and add it to the map canvas.
            if addLine == True:
                rotationAngle = actualAzimuth - referenceAzimuth
                scale = cadutils.distance(QgsPoint(x1, y1), QgsPoint(
                    x2, y2)) / cadutils.distance(points[0], points[-1])

                print str("scale ") + str(scale)

                if adjust == True:
                    lineTransformed = cadutils.helmert2d(
                        line, x1, y1, rotationAngle, scale)
                else:
                    lineTransformed = cadutils.helmert2d(
                        line, x1, y1, rotationAngle, 1.0)

                if lineTransformed <> None:
                    cadutils.addGeometryToCadLayer(lineTransformed)
                    self.canvas.refresh()
                else:
                    QMessageBox.information(
                        None, QCoreApplication.translate("ctools", "Warning"),
                        QCoreApplication.translate(
                            "ctools", "Error while transforming geometry."))
        def calculateTraverse(self, traverse, x1, y1, x2, y2, adjust, addLine):
            
            # Azimuth Startingpoint to Endpoint
            referenceAzimuth = cadutils.azimuth(QgsPoint(x1,y1), QgsPoint(x2,y2))
            
            # Create the line in a local coordinatesystem:
            # - origin is the starting point
            # - azimuth is 0
            
            line = OrthogonalTraverse.traverse(traverse, 0, 1)
            if line == None:
                print "Line is None!"
            else:
                points = line.asPolyline()
                
                # Azimuth of the new line (first to last point of the line)
                actualAzimuth = cadutils.azimuth( points[0], points[-1] )

                # Difference of reference distance and actual distance
                diff = 100* (cadutils.distance(QgsPoint(x1,y1), QgsPoint(x2,y2)) - cadutils.distance(points[0], points[-1]))
                      
                # number of characters to show as "Fs"
                if diff > 10:
                    digit = math.ceil(math.log10(abs(diff)))
                else:
                    digit = 1
                digit += 3
                if diff < 0:
                    digit += 1
                                        
                # update the difference ("Fs") text in the GUI
                self.ctrl.lineEditFs.setText(str(diff)[:int(digit)] + str( " [cm]"));
                
                # If the OK button was clicked we will rotate and if desired scale/adjust 
                # the line and add it to the map canvas.
                if addLine == True:
                    rotationAngle = actualAzimuth - referenceAzimuth
                    scale = cadutils.distance(QgsPoint(x1,y1), QgsPoint(x2,y2)) / cadutils.distance(points[0], points[-1])
                    
                    print str("scale ") + str(scale)
                    
                    if adjust == True:
                        lineTransformed = cadutils.helmert2d(line, x1, y1, rotationAngle, scale)
                    else:
                        lineTransformed = cadutils.helmert2d(line, x1, y1, rotationAngle, 1.0)
                    
                    if lineTransformed <> None:
                        cadutils.addGeometryToCadLayer(lineTransformed)
                        self.canvas.refresh()
                    else:
                        QMessageBox.information(None,  "Warning", "Error while transforming geometry.")
Esempio n. 3
0
    def traverse(trv, azth, scale):
        ##        print "OrthogonalTraverse.traverse"
        ##        print trv
        meas = str(trv).split()

        # List of the points
        coords = []

        # Startingpoint
        p0 = QgsPoint(0, 0)
        coords.append(p0)

        p1 = QgsPoint(0, abs(float(meas[0])))
        coords.append(p1)

        for i in range(len(meas)):
            if i > 0:
                azi = cadutils.azimuth(p0, p1)
                if azi == 0 or azi == 2 * math.pi:
                    p0 = p1
                    p1 = QgsPoint(p0.x() + float(meas[i]), p0.y())
                    coords.append(p1)
                elif azi == math.pi / 2:
                    p0 = p1
                    p1 = QgsPoint(p0.x(), p0.y() - float(meas[i]))
                    coords.append(p1)
                elif azi == math.pi:
                    p0 = p1
                    p1 = QgsPoint(p0.x() - float(meas[i]), p0.y())
                    coords.append(p1)
                elif azi == 3 * math.pi / 2:
                    p0 = p1
                    p1 = QgsPoint(p0.x(), p0.y() + float(meas[i]))

        if len(coords) > 0:
            g = QgsGeometry.fromPolyline(coords)
            return g
        else:
            return None
Esempio n. 4
0
    def traverse(trv,  azth,  scale):
##        print "OrthogonalTraverse.traverse"
##        print trv
        meas = str(trv).split()
        
        # List of the points
        coords = []
        
        # Startingpoint
        p0 = QgsPoint(0,0)
        coords.append(p0)
        
        p1 = QgsPoint(0,abs(float(meas[0])))
        coords.append(p1)

        for i in range(len(meas)):
            if i > 0:
                azi =  cadutils.azimuth(p0, p1)
                if azi == 0 or azi == 2*math.pi:
                    p0 = p1
                    p1 = QgsPoint( p0.x()+float(meas[i]), p0.y() )
                    coords.append(p1)
                elif azi == math.pi / 2:
                    p0 = p1
                    p1 = QgsPoint( p0.x(),  p0.y() - float(meas[i]))
                    coords.append(p1) 
                elif azi == math.pi:
                    p0 = p1
                    p1 = QgsPoint( p0.x() - float(meas[i]), p0.y() )
                    coords.append(p1)
                elif azi == 3*math.pi/2:
                    p0 = p1
                    p1 = QgsPoint( p0.x(), p0.y() + float(meas[i]))

        if len(coords) > 0:
            g = QgsGeometry.fromPolyline(coords)
            return g
        else:
            return None