QGIS/python/plugins/processing/algs/qgis/QgisAlgorithmProvider.py

325 lines
12 KiB
Python
Raw Normal View History

# -*- coding: utf-8 -*-
"""
***************************************************************************
QgisAlgorithmProvider.py
---------------------
Date : December 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__ = 'Victor Olaya'
__date__ = 'December 2012'
__copyright__ = '(C) 2012, Victor Olaya'
# This will get replaced with a git SHA1 when you do a git archive
__revision__ = '$Format:%H$'
import os
import warnings
try:
# importing plotly throws Python warnings from within the library - filter these out
with warnings.catch_warnings():
warnings.filterwarnings("ignore", category=ResourceWarning)
2018-06-22 14:26:55 +10:00
warnings.filterwarnings("ignore", category=ImportWarning)
import plotly # NOQA
hasPlotly = True
except:
2017-02-10 11:14:09 +02:00
hasPlotly = False
from qgis.core import (QgsApplication,
QgsProcessingProvider)
from PyQt5.QtCore import QCoreApplication
from processing.script import ScriptUtils
from .QgisAlgorithm import QgisAlgorithm
2017-06-22 18:17:56 +10:00
from .AddTableField import AddTableField
2017-05-04 13:38:14 +02:00
from .Aggregate import Aggregate
2017-06-22 18:17:56 +10:00
from .Aspect import Aspect
from .BasicStatistics import BasicStatisticsForField
from .CheckValidity import CheckValidity
from .ConcaveHull import ConcaveHull
2017-06-22 18:17:56 +10:00
from .CreateAttributeIndex import CreateAttributeIndex
from .CreateConstantRaster import CreateConstantRaster
from .Datasources2Vrt import Datasources2Vrt
2017-08-20 01:00:59 +10:00
from .DefineProjection import DefineProjection
from .Delaunay import Delaunay
2017-06-22 18:17:56 +10:00
from .DeleteColumn import DeleteColumn
from .DeleteDuplicateGeometries import DeleteDuplicateGeometries
2017-06-22 18:17:56 +10:00
from .DensifyGeometries import DensifyGeometries
2017-08-04 00:37:14 +10:00
from .EliminateSelection import EliminateSelection
2017-08-20 01:37:27 +10:00
from .ExecuteSQL import ExecuteSQL
2017-07-27 11:21:24 +10:00
from .ExportGeometryInfo import ExportGeometryInfo
2017-06-22 18:17:56 +10:00
from .ExtentFromLayer import ExtentFromLayer
from .ExtractSpecificVertices import ExtractSpecificVertices
from .FieldPyculator import FieldsPyculator
from .FieldsCalculator import FieldsCalculator
from .FieldsMapper import FieldsMapper
from .FindProjection import FindProjection
from .GeometryConvert import GeometryConvert
2017-07-20 15:25:55 +10:00
from .GeometryByExpression import GeometryByExpression
from .Grid import Grid
2017-07-12 10:22:45 +03:00
from .Heatmap import Heatmap
from .Hillshade import Hillshade
from .HubDistanceLines import HubDistanceLines
from .HubDistancePoints import HubDistancePoints
2017-08-18 15:35:27 +10:00
from .HypsometricCurves import HypsometricCurves
2017-08-19 04:03:50 +10:00
from .IdwInterpolation import IdwInterpolation
2017-06-22 18:20:14 +10:00
from .ImportIntoPostGIS import ImportIntoPostGIS
from .ImportIntoSpatialite import ImportIntoSpatialite
from .KeepNBiggestParts import KeepNBiggestParts
from .KNearestConcaveHull import KNearestConcaveHull
from .LinesToPolygons import LinesToPolygons
from .MinimumBoundingGeometry import MinimumBoundingGeometry
from .NearestNeighbourAnalysis import NearestNeighbourAnalysis
from .Orthogonalize import Orthogonalize
from .PointDistance import PointDistance
2017-07-28 12:05:05 +10:00
from .PointsAlongGeometry import PointsAlongGeometry
from .PointsDisplacement import PointsDisplacement
2017-08-09 00:24:49 +10:00
from .PointsFromLines import PointsFromLines
2017-08-09 00:17:27 +10:00
from .PointsFromPolygons import PointsFromPolygons
from .PointsInPolygon import PointsInPolygon
from .PointsLayerFromTable import PointsLayerFromTable
from .PointsToPaths import PointsToPaths
from .PoleOfInaccessibility import PoleOfInaccessibility
2017-07-27 14:56:39 +10:00
from .Polygonize import Polygonize
2017-06-22 18:20:36 +10:00
from .PostGISExecuteSQL import PostGISExecuteSQL
2018-05-28 19:05:01 +02:00
from .PostGISExecuteAndLoadSQL import PostGISExecuteAndLoadSQL
from .RandomExtract import RandomExtract
from .RandomExtractWithinSubsets import RandomExtractWithinSubsets
from .RandomPointsAlongLines import RandomPointsAlongLines
from .RandomPointsExtent import RandomPointsExtent
from .RandomPointsLayer import RandomPointsLayer
from .RandomPointsPolygons import RandomPointsPolygons
from .RandomSelection import RandomSelection
from .RandomSelectionWithinSubsets import RandomSelectionWithinSubsets
from .Rasterize import RasterizeAlgorithm
from .RasterCalculator import RasterCalculator
from .RasterLayerStatistics import RasterLayerStatistics
from .RasterSampling import RasterSampling
from .RectanglesOvalsDiamondsFixed import RectanglesOvalsDiamondsFixed
from .RectanglesOvalsDiamondsVariable import RectanglesOvalsDiamondsVariable
2017-06-22 18:20:56 +10:00
from .RegularPoints import RegularPoints
2017-08-19 00:01:58 +10:00
from .Relief import Relief
from .Ruggedness import Ruggedness
from .SelectByAttribute import SelectByAttribute
2017-06-27 13:02:20 +10:00
from .SelectByExpression import SelectByExpression
from .ServiceAreaFromLayer import ServiceAreaFromLayer
from .ServiceAreaFromPoint import ServiceAreaFromPoint
from .SetMValue import SetMValue
2017-08-19 00:30:32 +10:00
from .SetRasterStyle import SetRasterStyle
2017-08-19 00:23:25 +10:00
from .SetVectorStyle import SetVectorStyle
from .SetZValue import SetZValue
2017-07-20 14:53:02 +10:00
from .SingleSidedBuffer import SingleSidedBuffer
2017-07-14 17:46:12 +03:00
from .Slope import Slope
from .SnapGeometries import SnapGeometriesToLayer
from .SpatialiteExecuteSQL import SpatialiteExecuteSQL
from .SpatialIndex import SpatialIndex
from .SpatialJoin import SpatialJoin
from .SpatialJoinSummary import SpatialJoinSummary
from .StatisticsByCategories import StatisticsByCategories
from .SumLines import SumLines
from .TextToFloat import TextToFloat
2019-04-24 13:11:36 +02:00
from .TilesXYZ import TilesXYZ
2017-08-19 04:56:48 +10:00
from .TinInterpolation import TinInterpolation
2017-08-04 00:03:41 +10:00
from .TopoColors import TopoColor
2017-07-27 14:43:42 +10:00
from .TruncateTable import TruncateTable
from .UniqueValues import UniqueValues
from .VariableDistanceBuffer import VariableDistanceBuffer
2017-06-22 18:23:07 +10:00
from .VectorSplit import VectorSplit
from .VoronoiPolygons import VoronoiPolygons
from .ZonalStatistics import ZonalStatistics
2017-06-22 18:17:56 +10:00
pluginPath = os.path.normpath(os.path.join(
os.path.split(os.path.dirname(__file__))[0], os.pardir))
class QgisAlgorithmProvider(QgsProcessingProvider):
fieldMappingParameterName = QCoreApplication.translate('Processing', 'Fields Mapper')
def __init__(self):
super().__init__()
self.algs = []
self.externalAlgs = []
def getAlgs(self):
2017-06-06 12:36:10 +10:00
algs = [AddTableField(),
2017-05-04 13:38:14 +02:00
Aggregate(),
2017-06-06 13:41:42 +10:00
Aspect(),
2017-06-07 07:12:25 +10:00
BasicStatisticsForField(),
CheckValidity(),
ConcaveHull(),
CreateAttributeIndex(),
CreateConstantRaster(),
Datasources2Vrt(),
2017-08-20 01:00:59 +10:00
DefineProjection(),
Delaunay(),
DeleteColumn(),
DeleteDuplicateGeometries(),
DensifyGeometries(),
2017-08-04 00:37:14 +10:00
EliminateSelection(),
2017-08-20 01:37:27 +10:00
ExecuteSQL(),
2017-07-27 11:21:24 +10:00
ExportGeometryInfo(),
ExtentFromLayer(),
ExtractSpecificVertices(),
FieldsCalculator(),
FieldsMapper(),
FieldsPyculator(),
FindProjection(),
2017-07-20 15:25:55 +10:00
GeometryByExpression(),
GeometryConvert(),
Grid(),
Heatmap(),
Hillshade(),
HubDistanceLines(),
HubDistancePoints(),
2017-08-18 15:35:27 +10:00
HypsometricCurves(),
2017-08-19 04:03:50 +10:00
IdwInterpolation(),
2017-06-22 18:20:14 +10:00
ImportIntoPostGIS(),
ImportIntoSpatialite(),
KeepNBiggestParts(),
KNearestConcaveHull(),
LinesToPolygons(),
MinimumBoundingGeometry(),
NearestNeighbourAnalysis(),
Orthogonalize(),
PointDistance(),
2017-07-28 12:05:05 +10:00
PointsAlongGeometry(),
PointsDisplacement(),
2017-08-09 00:24:49 +10:00
PointsFromLines(),
2017-08-09 00:17:27 +10:00
PointsFromPolygons(),
PointsInPolygon(),
PointsLayerFromTable(),
PointsToPaths(),
PoleOfInaccessibility(),
2017-07-27 14:56:39 +10:00
Polygonize(),
2017-06-22 18:20:56 +10:00
PostGISExecuteSQL(),
2018-05-28 19:05:01 +02:00
PostGISExecuteAndLoadSQL(),
RandomExtract(),
RandomExtractWithinSubsets(),
RandomPointsAlongLines(),
RandomPointsExtent(),
RandomPointsLayer(),
RandomPointsPolygons(),
RandomSelection(),
RandomSelectionWithinSubsets(),
RasterCalculator(),
RasterizeAlgorithm(),
RasterLayerStatistics(),
RasterSampling(),
RectanglesOvalsDiamondsFixed(),
RectanglesOvalsDiamondsVariable(),
2017-06-22 18:21:16 +10:00
RegularPoints(),
2017-08-19 00:01:58 +10:00
Relief(),
Ruggedness(),
SelectByAttribute(),
2017-06-27 13:02:20 +10:00
SelectByExpression(),
ServiceAreaFromLayer(),
ServiceAreaFromPoint(),
SetMValue(),
2017-08-19 00:30:32 +10:00
SetRasterStyle(),
2017-08-19 00:23:25 +10:00
SetVectorStyle(),
SetZValue(),
2017-07-20 14:53:02 +10:00
SingleSidedBuffer(),
2017-07-14 17:46:12 +03:00
Slope(),
SnapGeometriesToLayer(),
SpatialiteExecuteSQL(),
SpatialIndex(),
SpatialJoin(),
SpatialJoinSummary(),
StatisticsByCategories(),
SumLines(),
TextToFloat(),
2019-04-24 13:11:36 +02:00
TilesXYZ(),
2017-08-19 04:56:48 +10:00
TinInterpolation(),
2017-08-04 00:03:41 +10:00
TopoColor(),
2017-07-27 14:43:42 +10:00
TruncateTable(),
UniqueValues(),
VariableDistanceBuffer(),
VectorSplit(),
VoronoiPolygons(),
ZonalStatistics()
2017-06-06 16:06:27 +10:00
]
2017-06-06 15:36:07 +10:00
if hasPlotly:
from .BarPlot import BarPlot
from .BoxPlot import BoxPlot
from .MeanAndStdDevPlot import MeanAndStdDevPlot
from .PolarPlot import PolarPlot
from .RasterLayerHistogram import RasterLayerHistogram
from .VectorLayerHistogram import VectorLayerHistogram
from .VectorLayerScatterplot import VectorLayerScatterplot
from .VectorLayerScatterplot3D import VectorLayerScatterplot3D
algs.extend([BarPlot(),
BoxPlot(),
MeanAndStdDevPlot(),
PolarPlot(),
RasterLayerHistogram(),
VectorLayerHistogram(),
VectorLayerScatterplot(),
VectorLayerScatterplot3D()])
2017-02-15 19:46:18 +02:00
# to store algs added by 3rd party plugins as scripts
#folder = os.path.join(os.path.dirname(__file__), 'scripts')
#scripts = ScriptUtils.loadFromFolder(folder)
#for script in scripts:
# script.allowEdit = False
#algs.extend(scripts)
return algs
def id(self):
return 'qgis'
def helpId(self):
return 'qgis'
def name(self):
return 'QGIS'
def icon(self):
return QgsApplication.getThemeIcon("/providerQgis.svg")
def svgIconPath(self):
return QgsApplication.iconPath("providerQgis.svg")
def loadAlgorithms(self):
self.algs = self.getAlgs()
for a in self.algs:
self.addAlgorithm(a)
for a in self.externalAlgs:
self.addAlgorithm(a)
def load(self):
success = super().load()
if success:
self.parameterTypeFieldsMapping = FieldsMapper.ParameterFieldsMappingType()
QgsApplication.instance().processingRegistry().addParameterType(self.parameterTypeFieldsMapping)
return success
def unload(self):
super().unload()
QgsApplication.instance().processingRegistry().removeParameterType(self.parameterTypeFieldsMapping)
def supportsNonFileBasedOutput(self):
return True