Ejemplo n.º 1
0
    def processMethod(self ,i ,j ,hCount,wCount,block,wStartNumber,hStartNumber,xStartValue,yStartValue,xOffSet, yOffSet,obstacleLayer,obstacleTable,obstacleUnits,mocMultiplier):
        featureID = 0
        while i <=  hCount - 1:
            j = 0
            while j <=  wCount - 1:
    #                         altitude = block.value(wStartNumber, hStartNumber)
                name = "DEM"
    #                     startTime = time.time()
    #                     print "startTime" + str(startTime)
                if block.isNoData(j + wStartNumber, i + hStartNumber):
                    j += 1
                    continue
                altitude = block.value(j + wStartNumber, i + hStartNumber)
                trees = define._trees
                tolerance = define._tolerance
                point = QgsPoint(xStartValue + (j + wStartNumber) * xOffSet + xOffSet / 2, yStartValue - (i + hStartNumber) * yOffSet - yOffSet / 2)
                position = Point3D()
                positionDegree = Point3D()
                if obstacleUnits == QGis.Meters:
                    position = Point3D(point.x(), point.y(), altitude)
                    if obstacleUnits != define._units:
                        positionDegree = QgisHelper.Meter2DegreePoint3D(position)
                else:
                    positionDegree = Point3D(point.x(), point.y(), altitude)
                    if obstacleUnits != define._units:
                        position = QgisHelper.Degree2MeterPoint3D(positionDegree)
                    
                featureId = featureID
                layerId = obstacleLayer.id()
                obstacle = Obstacle(name, position, layerId, featureId, None, trees, mocMultiplier, tolerance)
                obstacle.positionDegree = positionDegree 
                
    #                     middleTime = time.time()
    #                     print "middleTime" + str(middleTime)
    #                 obstacle.positionDegree = positionDegree
                
                obstacleTable.checkObstacle(obstacle)
                self.lock.acquire()
                try:
                    
                    obstacleTable.progress.setValue(obstacleTable.progress.value() + 1)
                    QApplication.processEvents()
                finally:
                    self.lock.release()
                
    #                     endTime = time.time()
    #                     print "endTime" + str(endTime)
                
                j += 1
                featureID += 1
#                 obstacle = None
#             print i
            i += 1  
    def tableViewObstacleMouseTeleaseEvent_rightButton(self, e):
        if self.obstaclesModel == None:
            return
        featID = self.obstaclesModel.data(
            self.obstaclesModel.index(
                self.selectedObstacleMoselIndex.row(),
                self.obstaclesModel.IndexObjectId)).toString()
        layerID = self.obstaclesModel.data(
            self.obstaclesModel.index(
                self.selectedObstacleMoselIndex.row(),
                self.obstaclesModel.IndexLayerId)).toString()
        name = self.obstaclesModel.data(
            self.obstaclesModel.index(
                self.selectedObstacleMoselIndex.row(),
                self.obstaclesModel.IndexName)).toString()
        xValue = self.obstaclesModel.data(
            self.obstaclesModel.index(self.selectedObstacleMoselIndex.row(),
                                      self.obstaclesModel.IndexX)).toString()
        yValue = self.obstaclesModel.data(
            self.obstaclesModel.index(self.selectedObstacleMoselIndex.row(),
                                      self.obstaclesModel.IndexY)).toString()
        altitudeMValue = self.obstaclesModel.data(
            self.obstaclesModel.index(
                self.selectedObstacleMoselIndex.row(),
                self.obstaclesModel.IndexAltM)).toString()
        surfaceName = self.obstaclesModel.data(
            self.obstaclesModel.index(
                self.selectedObstacleMoselIndex.row(),
                self.obstaclesModel.IndexSurface)).toString()
        ocaMValue = self.obstaclesModel.data(
            self.obstaclesModel.index(
                self.selectedObstacleMoselIndex.row(),
                self.obstaclesModel.IndexOcaM)).toString()
        # ocaMValue = self.obstaclesModel.data(self.obstaclesModel.index(self.selectedObstacleMoselIndex.row(), self.obstaclesModel.IndexOcaM)).toString()
        obstacle = Obstacle(
            name, Point3D(float(xValue), float(yValue), float(altitudeMValue)),
            layerID, featID, None, 0.0, self.obstaclesModel.MocMultiplier, 0.0)
        self.changedCriticalObstacleValue = {
            "Obstacle": obstacle,
            "SurfaceName": surfaceName,
            "OcaM": float(ocaMValue) if ocaMValue != "" else None
        }

        menu = QMenu()
        actionSetCriticalObst = QgisHelper.createAction(
            menu, "Set Most Critical Obstacles", self.menuSetCriticalObstClick)
        menu.addAction(actionSetCriticalObst)
        menu.exec_(self.ui.tblObstacles.mapToGlobal(e.pos()))
