def _findFiles(self):
     drawingType = self.drawingTypeCombo.itemData(
         self.drawingTypeCombo.currentIndex())
     drawingCode = Config.drawings[drawingType]['code']
     if self._georef:
         self._dir.setPath(Settings.georefDrawingPath(drawingType))
     else:
         self._dir.setPath(Settings.drawingPath(drawingType))
     name = drawingCode + '_' + self._str(
         self.siteCodeEdit.text()) + '_' + self._str(self.idSpin.value())
     if self.eastingSpin.value() > 0 or self.northingSpin.value() > 0:
         name = name + '_' + self._str(
             self.eastingSpin.value()) + 'e' + self._str(
                 self.northingSpin.value()) + 'n'
     nameList = []
     if self._georef:
         nameList.append(name + '_r.tif')
         nameList.append(name + '_modified.tif')
         nameList.append(name + '_*_r.tif')
         nameList.append(name + '_*_modified.tif')
     else:
         nameList.append(name + '.png')
         nameList.append(name + '.tif')
         nameList.append(name + '.tiff')
         nameList.append(name + '_*.png')
         nameList.append(name + '_*.tif')
         nameList.append(name + '_*.tiff')
     self._dir.setNameFilters(nameList)
     files = self._dir.entryInfoList()
     self.fileList.clear()
     for fileInfo in files:
         self.fileList.addItem(fileInfo.fileName())
     self.fileList.setCurrentRow(0)
     self.buttonBox.button(QDialogButtonBox.Open).setEnabled(len(files) > 0)
    def __init__(self, drawingType, siteCode='', georef=False, parent=None):
        super(SelectDrawingDialog, self).__init__(parent)
        self.setupUi(self)

        self._dir = None  # QDir
        self._fileList = []
        self._georef = georef

        keys = sorted(Config.classCodes.keys())
        for key in keys:
            classCode = Config.classCodes[key]
            if classCode['drawing']:
                self.drawingTypeCombo.addItem(classCode['label'], classCode['class'])
        self.drawingTypeCombo.setCurrentIndex(self.drawingTypeCombo.findData(drawingType))
        self.drawingTypeCombo.currentIndexChanged.connect(self._findFiles)
        self.findFilter = ReturnPressedFilter(self)
        self.findFilter.returnPressed.connect(self._findFiles)
        self.siteCodeEdit.installEventFilter(self.findFilter)
        self.idSpin.installEventFilter(self.findFilter)
        self.eastingSpin.installEventFilter(self.findFilter)
        self.northingSpin.installEventFilter(self.findFilter)
        self.idSpin.lineEdit().selectAll()
        self.fileList.setSelectionMode(QAbstractItemView.ExtendedSelection)
        self.buttonBox.button(QDialogButtonBox.Open).setDefault(True)

        if georef:
            self._dir = Settings.georefDrawingDir(drawingType)
        else:
            self._dir = Settings.drawingDir(drawingType)
        self._dir.setFilter(QDir.Files | QDir.NoDotAndDotDot)
        self.siteCodeEdit.setText(siteCode)
        self.findButton.clicked.connect(self._findFiles)
        self._findFiles()
 def _findFiles(self):
     drawingType = self.drawingTypeCombo.itemData(self.drawingTypeCombo.currentIndex())
     drawingCode = Config.drawings[drawingType]['code']
     if self._georef:
         self._dir.setPath(Settings.georefDrawingPath(drawingType))
     else:
         self._dir.setPath(Settings.drawingPath(drawingType))
     name = drawingCode + '_' + self._str(self.siteCodeEdit.text()) + '_' + self._str(self.idSpin.value())
     if self.eastingSpin.value() > 0 or self.northingSpin.value() > 0:
         name = name + '_' + self._str(self.eastingSpin.value()) + 'e' + self._str(self.northingSpin.value()) + 'n'
     nameList = []
     if self._georef:
         nameList.append(name + '_r.tif')
         nameList.append(name + '_modified.tif')
         nameList.append(name + '_*_r.tif')
         nameList.append(name + '_*_modified.tif')
     else:
         nameList.append(name + '.png')
         nameList.append(name + '.tif')
         nameList.append(name + '.tiff')
         nameList.append(name + '_*.png')
         nameList.append(name + '_*.tif')
         nameList.append(name + '_*.tiff')
     self._dir.setNameFilters(nameList)
     files = self._dir.entryInfoList()
     self.fileList.clear()
     for fileInfo in files:
         self.fileList.addItem(fileInfo.fileName())
     self.fileList.setCurrentRow(0)
     self.buttonBox.button(QDialogButtonBox.Open).setEnabled(len(files) > 0)
    def __init__(self, drawingType, siteCode='', georef=False, parent=None):
        super(SelectDrawingDialog, self).__init__(parent)
        self.setupUi(self)

        self._dir = None  # QDir
        self._fileList = []
        self._georef = georef

        keys = sorted(Config.classCodes.keys())
        for key in keys:
            classCode = Config.classCodes[key]
            if classCode['drawing']:
                self.drawingTypeCombo.addItem(classCode['label'],
                                              classCode['class'])
        self.drawingTypeCombo.setCurrentIndex(
            self.drawingTypeCombo.findData(drawingType))
        self.drawingTypeCombo.currentIndexChanged.connect(self._findFiles)
        self.findFilter = ReturnPressedFilter(self)
        self.findFilter.returnPressed.connect(self._findFiles)
        self.siteCodeEdit.installEventFilter(self.findFilter)
        self.idSpin.installEventFilter(self.findFilter)
        self.eastingSpin.installEventFilter(self.findFilter)
        self.northingSpin.installEventFilter(self.findFilter)
        self.idSpin.lineEdit().selectAll()
        self.fileList.setSelectionMode(QAbstractItemView.ExtendedSelection)
        self.buttonBox.button(QDialogButtonBox.Open).setDefault(True)

        if georef:
            self._dir = Settings.georefDrawingDir(drawingType)
        else:
            self._dir = Settings.drawingDir(drawingType)
        self._dir.setFilter(QDir.Files | QDir.NoDotAndDotDot)
        self.siteCodeEdit.setText(siteCode)
        self.findButton.clicked.connect(self._findFiles)
        self._findFiles()
