示例#1
0
文件: core.py 项目: lelou6666/PySOL
    def openInGoogleEarth(self):
        item = self._currentDatasetItem()

        if item is None:
            logging.info('no item selected.')
            QtGui.QMessageBox.information(self.app, self.tr('Information'),
                                          self.tr('No item selected.'))
            return

        src = item.filename
        prefix = os.path.splitext(os.path.basename(src))[0]
        prefix = 'gsdview_ras2vec_%s_' % prefix
        _, dst = tempfile.mkstemp('.kml', prefix)

        try:
            ras2vec.export_raster(src, dst, boxlayer='box', gcplayer='GCPs',
                                  mark_corners=True)
        except (OSError, RuntimeError):
            # @TODO: QtGui.QMessageBox.error(...)
            logging.error('unable to export "%s" to "%s".' % (src, dst))

        #success = QtCore.QProcess.startDetached(self.googleearth, [dst])
        logging.info('GoogleEarth: %s' % self.googleearth)
        logging.info('KML: %s' % dst)
        success = QtCore.QProcess.startDetached('sh', [self.googleearth, dst],
            os.path.dirname(self.googleearth))
        if not success:
            logging.warning('unable to open "%s" in GoogleEarth.' % dst)
            # @TODO: check
            QtGui.QMessageBox.warning(self.app, self.tr('Warning'),
                        self.tr('Unable to open "%s" in GoogleEarth.') % dst)
示例#2
0
    def openInGoogleEarth(self):
        item = self._currentDatasetItem()

        if item is None:
            _log.info('no item selected.')
            QtWidgets.QMessageBox.information(
                self.app, self.tr('Information'),
                self.tr('No item selected.'))
            return

        src = item.filename
        prefix = os.path.splitext(os.path.basename(src))[0]
        prefix = 'gsdview_ras2vec_%s_' % prefix
        _, dst = tempfile.mkstemp('.kml', prefix)

        try:
            ras2vec.export_raster(src, dst, boxlayer='box', gcplayer='GCPs',
                                  mark_corners=True)
        except (OSError, RuntimeError):
            # @TODO: QtWidgets.QMessageBox.error(...)
            _log.error('unable to export "%s" to "%s".', src, dst)

        # success = QtCore.QProcess.startDetached(self.googleearth, [dst])
        _log.info('GoogleEarth: %s', self.googleearth)
        _log.info('KML: %s', dst)
        success = QtCore.QProcess.startDetached(
            'sh', [self.googleearth, dst], os.path.dirname(self.googleearth))
        if not success:
            _log.warning('unable to open "%s" in GoogleEarth.', dst)
            # @TODO: check
            QtWidgets.QMessageBox.warning(
                self.app, self.tr('Warning'),
                self.tr('Unable to open "%s" in GoogleEarth.') % dst)
示例#3
0
文件: core.py 项目: lelou6666/PySOL
    def exportKML(self):
        item = self._currentDatasetItem()

        if item is None:
            logging.info('no item to export.')
            QtGui.QMessageBox.information(self.app, self.tr('Information'),
                                          self.tr('No item to export.'))
            return

        src = item.filename
        filters = [
            'KML files (*.kml)',
            'All files (*)',
        ]
        target = os.path.basename(src)
        target = os.path.splitext(target)[0] + '.kml'
        target = os.path.join(utils.default_workdir(), target)

        dst, filter_ = QtGui.QFileDialog.getSaveFileNameAndFilter(
                                        self.app,
                                        self.tr('Save KML'),
                                        target,
                                        ';;'.join(filters))

        dst = str(dst)

        if dst:
            try:
                ras2vec.export_raster(src, dst, boxlayer='box',
                                      gcplayer='GCPs', mark_corners=True)
            except (OSError, RuntimeError):
                # @TODO: QtGui.QMessageBox.error(...)
                logging.error('unable to export "%s" to "%s".' % (src, dst))
示例#4
0
    def exportKML(self):
        item = self._currentDatasetItem()

        if item is None:
            _log.info('no item to export.')
            QtWidgets.QMessageBox.information(
                self.app, self.tr('Information'),
                self.tr('No item to export.'))
            return

        src = item.filename
        filters = [
            'KML files (*.kml)',
            'All files (*)',
        ]
        target = os.path.basename(src)
        target = os.path.splitext(target)[0] + '.kml'
        target = os.path.join(utils.default_workdir(), target)

        dst, filter_ = QtWidgets.QFileDialog.getSaveFileName(
            self.app, self.tr('Save KML'), target, ';;'.join(filters))

        dst = str(dst)

        if dst:
            try:
                ras2vec.export_raster(src, dst, boxlayer='box',
                                      gcplayer='GCPs', mark_corners=True)
            except (OSError, RuntimeError):
                # @TODO: QtWidgets.QMessageBox.error(...)
                _log.error('unable to export "%s" to "%s".', src, dst)