Ejemplo n.º 3
0
    def loadObstaclesVector(self, obstacleLayers, surfaceLayers):
        progressMessageBar = define._messagBar.createMessage(
            "Loading Vector Obstacles...")
        self.progress = QProgressBar()
        self.progress.setAlignment(Qt.AlignLeft | Qt.AlignVCenter)
        progressMessageBar.layout().addWidget(self.progress)
        define._messagBar.pushWidget(progressMessageBar,
                                     define._messagBar.INFO)
        maxium = 0
        self.progress.setValue(0)
        for ly in obstacleLayers:
            maxium += ly.featureCount()

        if maxium == 0:
            return False
        self.progress.setMaximum(maxium)

        for obstacleLayer in obstacleLayers:
            obstacleUnits = obstacleLayer.crs().mapUnits()
            features = QgisHelper.getFeaturesInLayerExtent(
                define._canvas, obstacleLayer, surfaceLayers,
                SelectionModeType.Automatic)
            #             print len(features)
            for feature in features:
                name = feature.attribute("Name").toString()
                altitude = feature.attribute("Altitude").toFloat()[0]
                trees = define._trees
                tolerance = define._tolerance
                point = feature.geometry().asPoint()
                position = Point3D()
                positionDegree = Point3D()
                if define._canvas.mapUnits() == QGis.Meters:
                    if define._canvas.mapSettings().destinationCrs(
                    ) != obstacleLayer.crs():
                        position = QgisHelper.CrsTransformPoint(
                            point.x(), point.y(), obstacleLayer.crs(),
                            define._canvas.mapSettings().destinationCrs(),
                            altitude)
                    else:
                        position = Point3D(point.x(), point.y(), altitude)
                else:
                    if define._canvas.mapSettings().destinationCrs(
                    ) != obstacleLayer.crs():
                        positionDegree = QgisHelper.CrsTransformPoint(
                            point.x(), point.y(), obstacleLayer.crs(),
                            define._canvas.mapSettings().destinationCrs(),
                            altitude)
                    else:
                        positionDegree = Point3D(point.x(), point.y(),
                                                 altitude)
                featureId = feature.id()
                layerId = obstacleLayer.id()
                obstacle = Obstacle(name, position, layerId, featureId, None,
                                    trees, ObstacleTable.MocMultiplier,
                                    tolerance)
                obstacle.positionDegree = positionDegree
                #                 obstacle.positionDegree = positionDegree
                self.checkObstacle(obstacle)
                self.progress.setValue(self.progress.value() + 1)
                QApplication.processEvents()
            QApplication.processEvents()
        self.progress.setValue(maxium)
        define._messagBar.hide()
        self.manualPolygon = None