Example #5
0
 def loadProject(self, plugin):
     self.siteCodeCombo.clear()
     for siteCode in sorted(set(Settings.siteCodes())):
         self.siteCodeCombo.addItem(siteCode, siteCode)
     if Settings.siteCode():
         self._setSiteCode(Settings.siteCode())
     else:
         projectCode = Settings.projectCode()
         self.siteCodeCombo.addItem(projectCode, projectCode)
         self._setSiteCode(projectCode)
Example #6
0
 def loadProject(self, plugin):
     if Settings.siteServerUrl():
         self.loadArkTool.setEnabled(True)
     self._enableArkNav(False)
     self.siteCodeCombo.clear()
     for siteCode in sorted(set(Settings.siteCodes())):
         self.siteCodeCombo.addItem(siteCode, siteCode)
     idx = self.siteCodeCombo.findData(Settings.siteCode())
     if idx >= 0:
         self.siteCodeCombo.setCurrentIndex(idx)
     self.resetContext()
Example #7
0
    def configure(self):
        wizard = ProjectWizard(self._plugin.iface.mainWindow())

        ok = wizard.exec_()

        if ok:

            if wizard.newProject():
                if Project.exists():
                    Project.write()
                Project.clear()
                projectFolderPath = os.path.join(wizard.projectFolder(), 'project')
                if not QDir(projectFolderPath).mkpath('.'):
                    return False
                projectFilePath = os.path.join(projectFolderPath, wizard.projectFilename() + '.qgs')
                Project.setFileName(projectFilePath)

            Settings.setProjectCode(wizard.project().projectCode())
            Settings.setProjectName(wizard.project().projectName())
            Settings.setSiteCode(wizard.project().siteCode())
            if not Project.title():
                Project.setTitle(wizard.project().projectCode() + ' - ' + wizard.project().projectName())

            self._initialised = Project.write()
            if self._initialised:

                # We always want the site collection
                self._addCollection('site')
                self.collection('site').loadCollection()
                # Add the Site Location if entered
                location = wizard.projectLocation()
                if not location.isEmpty():
                    siteCode = wizard.project().siteCode() if wizard.project().siteCode() else wizard.project().projectCode()
                    item = Item(siteCode, 'site', siteCode)
                    source = Source('other', item)
                    audit = Audit(Settings.userFullName(), utils.timestamp())
                    itemFeature = ItemFeature(item, 'loc', None, source, 'New Project Wizard', audit)
                    layer = self.collection('site').layer('points')
                    feature = QgsFeature(layer.pendingFields(), 0)
                    feature.setGeometry(QgsGeometry(location))
                    attributes = itemFeature.toFeature(feature)
                    layers.addFeatures([feature], layer)

                # Temp load of other collection, later do on demand
                self._addCollection('plan')
                self.collection('plan').loadCollection()
                self._addCollection('section')
                self.collection('section').loadCollection()
                self._addCollection('grid')
                self.collection('grid').loadCollection()

                # self._configureDrawing('context')
                # self._configureDrawing('plan')
                # self._configureDrawing('section')

                Settings.setProjectConfigured()

        return ok
