-
Notifications
You must be signed in to change notification settings - Fork 13
/
Qneat3Provider.py
103 lines (85 loc) · 4.3 KB
/
Qneat3Provider.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
# -*- coding: utf-8 -*-
"""
/***************************************************************************
QNEAT3 - Qgis Network Analysis Toolbox 3
A QGIS processing provider for network analysis
Qneat3Provider.py
-------------------
begin : 2018-01-15
copyright : (C) 2018 by Clemens Raffler
email : [email protected]
***************************************************************************/
/***************************************************************************
* *
* 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. *
* *
***************************************************************************/
"""
import os
from qgis.core import QgsProcessingProvider
from qgis.PyQt.QtGui import QIcon
from importlib import util
matplotlib_specification = util.find_spec("matplotlib", "pyplot")
matplotlib_found = matplotlib_specification is not None #evaluates to true if matplotlib.pyplot can be importet
#import all algorithms that work with basic qgis modules
from .algs import (
ShortestPathBetweenPoints,
IsoAreaAsPointcloudFromPoint,
IsoAreaAsPointcloudFromLayer,
IsoAreaAsInterpolationFromPoint,
IsoAreaAsInterpolationFromLayer,
#IsoAreaAsQneatInterpolationFromPoint,
OdMatrixFromPointsAsCsv,
OdMatrixFromPointsAsLines,
OdMatrixFromPointsAsTable,
OdMatrixFromLayersAsTable,
OdMatrixFromLayersAsLines
)
#import all algorithms that require manually installed modules
if matplotlib_found:
from .algs import (
IsoAreaAsContoursFromPoint,
IsoAreaAsContoursFromLayer,
IsoAreaAsPolygonsFromPoint,
IsoAreaAsPolygonsFromLayer
)
else: #import dummy if manually installed modules are missing
from .algs import (
DummyAlgorithm
)
pluginPath = os.path.split(os.path.dirname(__file__))[0]
class Qneat3Provider(QgsProcessingProvider):
def __init__(self):
super().__init__()
self.matplotlib_specification = util.find_spec("matplotlib", "pyplot")
self.matplotlib_found = self.matplotlib_specification is not None #evaluates to true if matplotlib.pyplot can be importet
def id(self, *args, **kwargs):
return 'qneat3'
def name(self, *args, **kwargs):
return 'QNEAT3 - Qgis Network Analysis Toolbox'
def icon(self):
return QIcon(os.path.join(pluginPath, 'QNEAT3', 'icon_qneat3.svg'))
def svgIconPath(self):
return os.path.join(pluginPath, 'QNEAT3', 'icon_qneat3.svg')
def loadAlgorithms(self, *args, **kwargs):
self.addAlgorithm(ShortestPathBetweenPoints.ShortestPathBetweenPoints())
self.addAlgorithm(IsoAreaAsPointcloudFromPoint.IsoAreaAsPointcloudFromPoint())
self.addAlgorithm(IsoAreaAsPointcloudFromLayer.IsoAreaAsPointcloudFromLayer())
self.addAlgorithm(IsoAreaAsInterpolationFromPoint.IsoAreaAsInterpolationFromPoint())
self.addAlgorithm(IsoAreaAsInterpolationFromLayer.IsoAreaAsInterpolationFromLayer())
#self.addAlgorithm(IsoAreaAsQneatInterpolationFromPoint.IsoAreaAsQneatInterpolationFromPoint())
self.addAlgorithm(OdMatrixFromPointsAsCsv.OdMatrixFromPointsAsCsv())
self.addAlgorithm(OdMatrixFromPointsAsLines.OdMatrixFromPointsAsLines())
self.addAlgorithm(OdMatrixFromPointsAsTable.OdMatrixFromPointsAsTable())
self.addAlgorithm(OdMatrixFromLayersAsTable.OdMatrixFromLayersAsTable())
self.addAlgorithm(OdMatrixFromLayersAsLines.OdMatrixFromLayersAsLines())
if self.matplotlib_found:
self.addAlgorithm(IsoAreaAsContoursFromPoint.IsoAreaAsContoursFromPoint())
self.addAlgorithm(IsoAreaAsPolygonsFromPoint.IsoAreaAsPolygonsFromPoint())
self.addAlgorithm(IsoAreaAsPolygonsFromLayer.IsoAreaAsPolygonsFromLayer())
self.addAlgorithm(IsoAreaAsContoursFromLayer.IsoAreaAsContoursFromLayer())
else:
self.addAlgorithm(DummyAlgorithm.DummyAlgorithm())