Ejemplo n.º 4
0
    def loadObstaclesDEM(self, obstacleLayersDEM, surfaceLayers):
        progressMessageBar = define._messagBar.createMessage(
            "Loading DEM Obstacles...")
        self.progress = QProgressBar()
        self.progress.setAlignment(Qt.AlignLeft | Qt.AlignVCenter)
        progressMessageBar.layout().addWidget(self.progress)
        define._messagBar.pushWidget(progressMessageBar,
                                     define._messagBar.INFO)
        maxium = 0
        offset = 0.0
        self.progress.setValue(0)
        wCount = 0
        hCount = 0
        for ly in obstacleLayersDEM:
            demDataProvider = ly.dataProvider()
            boundDem = demDataProvider.extent()
            xMin = boundDem.xMinimum()
            xMax = boundDem.xMaximum()
            yMin = boundDem.yMinimum()
            yMax = boundDem.yMaximum()
            bound = QgisHelper.getIntersectExtent(
                ly, QgsGeometry.fromRect(boundDem), surfaceLayers)
            #             boundGeom = QgsGeometry.fromRect(bound)
            if bound == None:
                continue
            block = ly.dataProvider().block(0, ly.extent(), ly.width(),
                                            ly.height())
            xMinimum = ly.dataProvider().extent().xMinimum()
            yMaximum = ly.dataProvider().extent().yMaximum()
            yMinimum = ly.dataProvider().extent().yMinimum()
            xMaximum = ly.dataProvider().extent().xMaximum()

            xOffSet = ly.extent().width() / ly.width()
            yOffSet = ly.extent().height() / ly.height()
            offset = xOffSet
            if bound.xMinimum() < xMinimum:
                wStartNumber = 0
                xStartValue = xMinimum
            else:
                wStartNumber = int((bound.xMinimum() - xMinimum) / xOffSet)
                xStartValue = bound.xMinimum()
            if yMaximum < bound.yMaximum():
                hStartNumber = 0
                yStartValue = yMaximum
            else:
                hStartNumber = int((yMaximum - bound.yMaximum()) / yOffSet)
                yStartValue = bound.yMaximum()

            if bound.xMaximum() > xMaximum:
                xEndValue = xMaximum
            else:
                xEndValue = bound.xMaximum()
            if yMinimum > bound.yMinimum():
                yEndValue = yMinimum
            else:
                yEndValue = bound.yMinimum()
            wCount = int(math.fabs(xEndValue - xStartValue) / xOffSet)
            hCount = int(math.fabs(yEndValue - yStartValue) / yOffSet)

            pixelCount = hCount
            maxium += pixelCount

        cellSizeWnd = cellsizeWnd(offset, wCount * hCount, maxium * 0.04)
        cellSizeWnd.setWindowTitle("Input Cell Size")
        result = cellSizeWnd.exec_()
        cellRate = 1
        if result == 1:
            offset = cellSizeWnd.cellsize
            maxium = cellSizeWnd.cellCount + 2
            cellRate = cellSizeWnd.cellRate