Example #8
0
 def georeferencePlan(self, sourceFile, mode='name'):
     drawings = Config.drawings
     for drawing in drawings:
         drawings[drawing]['raw'] = Settings.drawingDir(drawing)
         drawings[drawing]['geo'] = Settings.georefDrawingDir(drawing)
         drawings[drawing]['suffix'] = '_r'
         drawings[drawing]['crs'] = self._plugin.project().crs().authid()
         drawings[drawing]['grid'] = self._plugin.project().collection('grid').layer('points')
         drawings[drawing]['local_x'] = 'local_x'
         drawings[drawing]['local_y'] = 'local_y'
     georefDialog = GeorefDialog(drawings)
     if georefDialog.loadImage(sourceFile) and georefDialog.exec_():
         self._setDrawing(georefDialog.drawing())
         self._plugin.project().loadGeoLayer(georefDialog.geoFileInfo())
Example #9
0
 def openItem(self, item):
     if not Settings.siteServerUrl():
         self._plugin.showWarningMessage('ARK link not configured, please set the ARK URL in Settings.')
     elif not self.haveItem(item):
         self._plugin.showWarningMessage('Item not in ARK.')
     else:
         mod_cd = item.classCode() + '_cd'
         item_cd = item.siteCode() + '_' + item.itemId()
         url = Settings.siteServerUrl() + '/micro_view.php?item_key=' + mod_cd + '&' + mod_cd + '=' + item_cd
         try:
             webbrowser.get().open_new_tab(url)
         except Exception:
             QApplication.clipboard().setText(url)
             self._plugin.showWarningMessage('Unable to open browser, ARK link has been copied to the clipboard')
Example #10
0
    def configure(self):
        # Configure the plugin if required
        if not Settings.isPluginConfigured():
            if not self.configurePlugin():
                return False

        if not Settings.isProjectConfigured():
            self.project().configure()

        if Settings.isProjectConfigured():
            return True

        self.showCriticalMessage('ARK Spatial not configured, unable to continue!')
        self.project().showDock(False)
        return False
Example #11
0
    def loadProject(self):
        if Settings.isProjectConfigured():
            self.projectGroupIndex = layers.createLayerGroup(self._plugin.iface, Config.projectGroupName)

            # Load the layer collections
            self._addCollection('grid')
            self._addCollection('plan')
            self._addCollection('section')
            self._addCollection('site')
            self.drawingsGroupName = Config.drawings['context']['layersGroupName']
            if (self.collection('grid').loadCollection()
                    and self.collection('plan').loadCollection()
                    and self.collection('section').loadCollection()
                    and self.collection('site').loadCollection()):

                self._dock.loadProject(self._plugin)

                if self.collection('plan').isLogged():
                    self._itemLogPath = os.path.join(self.collection('plan').projectPath,
                                                     self.collection('plan').settings.collectionPath,
                                                     'log/itemLog.csv')
                    if not QFile.exists(self._itemLogPath):
                        fd = open(self._itemLogPath, 'a')
                        fd.write('timestamp,action,siteCode,classCode,itemId\n')
                        fd.close()

                    # TODO Think of a better way...
                    # self.metadata = Metadata(self._dock.widget.sourceWidget)
                    # self.metadata.metadataChanged.connect(self.updateMapToolAttributes)
            self._initialised = True
            return True
        return False
