Esempio n. 1
0
 def test_byContinuity(self):
     dataCollector = DataCollector()
     dataCollector.collectData([pipe_L_broken])
     pipeDirectionTool = PipeDirectionTool()
     pipeDirectionTool.byContinuity([pipe_L_broken], dataCollector)
     
     self.assertTrue(pipeDirectionTool.outputLyr.isValid())
     self.assertEqual(pipeDirectionTool.outputLyr.featureCount(), 1)
Esempio n. 2
0
    def test_snapping_tool(self):
        dataCollectorLines = DataCollector(None)
        dataCollectorLines.collectData([pipe_L_broken, culv_L], dem)
        dataCollectorPoints = DataCollector(None)
        dataCollectorPoints.collectData([pits_P_broken], dem, [pipe_L_broken, culv_L], dataCollectorLines)

        snappingToolLines = SnappingTool(dataCollector=dataCollectorLines, dataCollectorPoints=dataCollectorPoints)
        snappingToolPoints = SnappingTool(dataCollector=dataCollectorPoints, outputLyr=snappingToolLines.outputLyr,
                                          dataCollectorLines=dataCollectorLines)

        self.assertTrue(snappingToolLines.outputLyr.isValid())
        self.assertEqual(snappingToolLines.outputLyr.featureCount(), 6)

        snappingToolLines.autoSnap(2)
        self.assertTrue(snappingToolLines.outputLyr.isValid())
        self.assertEqual(snappingToolLines.outputLyr.featureCount(), 8)
        lyr = snappingToolLines.tmpLyrs[0]
        allFeatures = {f.attribute(0): f for f in lyr.getFeatures()}
        feat = allFeatures['Pipe5']
        feat2 = allFeatures['Pipe19']
        point1 = feat.geometry().asMultiPolyline()[0][0]
        point2 = feat2.geometry().asMultiPolyline()[0][-1]
        self.assertEqual(point1, point2)
        
        snappingToolPoints.autoSnap(2)
        self.assertTrue(snappingToolPoints.outputLyr.isValid())
        self.assertTrue((snappingToolPoints.outputLyr.featureCount()), 10)
        lyrP = snappingToolPoints.tmpLyrs[0]
        allFeaturesP = {f.attribute(0): f for f in lyrP.getFeatures()}
        feat3 = allFeaturesP['Pit15']
        point3 = feat3.geometry().asPoint()
        point4 = feat.geometry().asMultiPolyline()[0][-1]
        self.assertEqual(point3, point4)
Esempio n. 3
0
 def test_xs(self):
     dataCollector = DataCollector(None)
     dataCollector.collectData([chan_L], tables=[xs])
     
     feature1 = dataCollector.features['FC01.40']
     self.assertEqual(feature1.invertUs, 48.543999999999997)
     self.assertEqual(feature1.invertDs, 45.984000000000002)
     
     feature2 = dataCollector.features['FC01.37']
     self.assertEqual(feature2.invertUs, 44.6067)
     self.assertEqual(feature2.invertDs, 44.3078)
     
     feature3 = dataCollector.features['FC_weir1']
     self.assertEqual(feature3.invertUs, 44.7724)
     self.assertEqual(feature3.invertDs, 44.7724)
Esempio n. 4
0
    def test_unsnapped_objects(self):
        dataCollectorLines = DataCollector(None)
        dataCollectorLines.collectData([pipe_L_broken], dem)
        dataCollectorPoints = DataCollector(None)
        dataCollectorPoints.collectData([pits_P_broken], dem, [pipe_L_broken], dataCollectorLines)

        self.assertEqual(len(dataCollectorLines.unsnappedVertexes), 7)
        self.assertEqual(dataCollectorLines.unsnappedVertexes[3].id, 'Pipe19')
        self.assertEqual(dataCollectorLines.unsnappedVertexes[3].vertex, VERTEX.Last)
        self.assertEqual(dataCollectorLines.unsnappedVertexes[3].closestVertex.id, 'Pipe5')
        self.assertEqual(len(dataCollectorPoints.unsnappedVertexes), 3)
        self.assertEqual(dataCollectorPoints.unsnappedVertexes[0].id, 'Pit7')
        self.assertEqual(dataCollectorPoints.unsnappedVertexes[0].distanceToClosest, 1.1485081024527481)
        self.assertEqual(dataCollectorPoints.unsnappedVertexes[1].closestVertex.id, "Pipe12")