#             print cellSizeWnd.textedit1.text()

        if maxium == 0:
            return False
        self.progress.setMaximum(maxium)

        trees = define._treesDEM
        tolerance = define._toleranceDEM

        for obstacleLayer in obstacleLayersDEM:
            obstacleUnits = obstacleLayer.crs().mapUnits()
            demDataProvider = obstacleLayer.dataProvider()
            boundDem = demDataProvider.extent()
            bound = QgisHelper.getIntersectExtent(
                obstacleLayer, QgsGeometry.fromRect(boundDem), surfaceLayers)
            if bound == None:
                continue
            boundGeom = QgsGeometry.fromRect(bound)
            if not boundGeom.intersects(QgsGeometry.fromRect(boundDem)):
                continue
            block = obstacleLayer.dataProvider().block(1,
                                                       obstacleLayer.extent(),
                                                       obstacleLayer.width(),
                                                       obstacleLayer.height())
            xMinimum = obstacleLayer.extent().xMinimum()
            yMaximum = obstacleLayer.extent().yMaximum()
            yMinimum = obstacleLayer.extent().yMinimum()
            xMaximum = obstacleLayer.extent().xMaximum()

            xOffSet = obstacleLayer.extent().width() / obstacleLayer.width()
            yOffSet = obstacleLayer.extent().height() / obstacleLayer.height()

            if bound.xMinimum() < xMinimum:
                hStartNumber = 0
                xStartValue = xMinimum
            else:
                hStartNumber = int((bound.xMinimum() - xMinimum) / xOffSet)
                xStartValue = bound.xMinimum()
            if yMaximum < bound.yMaximum():
                wStartNumber = 0
                yStartValue = yMaximum
            else:
                wStartNumber = int((yMaximum - bound.yMaximum()) / yOffSet)
                yStartValue = bound.yMaximum()

            if bound.xMaximum() > xMaximum:
                xEndValue = xMaximum
            else:
                xEndValue = bound.xMaximum()
            if yMinimum > bound.yMinimum():
                yEndValue = yMinimum
            else:
                yEndValue = bound.yMinimum()
            wCount = int(math.fabs(xEndValue - xStartValue) / offset)
            hCount = int(math.fabs(yEndValue - yStartValue) / offset)

            xPixelWidth = 0.0
            yPixelWidth = 0.0
            featureID = 0
            # i = 0
            # k = 0
            # altitudeList = []
            # self.progress.setValue(0)
            # while i  <=  hCount - 1:
            #     j = 0
            #     while j <= wCount - 1:
            #         if block.isNoData(j * int(cellRate) + wStartNumber, i* int(cellRate) + hStartNumber):
            #             self.progress.setValue(k)
            #             QApplication.processEvents()
            #             j += 1
            #             k += 1
            #             altitudeList.append(None)
            #             continue
            #         altitude = block.value(j * int(cellRate) + wStartNumber, i * int(cellRate) + hStartNumber)
            #         altitudeList.append(altitude)
            #         self.progress.setValue(k)
            #         QApplication.processEvents()
            #         j += 1
            #         k += 1
            #     i += 1

            i = 0
            k = 0
            name = "DEM"
            semiXoffset = xOffSet / 2
            semiYoffset = yOffSet / 2
            while i <= hCount - 1:
                j = 0
                while j <= wCount - 1:
                    if block.isNoData(j * cellRate + wStartNumber,
                                      i * cellRate + hStartNumber):
                        self.progress.setValue(k)
                        QApplication.processEvents()
                        j += 1
                        k += 1
                        continue
                    altitude = block.value(j * cellRate + wStartNumber,
                                           i * cellRate + hStartNumber)
                    # # if block.isNoData(j * int(cellRate) + wStartNumber, i* int(cellRate) + hStartNumber):
                    # #     j += 1
                    # #     self.progress.setValue(self.progress.value() + 1)
                    # #     QApplication.processEvents()
                    # #     continue
                    # # altitude = block.value(j* int(cellRate) + wStartNumber, i* int(cellRate)+ hStartNumber)
                    # altitude = altitudeList[k]
                    # if altitude == None:
                    #     self.progress.setValue(k)
                    #     QApplication.processEvents()
                    #     j += 1
                    #     k += 1
                    #     continue

                    point = QgsPoint(
                        xStartValue + (i * cellRate) * xOffSet + semiXoffset,
                        yStartValue - (j * cellRate - 1) * yOffSet -
                        semiYoffset)
                    position = Point3D()
                    positionDegree = Point3D()

                    if define._canvas.mapUnits() == QGis.Meters:
                        if define._canvas.mapSettings().destinationCrs(
                        ) != obstacleLayer.crs():
                            position = QgisHelper.CrsTransformPoint(
                                point.x(), point.y(), obstacleLayer.crs(),
                                define._canvas.mapSettings().destinationCrs(),
                                altitude)
                        else:
                            position = Point3D(point.x(), point.y(), altitude)
                    else:
                        if define._canvas.mapSettings().destinationCrs(
                        ) != obstacleLayer.crs():
                            positionDegree = QgisHelper.CrsTransformPoint(
                                point.x(), point.y(), obstacleLayer.crs(),
                                define._canvas.mapSettings().destinationCrs(),
                                altitude)
                        else:
                            positionDegree = Point3D(point.x(), point.y(),
                                                     altitude)
                    obstacle = Obstacle(name, position, obstacleLayer.id(),
                                        featureID, None, trees,
                                        ObstacleTable.MocMultiplier, tolerance)
                    obstacle.positionDegree = positionDegree
                    if self.manualPolygon != None:
                        if not self.manualPolygon.contains(obstacle.Position):
                            continue
                    self.checkObstacle(obstacle)
                    self.progress.setValue(k)
                    QApplication.processEvents()
                    j += 1
                    featureID += 1
                    k += 1
                i += 1
        self.progress.setValue(maxium)
        define._messagBar.hide()
        self.manualPolygon = None