Example #12
0
 def _loadOnlineClassIndex(self, classCode):
     if not Settings.siteServerUrl():
         return False
     if self._ark is None:
         self._createArkSession()
     if self._ark is None:
         return False
     response = self._ark.getItems(classCode + '_cd')
     if response.error:
         self._plugin.logMessage(response.url)
         self._plugin.logMessage(response.message)
         self._plugin.logMessage(response.raw)
     else:
         lst = response.data[classCode]
         items = set()
         for record in lst:
             item = Item(record['ste_cd'], classCode, record[classCode + '_no'])
             if item.isValid():
                 items.add(item)
         self.items[classCode] = sorted(items)
         self._plugin.logMessage('ARK Items ' + classCode + ' = ' + str(len(self.items[classCode])))
         if (len(self.items[classCode]) > 0):
             self._indexLoaded = True
             return True
     return False
Example #13
0
 def _loadGeoPlan(self):
     dialog = SelectDrawingDialog('context', Settings.siteCode(), True)
     if (dialog.exec_()):
         for filePath in dialog.selectedFiles():
             geoFile = QFileInfo(filePath)
             self._setDrawing(Drawing(geoFile))
             self._plugin.project().loadGeoLayer(geoFile)
Example #14
0
 def _selectProjectFolder(self):
     defaultPath = self.field("projectFolder")
     if defaultPath == '':
         defaultPath = Settings.projectsFolder()
     folderName = unicode(
         QFileDialog.getExistingDirectory(self, self.tr('Project Folder'), defaultPath)
     )
     if folderName:
         self.setField("projectFolder", folderName)
Example #15
0
 def _showItem(self, item):
     if not Settings.siteServerUrl():
         return
     self._prevItem = item
     url = ''
     if item.isValid() and self.haveItem(item):
         url = self._ark.transcludeSubformUrl(
             item.classCode() + '_cd', item.itemValue(), item.classCode() + '_apisum')
     self._dock.setItemUrl(url)
Example #16
0
 def load(self):
     if Settings.useProjectServer():
         self._ark = Ark(Settings.serverUrl(), Settings.serverUser(), Settings.serverPassword())
         projects = self._ark.getProjectList()
         self.projectCodeCombo.setMaxCount(len(projects))
         for key in utils.natsorted(projects.keys()):
             self.projectCodeCombo.addItem(projects[key], key)
     self.setProjectCode(Settings.projectCode())
     self.setProjectName(Settings.projectName())
     self.setSiteCode(Settings.siteCode())
     self.setLocation(Settings.locationEasting(), Settings.locationNorthing)
Example #17
0
 def _setDrawing(self, pmd):
     self.metadata.setSiteCode(pmd.siteCode)
     self.metadata.setClassCode(pmd.sourceClass)
     if pmd.sourceId > 0:
         self.metadata.setItemId(pmd.sourceId)
         self.metadata.setSourceId(pmd.sourceId)
     self.metadata.setSourceCode('drawing')
     self.metadata.setSourceClass(pmd.sourceClass)
     self.metadata.setSourceFile(pmd.filename)
     self.metadata.setEditor(Settings.userFullName())
Example #18
0
 def load(self):
     if Settings.useProjectServer():
         self._ark = Ark(Settings.serverUrl(), Settings.serverUser(),
                         Settings.serverPassword())
         projects = self._ark.getProjectList()
         self.projectCodeCombo.setMaxCount(len(projects))
         for key in utils.natsorted(projects.keys()):
             self.projectCodeCombo.addItem(projects[key], key)
     self.setProjectCode(Settings.projectCode())
     self.setProjectName(Settings.projectName())
     self.setSiteCode(Settings.siteCode())
     self.setLocation(Settings.locationEasting(), Settings.locationNorthing)