Esempio n. 5
0
    def test_channel_connection(self):
        dataCollector = DataCollector(None)
        dataCollector.collectData([chan_L, culv_L], dem)

        x1ConnData = dataCollector.connections['__connector__1']
        self.assertEqual(x1ConnData.linesUs, ['FC_weir1'])
        self.assertEqual(x1ConnData.linesDs, ['FC01.32'])
        self.assertEqual(x1ConnData.linesUsUs, [])
        self.assertEqual(x1ConnData.linesDsDs, ['FC01.33'])

        x2ConnData = dataCollector.connections['__connector__2']
        self.assertEqual(x2ConnData.linesUs, ['FC01.34'])
        self.assertEqual(x2ConnData.linesDs, ['FC_weir1'])
        self.assertEqual(x2ConnData.linesUsUs, ['FC01.33'])
        self.assertEqual(x2ConnData.linesDsDs, [])

        x3ConnData = dataCollector.connections['__connector__3']
        self.assertEqual(x3ConnData.linesUs, ['TEST'])
        self.assertEqual(x3ConnData.linesDs, ['FC01.30'])
        self.assertEqual(x3ConnData.linesUsUs, [])
        self.assertEqual(x3ConnData.linesDsDs, ['FC01.31'])

        x4ConnData = dataCollector.connections['__connector__4']
        self.assertEqual(x4ConnData.linesUs, ['FC01.32'])
        self.assertEqual(x4ConnData.linesDs, ['TEST'])
        self.assertEqual(x4ConnData.linesUsUs, ['FC01.31'])
        self.assertEqual(x4ConnData.linesDsDs, [])

        connData = dataCollector.connections['FC01.32']
        self.assertEqual(sorted(connData.linesUs), ['FC01.33', '__connector__1'])
        self.assertEqual(sorted(connData.linesDs), ['FC01.31', '__connector__4'])
        self.assertEqual(connData.linesUsUs, [])
        self.assertEqual(connData.linesDsDs, [])

        connData2 = dataCollector.connections['FC01.12']
        self.assertEqual(connData2.linesUs, ['FC01.13'])
        self.assertEqual(connData2.linesDs, ['FC01.2_R'])
        self.assertEqual(connData2.linesUsUs, [])
        self.assertEqual(connData2.linesDsDs, [])
Esempio n. 6
0
 def test_area(self):
     dataCollector = DataCollector(None)
     dataCollector.collectData([pipe_L_broken], dem=dem)
     dataCollectorP = DataCollector(None)
     dataCollectorP.collectData([pits_P_broken], lines=[pipe_L_broken], lineDataCollector=dataCollector, dem=dem)
     
     continuityCheck = ContinuityTool(dataCollector=dataCollector, limitAngle=90, limitCover=0.5, limitArea=20,
                                      checkArea=True, checkAngle=True, checkInvert=True, checkCover=True)
     self.assertEqual(len(continuityCheck.flaggedAreas), 3)
     self.assertEqual(len(continuityCheck.flaggedInverts), 1)
     self.assertEqual(len(continuityCheck.flaggedGradients), 2)
     self.assertEqual(len(continuityCheck.flaggedAngles), 1)
     self.assertEqual(len(continuityCheck.flaggedCover), 3)
     self.assertTrue(continuityCheck.outputLyr.isValid())
     self.assertEqual(continuityCheck.outputLyr.featureCount(), 10)
Esempio n. 7
0
    def test_pipe_connections(self):
        dataCollectorLines = DataCollector(None)
        dataCollectorLines.collectData([pipe_L], dem)
        dataCollectorPoints = DataCollector(None)
        dataCollectorPoints.collectData([pits_P], dem, [pipe_L], dataCollectorLines)

        pitConnData = dataCollectorPoints.connections['Pit17']
        self.assertEqual(sorted(pitConnData.linesUs), ['Pipe2', 'Pipe8'])
        self.assertEqual(pitConnData.linesDs, ['Pipe9'])
        self.assertEqual(pitConnData.linesUsUs, [])
        self.assertEqual(pitConnData.linesDsDs, [])

        pipeConnData = dataCollectorLines.connections['Pipe12']
        self.assertEqual(pipeConnData.pointUs, 'Pit8')
        self.assertEqual(pipeConnData.pointDs, 'Pit9')
Esempio n. 8
0
import sys
import os
from qgis.core import QgsApplication, QgsVectorLayer
from tuflow.integrity_tool.DataCollector import DataCollector

# initialise QGIS data providers
argv = [bytes(x, 'utf-8') for x in sys.argv]
qgis = QgsApplication(argv, False)
qgis.initQgis()

# path to test map layers
path_elwood_pipes = r"C:\Users\Ellis.Symons\Desktop\Ash Wright\temporary\1d_nwk_Elwood_Pipe_L.shp"
path_elwood_pits = r"C:\Users\Ellis.Symons\Desktop\Ash Wright\temporary\1d_nwk_Elwood_pits_P.shp"

# QgsVectorLayers
elwood_pipes = QgsVectorLayer(path_elwood_pipes, "1d_nwk_Elwood_Pipe_L")
elwood_pits = QgsVectorLayer(path_elwood_pits, "1d_nwk_Elwood_pits_P")

if __name__ == '__main__':
    if elwood_pipes.isValid():
        dataCollector = DataCollector()
        dataCollector.collectData([elwood_pipes])