Ejemplo n.º 5
0
    def loadObstaclesDEM(self, obstacleLayersDEM, surfaceLayers):
        progressMessageBar = define._messagBar.createMessage(
            "Loading DEM Obstacles...")
        self.progress = QProgressBar()
        self.progress.setAlignment(Qt.AlignLeft | Qt.AlignVCenter)
        progressMessageBar.layout().addWidget(self.progress)
        define._messagBar.pushWidget(progressMessageBar,
                                     define._messagBar.INFO)
        maxium = 0
        offset = 0.0
        self.progress.setValue(0)
        wCount = 0
        hCount = 0
        for ly in obstacleLayersDEM:
            #             if isinstance(ly, QgsRasterLayer):

            #             if demEvaluateAg == QMessageBox.No:
            #                 continue

            demDataProvider = ly.dataProvider()
            boundDem = demDataProvider.extent()
            xMin = boundDem.xMinimum()
            xMax = boundDem.xMaximum()
            yMin = boundDem.yMinimum()
            yMax = boundDem.yMaximum()
            bound = QgisHelper.getIntersectExtent(
                ly, QgsGeometry.fromRect(boundDem), surfaceLayers)
            #             boundGeom = QgsGeometry.fromRect(bound)
            if bound == None:
                continue

#             if define._units != ly.crs().mapUnits():
#
#                 if ly.crs().mapUnits() == QGis.Meters:
#                     minPoint = QgisHelper.Degree2Meter(xMin, yMin)
#                     maxPoint = QgisHelper.Degree2Meter(xMax, yMax)
#                     bound = QgsRectangle(minPoint, maxPoint)
#                 else:
#                     minPoint = QgisHelper.Meter2Degree(xMin, yMin)
#                     maxPoint = QgisHelper.Meter2Degree(xMax, yMax)
#                     bound = QgsRectangle(minPoint, maxPoint)
#             if define._canvas.mapUnits() == ly.crs().mapUnits():
#                 if define._mapCrs != None and define._mapCrs != ly.crs():
#                     minPoint = QgisHelper.CrsTransformPoint(xMin, yMin, define._mapCrs, ly.crs())
#                     maxPoint = QgisHelper.CrsTransformPoint(xMax, yMax, define._mapCrs, ly.crs())
#                     bound = QgsRectangle(minPoint, maxPoint)
            block = ly.dataProvider().block(0, ly.extent(), ly.width(),
                                            ly.height())
            xMinimum = ly.dataProvider().extent().xMinimum()
            yMaximum = ly.dataProvider().extent().yMaximum()
            yMinimum = ly.dataProvider().extent().yMinimum()
            xMaximum = ly.dataProvider().extent().xMaximum()

            xOffSet = ly.extent().width() / ly.width()
            yOffSet = ly.extent().height() / ly.height()
            offset = xOffSet
            if bound.xMinimum() < xMinimum:
                wStartNumber = 0
                xStartValue = xMinimum
            else:
                wStartNumber = int((bound.xMinimum() - xMinimum) / xOffSet)
                xStartValue = bound.xMinimum()
            if yMaximum < bound.yMaximum():
                hStartNumber = 0
                yStartValue = yMaximum
            else:
                hStartNumber = int((yMaximum - bound.yMaximum()) / yOffSet)
                yStartValue = bound.yMaximum()

            if bound.xMaximum() > xMaximum:
                xEndValue = xMaximum
            else:
                xEndValue = bound.xMaximum()
            if yMinimum > bound.yMinimum():
                yEndValue = yMinimum
            else:
                yEndValue = bound.yMinimum()
            wCount = int(math.fabs(xEndValue - xStartValue) / xOffSet)
            hCount = int(math.fabs(yEndValue - yStartValue) / yOffSet)

            pixelCount = hCount
            maxium += pixelCount
        cellSizeWnd = cellsizeWnd(offset, wCount * hCount, maxium * 0.04)
        cellSizeWnd.setWindowTitle("Input Cell Size")
        result = cellSizeWnd.exec_()
        if result == 1:
            offset = cellSizeWnd.cellsize
            maxium = cellSizeWnd.cellCount + 2