Example #19
0
 def _newProjectChanged(self):
     checked = self.wizard().newProjectCheck.isChecked()
     self.wizard().projectFolderEdit.setEnabled(checked)
     self.wizard().projectFolderButton.setEnabled(checked)
     self.wizard().projectFilenameEdit.setEnabled(checked)
     if checked:
         self.setField('projectFolder', self._defaultProjectFolder())
         self.setField('projectFilename', self._defaultFileName())
     else:
         self.setField('projectFolder', Settings.projectPath())
         self.setField('projectFilename', Project.fileInfo().baseName())
Example #20
0
 def loadGeoLayer(self, geoFile, zoomToLayer=True):
     # TODO Check if already loaded, remove old one?
     self.geoLayer = QgsRasterLayer(geoFile.absoluteFilePath(), geoFile.completeBaseName())
     self.geoLayer.renderer().setOpacity(Settings.drawingTransparency() / 100.0)
     QgsMapLayerRegistry.instance().addMapLayer(self.geoLayer)
     if (self.drawingsGroupIndex < 0):
         self.drawingsGroupIndex = layers.createLayerGroup(
             self._plugin.iface, self.drawingsGroupName, Config.projectGroupName)
     self._plugin.legendInterface().moveLayer(self.geoLayer, self.drawingsGroupIndex)
     if zoomToLayer:
         self._plugin.mapCanvas().setExtent(self.geoLayer.extent())
Example #21
0
 def __init__(self, parent=None):
     super(ProjectWidget, self).__init__(parent)
     self.setupUi(self)
     self._ark = None
     if Settings.useProjectServer():
         self.projectNameEdit.setEnabled(False)
         self.siteCodeEdit.setEnabled(False)
         self.locationEastingEdit.setEnabled(False)
         self.locationNorthingEdit.setEnabled(False)
         self.projectCodeCombo.setMaxVisibleItems(10)
         self.projectCodeCombo.setInsertPolicy(QComboBox.NoInsert)
         self.projectCodeCombo.currentIndexChanged.connect(self._selectProject)
Example #22
0
 def initializePage(self):
     self.registerField("newProject", self.wizard().newProjectCheck)
     self.registerField("projectFolder", self.wizard().projectFolderEdit)
     self.registerField("projectFilename", self.wizard().projectFilenameEdit)
     if Project.exists() and not Settings.isProjectConfigured():
         self.wizard().newProjectCheck.setChecked(False)
         self.wizard().newProjectCheck.setEnabled(True)
     else:
         self.wizard().newProjectCheck.setChecked(True)
         self.wizard().newProjectCheck.setEnabled(False)
     self._newProjectChanged()
     self.wizard().newProjectCheck.stateChanged.connect(self._newProjectChanged)
     self.wizard().projectFolderButton.clicked.connect(self._selectProjectFolder)
Example #23
0
 def __init__(self, parent=None):
     super(ProjectWidget, self).__init__(parent)
     self.setupUi(self)
     self._ark = None
     if Settings.useProjectServer():
         self.projectNameEdit.setEnabled(False)
         self.siteCodeEdit.setEnabled(False)
         self.locationEastingEdit.setEnabled(False)
         self.locationNorthingEdit.setEnabled(False)
         self.projectCodeCombo.setMaxVisibleItems(10)
         self.projectCodeCombo.setInsertPolicy(QComboBox.NoInsert)
         self.projectCodeCombo.currentIndexChanged.connect(
             self._selectProject)
Example #24
0
 def _getOnlineLinks(self, item, linkClassCode):
     if not Settings.siteServerUrl():
         return []
     xmi = unicode('conf_field_' + item.classCode() + linkClassCode + 'xmi')
     data = self.getItemFields(item, [xmi])
     items = []
     try:
         for link in data[xmi]:
             itemkey = link[u'xmi_itemkey']
             itemvalue = link[u'xmi_itemvalue'].split(u'_')
             item = Item(itemvalue[0], itemkey[:3], itemvalue[1])
             items.append(item)
     except Exception:
         return []
     return items
