# -*- coding: utf-8 -*- """ *************************************************************************** spotfiledelete.py --------------------- Date : November 2012 Copyright : (C) 2012 by Victor Olaya Email : volayaf at gmail dot com *************************************************************************** * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * *************************************************************************** """ __author__ = 'wanger' __date__ = 'November 2024' __copyright__ = '(C) 2024, wanger' import os from osgeo import ogr, gdal from PyQt5.QtGui import QIcon from PyQt5.QtWidgets import QApplication from future.moves import sys from qgis.PyQt import QtWidgets from qgis._core import QgsProcessingParameterFileDestination from qgis.core import (QgsProcessing, QgsProcessingParameterFeatureSource, QgsProcessingParameterString, QgsProcessingParameterFile, QgsProcessingParameterDateTime, QgsProcessingParameterEnum, QgsProcessingParameterCrs, QgsProcessingParameterField, QgsProcessingParameterExtent, QgsProcessingParameterBoolean, QgsProcessingParameterProviderConnection, QgsProcessingParameterDatabaseSchema, QgsProcessingParameterDatabaseTable, QgsProviderRegistry, QgsProcessingException, QgsProcessingParameterDefinition, QgsProviderConnectionException, QgsDataSourceUri) from processing.tools.requestUtils import getSpotFileList from processing.algs.gdal.GdalAlgorithm import GdalAlgorithm from processing.algs.gdal.GdalUtils import GdalUtils from processing.tools.PrintUtils import printStr from processing.tools.StringUtils import getConnectionStr from processing.tools.GeoServer.Geoserver import Geoserver from processing.tools.PostgreSQL.PostgreSQL import PostgreSQL from processing.tools.system import isWindows pluginPath = os.path.normpath(os.path.join( os.path.split(os.path.dirname(__file__))[0], os.pardir)) gdal.SetConfigOption("GDAL_FILENAME_IS_UTF8", "YES") gdal.SetConfigOption("SHAPE_ENCODING", "GBK") class SpotfileDelete(GdalAlgorithm): LOGIN_USER = "admin" SPOTFILEDELETE = 'SPOTFILEDELETE' SPOTFILEOUT = 'SPOTFILEOUT' spotfilelist = [] def __init__(self): super().__init__() def initAlgorithm(self, config=None): res = getSpotFileList(uploaduser=self.LOGIN_USER) self.spotfilelist = res["data"] names = [] for row in self.spotfilelist: names.append(row["name"]) self.addParameter(QgsProcessingParameterEnum(name=self.SPOTFILEDELETE, description=self.tr('图斑数据记录'), options=names)) def name(self): return 'spotfiledelete' def icon(self): return QIcon(os.path.join(pluginPath, 'images', 'dbms', 'delete.png')) def displayName(self): return self.tr('图斑数据删除') def shortDescription(self): return self.tr('图斑数据删除') def tags(self): t = self.tr('import,into,postgis,database,vector').split(',') t.extend(super().tags()) return t def group(self): return self.tr('图斑核查与传输') def groupId(self): return 'spot' # 判断数据是否为字符串 def is_string(self, var): return isinstance(var, str) def getConsoleCommands(self, parameters, context, feedback, executing=True): print(parameters) return [] def contains_keys(self, obj, keys): if isinstance(obj, dict): return all(key in obj.keys() for key in keys) elif hasattr(type(obj), '__dict__'): return all(key in obj.__dict__ for key in keys) else: raise ValueError("Invalid object type") def commandName(self): return "ogr2ogr"