#             print cellSizeWnd.textedit1.text()

        if maxium == 0:
            return False
        self.progress.setMaximum(maxium)

        for obstacleLayer in obstacleLayersDEM:
            obstacleUnits = obstacleLayer.crs().mapUnits()
            #             if isinstance(obstacleLayer, QgsRasterLayer):
            #             if demEvaluateAg == QMessageBox.No or demEvaluateAg == None:
            #                 continue
            #             bound = QgisHelper.getMultiExtent(surfaceLayers)
            demDataProvider = obstacleLayer.dataProvider()
            boundDem = demDataProvider.extent()
            bound = QgisHelper.getIntersectExtent(
                obstacleLayer, QgsGeometry.fromRect(boundDem), surfaceLayers)
            if bound == None:
                continue
            boundGeom = QgsGeometry.fromRect(bound)
            if not boundGeom.intersects(QgsGeometry.fromRect(boundDem)):
                continue
#             if define._units != obstacleLayer.crs().mapUnits():
#                 xMin = bound.xMinimum()
#                 xMax = bound.xMaximum()
#                 yMin = bound.yMinimum()
#                 yMax = bound.yMaximum()
#                 if obstacleLayer.crs().mapUnits() == QGis.Meters:
#                     minPoint = QgisHelper.Degree2Meter(xMin, yMin)
#                     maxPoint = QgisHelper.Degree2Meter(xMax, yMax)
#                     bound = QgsRectangle(minPoint, maxPoint)
#                 else:
#                     minPoint = QgisHelper.Meter2Degree(xMin, yMin)
#                     maxPoint = QgisHelper.Meter2Degree(xMax, yMax)
#                     bound = QgsRectangle(minPoint, maxPoint)
#             if define._canvas.mapUnits() == obstacleLayer.crs().mapUnits():
#                 if define._mapCrs != None and define._mapCrs != obstacleLayer.crs():
#                     minPoint = QgisHelper.CrsTransformPoint(xMin, yMin, define._mapCrs, obstacleLayer.crs())
#                     maxPoint = QgisHelper.CrsTransformPoint(xMax, yMax, define._mapCrs, obstacleLayer.crs())
#                     bound = QgsRectangle(minPoint, maxPoint)
            block = obstacleLayer.dataProvider().block(1,
                                                       obstacleLayer.extent(),
                                                       obstacleLayer.width(),
                                                       obstacleLayer.height())
            xMinimum = obstacleLayer.extent().xMinimum()
            yMaximum = obstacleLayer.extent().yMaximum()
            yMinimum = obstacleLayer.extent().yMinimum()
            xMaximum = obstacleLayer.extent().xMaximum()

            xOffSet = obstacleLayer.extent().width() / obstacleLayer.width()
            yOffSet = obstacleLayer.extent().height() / obstacleLayer.height()

            if bound.xMinimum() < xMinimum:
                wStartNumber = 0
                xStartValue = xMinimum
            else:
                wStartNumber = int((bound.xMinimum() - xMinimum) / xOffSet)
                xStartValue = bound.xMinimum()
            if yMaximum < bound.yMaximum():
                hStartNumber = 0
                yStartValue = yMaximum
            else:
                hStartNumber = int((yMaximum - bound.yMaximum()) / yOffSet)
                yStartValue = bound.yMaximum()

            if bound.xMaximum() > xMaximum:
                xEndValue = xMaximum
            else:
                xEndValue = bound.xMaximum()
            if yMinimum > bound.yMinimum():
                yEndValue = yMinimum
            else:
                yEndValue = bound.yMinimum()
            wCount = int(math.fabs(xEndValue - xStartValue) / offset)
            hCount = int(math.fabs(yEndValue - yStartValue) / offset)

            xPixelWidth = 0.0
            yPixelWidth = 0.0
            featureID = 0
            i = 0
            #                 j = 0
            i0 = 0
            j = 0

            #             i1 = int(hCount/2)
            #             threads = []
            # #             i2 = int(hCount/3 * 2)
            #             lock = threading.Lock()
            #
            #             for n in range(2):
            #                 i0 =  int(hCount/3 * n)
            #                 i1 =  int(hCount/3 * (n + 1))
            #                 if i0 == i1:
            #                     continue
            #                 thread0 = threading.Thread(target=processDEMMethod, args=(lock,i0,j,i1,wCount,block,wStartNumber,hStartNumber,xStartValue,yStartValue,xOffSet, yOffSet,obstacleLayer,self,obstacleUnits,ObstacleTable.MocMultiplier,))
            #                 thread0.start()
            #                 threads.append(thread0)
            #             i = i1
            while i <= hCount - 1:
                j = 0
                while j <= wCount - 1:
                    #                         altitude = block.value(wStartNumber, hStartNumber)
                    name = "DEM"
                    #                     startTime = time.time()
                    #                     print "startTime" + str(startTime)
                    if block.isNoData(j * int(offset / xOffSet) + wStartNumber,
                                      i * int(offset / xOffSet) +
                                      hStartNumber):
                        j += 1
                        continue
                    altitude = block.value(
                        j * int(offset / xOffSet) + wStartNumber,
                        i * int(offset / xOffSet) + hStartNumber)
                    trees = define._treesDEM
                    tolerance = define._toleranceDEM
                    point = QgsPoint(
                        xStartValue + (j * int(offset / xOffSet)) * xOffSet +
                        xOffSet / 2, yStartValue -
                        (i * int(offset / xOffSet)) * yOffSet - yOffSet / 2)
                    position = Point3D()
                    positionDegree = Point3D()
                    if obstacleUnits == QGis.Meters:
                        if define._canvas.mapSettings().destinationCrs(
                        ) != obstacleLayer.crs():
                            position = QgisHelper.CrsTransformPoint(
                                point.x(), point.y(), obstacleLayer.crs(),
                                define._canvas.mapSettings().destinationCrs(),
                                altitude)
                    if define._canvas.mapUnits() == QGis.Meters:
                        if define._canvas.mapSettings().destinationCrs(
                        ) != obstacleLayer.crs():
                            position = QgisHelper.CrsTransformPoint(
                                point.x(), point.y(), obstacleLayer.crs(),
                                define._canvas.mapSettings().destinationCrs(),
                                altitude)
                        else:
                            position = Point3D(point.x(), point.y())