Example #25
0
 def _styleFile(self, layerPath, layerName):
     # First see if the layer itself has a default style saved
     filePath = layerPath + '/' + layerName + '.qml'
     if QFile.exists(filePath):
         return filePath
     # Next see if the layer name has a style in the styles folder (which may
     # be a special folder, the site folder or the plugin folder)
     filePath = Settings.stylePath() + '/' + layerName + '.qml'
     if QFile.exists(filePath):
         return filePath
     # Finally, check the plugin folder for the default style
     filePath = self._pluginStylesPath() + '/' + layerName + '.qml'
     if QFile.exists(filePath):
         return filePath
     # If we didn't find that then something is wrong!
     return ''
Example #26
0
 def loadDrawing(self, item, zoomToDrawing=True):
     if not Config.classCodes[item.classCode()]['drawing']:
         return
     drawingDir = Settings.georefDrawingDir(item.classCode())
     drawingDir.setFilter(QDir.Files | QDir.NoDotAndDotDot)
     name = item.name()
     nameList = []
     nameList.append(name + '.png')
     nameList.append(name + '.tif')
     nameList.append(name + '.tiff')
     nameList.append(name + '_*.png')
     nameList.append(name + '_*.tif')
     nameList.append(name + '_*.tiff')
     drawingDir.setNameFilters(nameList)
     drawings = drawingDir.entryInfoList()
     for drawing in drawings:
         self._setDrawing(Drawing(drawing))
         self._plugin.loadGeoLayer(drawing, zoomToDrawing)
Example #27
0
    def loadProject(self):
        # Load the Site Codes
        self._dock.initSiteCodes([Settings.siteCode()])

        # Load the Class Codes
        self._loadClassCodes()

        # Load the saved Filter Sets
        self._loadFilterSets()

        # Respond to ARK data load
        self._enableArkData()
        self._plugin.data().dataLoaded.connect(self._activateArkData)

        # Init the schematic filter set
        self._schematicFilterSet = FilterSet.fromSchematic(self._plugin)

        self._initialised = True
        self.setFilterSet('Default')
        return self._initialised
Example #28
0
    def __init__(self, iface, plugin, parent=None):
        super(GridWizard, self).__init__(parent)
        self._iface = iface  # QgisInterface()
        self._mapTool = None  # MapToolEmitPoint

        self.setupUi(self)
        collection = plugin.project().collection('grid')
        self.gridFolderEdit.setText(collection.settings.collectionPath)
        self.gridGroupNameEdit.setText(collection.settings.collectionGroupName)
        self.gridPointsNameEdit.setText(collection.layer('points').id())
        self.gridLinesNameEdit.setText(collection.layer('lines').id())
        self.gridPolygonsNameEdit.setText(collection.layer('polygons').id())
        self.siteCodeEdit.setText(Settings.siteCode())
        self.mapPoint1FromMapButton.clicked.connect(self.getPoint1FromMap)
        self.mapPoint2FromMapButton.clicked.connect(self.getPoint2FromMap)
        self.methodCombo.currentIndexChanged.connect(self.setMethodType)

        self._mapTool = MapToolEmitPoint(self._iface.mapCanvas())
        self._mapTool.setSnappingEnabled(True)
        self._mapTool.canvasClicked.connect(self.pointSelected)
        self._mapTool.deactivated.connect(self.cancelGetPoint)
Example #29
0
    def __init__(self, iface, plugin, parent=None):
        super(GridWizard, self).__init__(parent)
        self._iface = iface  # QgisInterface()
        self._mapTool = None  # MapToolEmitPoint

        self.setupUi(self)
        collection = plugin.project().collection('grid')
        self.gridFolderEdit.setText(collection.settings.collectionPath)
        self.gridGroupNameEdit.setText(collection.settings.collectionGroupName)
        self.gridPointsNameEdit.setText(collection.layer('points').id())
        self.gridLinesNameEdit.setText(collection.layer('lines').id())
        self.gridPolygonsNameEdit.setText(collection.layer('polygons').id())
        self.siteCodeEdit.setText(Settings.siteCode())
        self.mapPoint1FromMapButton.clicked.connect(self.getPoint1FromMap)
        self.mapPoint2FromMapButton.clicked.connect(self.getPoint2FromMap)
        self.methodCombo.currentIndexChanged.connect(self.setMethodType)

        self._mapTool = MapToolEmitPoint(self._iface.mapCanvas())
        self._mapTool.setSnappingEnabled(True)
        self._mapTool.canvasClicked.connect(self.pointSelected)
        self._mapTool.deactivated.connect(self.cancelGetPoint)
