88* *
99***************************************************************************
1010"""
11-
11+ # Python imports
1212from typing import Any , Optional
1313
14+ # QGIS imports
1415from qgis import processing
1516from qgis .core import (
1617 QgsFeatureSink ,
2223 QgsProcessingParameterFeatureSink ,
2324 QgsProcessingParameterFeatureSource ,
2425)
26+ # Internal imports
27+ from ...main .vectorLayerWrapper import qgsLayerToGeoDataFrame , GeoDataFrameToQgsLayer
28+ from map2loop import ContactExtractor
2529
2630
2731class BasalContactsAlgorithm (QgsProcessingAlgorithm ):
2832 """Processing algorithm to create basal contacts."""
29-
30- INPUT = "INPUT"
31- OUTPUT = "OUTPUT"
33+
34+
35+ INPUT_GEOLOGY = 'GEOLOGY'
36+ INPUT_FAULTS = 'FAULTS'
37+ INPUT_STRATI_COLUMN = 'STRATIGRAPHIC_COLUMN'
38+ OUTPUT = "BASAL_CONTACTS"
3239
3340 def name (self ) -> str :
3441 """Return the algorithm name."""
35- return "loop: basal_contacts"
42+ return "basal_contacts"
3643
3744 def displayName (self ) -> str :
3845 """Return the algorithm display name."""
@@ -48,28 +55,64 @@ def groupId(self) -> str:
4855
4956 def initAlgorithm (self , config : Optional [dict [str , Any ]] = None ) -> None :
5057 """Initialize the algorithm parameters."""
58+
5159 self .addParameter (
5260 QgsProcessingParameterFeatureSource (
53- self .INPUT ,
54- "Geology Polygons " ,
61+ self .INPUT_GEOLOGY ,
62+ "GEOLOGY " ,
5563 [QgsProcessing .TypeVectorPolygon ],
5664 )
5765 )
66+ self .addParameter (
67+ QgsProcessingParameterFeatureSource (
68+ self .INPUT_FAULTS ,
69+ "FAULTS" ,
70+ [QgsProcessing .TypeVectorLine ],
71+ optional = True ,
72+ )
73+ )
74+
75+ self .addParameter (
76+ QgsProcessingParameterFeatureSource (
77+ self .INPUT_STRATI_COLUMN ,
78+ "STRATIGRAPHIC_COLUMN" ,
79+ [QgsProcessing .TypeVectorLine ],
80+ )
81+ )
82+
5883 self .addParameter (
5984 QgsProcessingParameterFeatureSink (
6085 self .OUTPUT ,
6186 "Basal Contacts" ,
6287 )
6388 )
64- pass
6589
6690 def processAlgorithm (
6791 self ,
6892 parameters : dict [str , Any ],
6993 context : QgsProcessingContext ,
7094 feedback : QgsProcessingFeedback ,
7195 ) -> dict [str , Any ]:
72- pass
96+
97+ geology = self .parameterAsSource (parameters , self .INPUT_GEOLOGY , context )
98+ faults = self .parameterAsSource (parameters , self .INPUT_FAULTS , context )
99+ strati_column = self .parameterAsSource (parameters , self .INPUT_STRATI_COLUMN , context )
100+
101+ geology = qgsLayerToGeoDataFrame (geology )
102+ faults = qgsLayerToGeoDataFrame (faults ) if faults else None
103+
104+ feedback .pushInfo ("Extracting Basal Contacts..." )
105+ contact_extractor = ContactExtractor (geology , faults , feedback )
106+ contact_extractor .extract_basal_contacts (strati_column )
107+
108+ basal_contacts = GeoDataFrameToQgsLayer (
109+ self ,
110+ contact_extractor .basal_contacts ,
111+ parameters = parameters ,
112+ context = context ,
113+ feedback = feedback ,
114+ )
115+ return {self .OUTPUT : basal_contacts }
73116
74117 def createInstance (self ) -> QgsProcessingAlgorithm :
75118 """Create a new instance of the algorithm."""
0 commit comments