Пример #1
0
    def run(self, gc, rawFile, pointFile, geoFile):
        self._step = Georeferencer.Start
        if (not gc.isValid()):
            self._signalError('Invalid ground control points.')
            return
        self._gc = gc

        if (not rawFile.exists()):
            self._signalError('Raw file not found.')
            return
        self._rawFile = rawFile

        self._pointFile = pointFile
        self._geoFile = geoFile
        if not self._geoFile.absoluteDir().exists():
            self._geoFile.absoluteDir().mkpath('.')

        if (self._debug):
            debug('Raw File: \'' + self._rawFile.absoluteFilePath() + '\'')
            debug('GCP File: \'' + self._pointFile.absoluteFilePath() + '\'')
            debug('Crop File: \'' + self._cropFile.absoluteFilePath() + '\'')
            debug('Translate File: \'' +
                  self._translateFile.absoluteFilePath() + '\'')
            debug('Geo File: \'' + self._geoFile.absoluteFilePath() + '\'')

        QCoreApplication.processEvents()
        self._runCropStep()
Пример #2
0
 def _updateArkProject(self):
     utils.debug(self.field("projectCode"))
     project = self.wizard().projectCodeCombo.itemData(self.field("projectCode"))
     data = self.ark.getProjectDetails(project)
     self._setField('projectName', data)
     self._setField('siteCode', data)
     self._setField('locationEasting', data)
     self._setField('locationNorthing', data)
Пример #3
0
    def __init__(self, parent=None):
        super(Georeferencer, self).__init__(parent)

        # Internal variables
        self._debug = True
        self._gdalDir = QDir()
        self._step = 0
        self._status = 0
        self._translate = QFileInfo()
        self._warp = QFileInfo()
        self._overview = QFileInfo()
        self._command = ''
        self._args = ''
        self._process = QProcess()
        self._gc = Transform()
        self._rawFile = QFileInfo()
        self._pointFile = QFileInfo()
        self._cropFile = QFileInfo()
        self._translateFile = QFileInfo()
        self._geoFile = QFileInfo()

        tempDir = QDir.temp()
        self._cropFile.setFile(
            tempDir.absoluteFilePath('.ark_georef_crop.png'))
        self._translateFile = QFileInfo(
            tempDir.absoluteFilePath('.ark_georef_translate.tiff'))

        self._gdalDir = QDir(self.gdalPath())
        if self._debug:
            debug('GDAL Path: ' + self._gdalDir.absolutePath())
        self._translate.setFile(self._gdalDir, 'gdal_translate')
        self._warp.setFile(self._gdalDir, 'gdalwarp')
        self._overview.setFile(self._gdalDir, 'gdaladdo')
        if (not self._translate.exists() or not self._warp.exists()
                or not self._overview.exists()):
            self._signalError(
                'GDAL commands not found, please ensure GDAL Tools plugin is installed and has correct path set!'
            )
            return

        self._process.started.connect(self._processStarted)
        self._process.finished.connect(self._processFinished)
        self._process.error.connect(self._processError)
        self._process.readyReadStandardError.connect(self._processError)
Пример #4
0
 def _runCropStep(self):
     if self._debug:
         debug('Crop')
     self._step = Georeferencer.Crop
     self._args = []
     self._command = ''
     pixmap = QPixmap(self._rawFile.absoluteFilePath())
     if pixmap.isNull():
         self._signalError('Loading of raw image failed.')
         return
     pixmap = pixmap.copy(0, 0, pixmap.width(), int(pixmap.height() * 0.84))
     image = pixmap.toImage()
     if image.isNull():
         self._signalError('Cropping of raw image failed.')
         return
     if not image.save(self._cropFile.absoluteFilePath(), 'PNG', 100):
         self._signalError('Saving of cropped image failed.')
         return
     self._signalStatus()
     self._runTranslateStep()
Пример #5
0
 def getProjectList(self):
     response = self.getItems('job_cd')
     projects = {}
     if response.error:
         utils.debug(response.url)
         utils.debug(response.message)
         utils.debug(response.raw)
     else:
         for item in response.data['job']:
             projects[item["job_cd"]] = item["job_no"]
     return projects
Пример #6
0
 def getProjectList(self):
     response = self.getItems('job_cd')
     projects = {}
     if response.error:
         utils.debug(response.url)
         utils.debug(response.message)
         utils.debug(response.raw)
     else:
         for item in response.data['job']:
             projects[item["job_cd"]] = item["job_no"]
     return projects
Пример #7
0
 def getProjectDetails(self, project):
     data = {}
     response = self.getFields(
         'job_cd',
         str(project),
         ['conf_field_job_name', 'conf_field_sitecode', 'conf_field_easting', 'conf_field_northing']
     )
     if response.error:
         utils.debug(response.url)
         utils.debug(response.message)
         utils.debug(response.raw)
     else:
         data['projectName'] = self.readFieldValue('conf_field_job_name', response.data)
         data['siteCode'] = self.readFieldValue('conf_field_sitecode', response.data)
         data['locationEasting'] = self.readFieldValue('conf_field_easting', response.data)
         data['locationNorthing'] = self.readFieldValue('conf_field_northing', response.data)
     return data
Пример #8
0
 def getProjectDetails(self, project):
     data = {}
     response = self.getFields('job_cd', str(project), [
         'conf_field_job_name', 'conf_field_sitecode', 'conf_field_easting',
         'conf_field_northing'
     ])
     if response.error:
         utils.debug(response.url)
         utils.debug(response.message)
         utils.debug(response.raw)
     else:
         data['projectName'] = self.readFieldValue('conf_field_job_name',
                                                   response.data)
         data['siteCode'] = self.readFieldValue('conf_field_sitecode',
                                                response.data)
         data['locationEasting'] = self.readFieldValue(
             'conf_field_easting', response.data)
         data['locationNorthing'] = self.readFieldValue(
             'conf_field_northing', response.data)
     return data
Пример #9
0
 def _processError(self):
     self._status = ProcessStatus.Failure
     msg = str(self._process.readAllStandardError())
     debug(msg)
     self._signalError(msg)
Пример #10
0
 def _processStarted(self):
     self._status = ProcessStatus.Running
     self._signalStatus()
     if self._debug:
         debug(self.Label[self._step])
         debug(self._command)
Пример #11
0
 def _setAttributes(self, feature, attributes):
     utils.debug(attributes)
     for key in attributes:
         feature.setAttribute(key, attributes[key])