Example #30
0
    def _mergeBuffers(self, collection):
        # Check the layers are writable
        name = collection.settings.collectionGroupName
        if not collection.isWritable():
            self._plugin.showCriticalMessage(
                name + ' layers are not writable! Please correct the permissions and log out.', 0)
            return

        # Check the buffers contain valid data
        errors = self._preMergeBufferCheck(collection.buffer('points'))
        errors.extend(self._preMergeBufferCheck(collection.buffer('lines')))
        errors.extend(self._preMergeBufferCheck(collection.buffer('polygons')))
        if len(errors) > 0:
            dialog = ItemFeatureErrorDialog()
            dialog.loadErrors(errors)
            dialog.exec_()
            if not dialog.ignoreErrors():
                return

        # Update the audit attributes
        timestamp = utils.timestamp()
        user = Settings.userFullName()
        self._preMergeBufferUpdate(collection.buffer('points'), timestamp, user)
        self._preMergeBufferUpdate(collection.buffer('lines'), timestamp, user)
        self._preMergeBufferUpdate(collection.buffer('polygons'), timestamp, user)

        # Finally actually merge the data
        if collection.mergeBuffers('Merge data', timestamp):
            self._plugin.showInfoMessage(name + ' data successfully merged.')
            # TODO pass current Item...
            self._logItemAction(Item(), 'Merge Buffers', timestamp)
            # TODO Signal out layers merged for schematic dock to catch
            # if self._editSchematic:
            #     self._editSchematic = False
            #     self._dock.activateSchematicCheck()
            #     self._findContext()
        else:
            self._plugin.showCriticalMessage(
                name + ' data merge failed! Some data has not been saved, please check your data.', 5)
Example #31
0
 def _enableArkData(self, enable=True):
     if Settings.siteServerUrl():
         self._dock.enableArkData(enable)
Example #32
0
 def loadProject(self):
     # Load the Site Codes
     self._dock.initSiteCodes([Settings.siteCode()])
     return True
Example #33
0
 def _defaultFileName(self):
     if (self.field("siteCode") != ''):
         return str(self.field("siteCode")) + '_' + str(Settings.userInitials())
     else:
         return str(self.field("projectCode")) + '_' + str(Settings.userInitials())