#                         if obstacleUnits != define._units:
#                             positionDegree = QgisHelper.Meter2DegreePoint3D(position)
                    else:
                        if define._canvas.mapSettings().destinationCrs(
                        ) != obstacleLayer.crs():
                            positionDegree = QgisHelper.CrsTransformPoint(
                                point.x(), point.y(), obstacleLayer.crs(),
                                define._canvas.mapSettings().destinationCrs(),
                                altitude)
                        else:
                            positionDegree = Point3D(point.x(), point.y())
#                         if obstacleUnits != define._units:
#                             position = QgisHelper.Degree2MeterPoint3D(positionDegree)

                    featureId = featureID
                    layerId = obstacleLayer.id()
                    obstacle = Obstacle(name, position, layerId, featureId,
                                        None, trees,
                                        ObstacleTable.MocMultiplier, tolerance)
                    obstacle.positionDegree = positionDegree
                    if self.manualPolygon != None:
                        if not self.manualPolygon.contains(obstacle.position):
                            continue

#                     middleTime = time.time()
#                     print "middleTime" + str(middleTime)
#                 obstacle.positionDegree = positionDegree

                    self.checkObstacle(obstacle)
                    self.progress.setValue(self.progress.value() + 1)
                    QApplication.processEvents()

                    #                     endTime = time.time()
                    #                     print "endTime" + str(endTime)

                    j += 1
                    featureID += 1
#                     obstacle = None
#                 lock.acquire()
#                 try:

#                 finally:
#                     lock.release()
                i += 1
#             threadFinishedFlag = False
#             while not threadFinishedFlag:
#                 QThread.sleep(0.5)
#                 if(thread0.isFinished() and thread1.isFinished()):
#                     threadFinishedFlag = True
#             for thread in threads:
#                 thread.join()
        self.progress.setValue(maxium)
        define._messagBar.hide()
        self.manualPolygon = None