Example #34
0
 def _defaultProjectFolder(self):
     projectFolderName = self.field("projectCode") + ' - ' + self.field("projectName")
     return os.path.join(Settings.projectsFolder(), projectFolderName, 'GIS')
    def __init__(self, item, plugin, parent=None):
        super(IdentifyItemAction, self).__init__(parent)

        self._iface = plugin.iface
        self.item = item

        self.setText(item.itemLabel())
        menu = QMenu()
        sourceSet = set()
        area = []
        haveSchematic = False
        sectionSchematics = []
        for feature in plugin.project().collection('plan').layer('polygons').getFeatures(item.featureRequest()):
            category = feature.attribute('category')
            if category == 'sch' or category == 'scs':
                haveSchematic = True
                source = Source()
                source.fromFeature(feature)
                if source.isValid():
                    sourceSet.add(source)
                if category == 'sch':
                    area.append(feature.geometry().area())
        sourceDict = {}
        for source in sourceSet:
            if source.sourceCode not in sourceDict:
                sourceDict[source.sourceCode] = set()
            sourceDict[source.sourceCode].add(source.items)
        self.zoomAction = QAction('Zoom to Item', parent)
        self.zoomAction.triggered.connect(self._zoomToItem)
        menu.addAction(self.zoomAction)
        self.panAction = QAction('Pan to Item', parent)
        self.panAction.triggered.connect(self._panToItem)
        menu.addAction(self.panAction)
        self.filterAction = QAction('Filter Item', parent)
        self.filterAction.triggered.connect(self._filterItem)
        menu.addAction(self.filterAction)
        self.excludeFilterAction = QAction('Exclude Item from Filter', parent)
        self.excludeFilterAction.triggered.connect(self._excludeFilterItem)
        menu.addAction(self.excludeFilterAction)
        self.highlightAction = QAction('Select Item', parent)
        self.highlightAction.triggered.connect(self._highlightItem)
        menu.addAction(self.highlightAction)
        self.addHighlightAction = QAction('Add Item to Selection', parent)
        self.addHighlightAction.triggereConfigd.connect(self._addHighlightItem)
        menu.addAction(self.addHighlightAction)
        if Settings.siteServerUrl():
            self.linkAction = OpenArkAction(Settimgs.siteServerUrl(), item, 'Open in ARK', parent)
            menu.addAction(self.linkAction)
        self.drawingAction = QAction('Open Drawings', parent)
        self.drawingAction.triggered.connect(self._openDrawings)
        menu.addAction(self.drawingAction)
        menu.addSeparator()
        self.editAction = QAction('Edit Item', parent)
        self.editAction.triggered.connect(self._editItem)
        menu.addAction(self.editAction)
        self.deleteAction = QAction('Delete Item', parent)
        self.deleteAction.triggered.connect(self._deleteItem)
        menu.addAction(self.deleteAction)
        menu.addSeparator()
        if len(sourceDict) > 0:
            for sourceCode in sourceDict.keys():
                menu.addAction(Config.sourceCodes[sourceCode]['label'] + ':')
                sources = sorted(sourceDict[sourceCode])
                for item in sources:
                    if item.isValid():
                        menu.addAction(item.itemLabel())
        elif haveSchematic:
            menu.addAction('Unknown Source')
        else:
            menu.addAction('No Schematic')
        if item.classCode() == 'context':
            subItem = plugin.data().parentItem(item)
            if subItem and subItem.isValid():
                menu.addSeparator()
                grpItem = plugin.data().parentItem(subItem)
                if Settings.siteServerUrl():
                    self.subAction = OpenArkAction(
                        Settings.siteServerUrl(), subItem, 'Sub-group: ' + str(subItem.itemId()), parent)
                    menu.addAction(self.subAction)
                    if grpItem:
                        self.grpAction = OpenArkAction(
                            Settings.siteServerUrl(), grpItem, 'Group: ' + str(grpItem.itemId()), parent)
                        menu.addAction(self.grpAction)
                else:
                    menu.addAction('Sub-group: ' + str(subItem.itemId()))
                    if grpItem:
                        menu.addAction('Group: ' + str(grpItem.itemId()))
        if len(area) > 0:
            menu.addSeparator()
            tot = 0
            for a in area:
                tot += a
            units = self._iface.mapCanvas().mapUnits()
            suffix = ''
            if units == QGis.Meters:
                suffix = u' m²'
            elif units == QGis.Feet:
                suffix = u' ft²'
            elif units == QGis.NauticalMiles:
                suffix = u' NM²'
            menu.addAction(ClipboardAction(u'Area: ', u'%.3f' % tot + suffix, parent))
        self.setMenu(menu)
Example #36
0
 def loadSite(self):
     self.setUrl(Settings.siteServerUrl())
     self.setUser(Settings.siteServerUser())
     self.setPassword(Settings.siteServerPassword())
Example #37
0
 def load(self):
     self.setProjectsFolder(Settings.projectsFolder())
     self.setUserFullName(Settings.userFullName())
     self.setUserInitials(Settings.userInitials())
     self.setUserOrganisation(Settings.userOrganisation())
 def loadProject(self, plugin):
     self.projectCodeEdit.setText(Settings.projectCode())
     self.siteCodeEdit.setText(Settings.siteCode())
     self.projectNameEdit.setText(Settings.projectName())
Example #39
0
 def loadProject(self, plugin):
     self.siteCodeCombo.clear()
     for siteCode in sorted(set(Settings.siteCodes())):
         self.siteCodeCombo.addItem(siteCode, siteCode)
     self.setSiteCode(Settings.siteCode())