2323 QgsProcessingParameterFeatureSink ,
2424 QgsProcessingParameterFeatureSource ,
2525 QgsProcessingParameterString ,
26- QgsProcessingParameterField
26+ QgsProcessingParameterField ,
27+ QgsProcessingParameterMatrix ,
28+ QgsSettings
2729)
2830# Internal imports
2931from ...main .vectorLayerWrapper import qgsLayerToGeoDataFrame , GeoDataFrameToQgsLayer
@@ -37,6 +39,7 @@ class BasalContactsAlgorithm(QgsProcessingAlgorithm):
3739 INPUT_GEOLOGY = 'GEOLOGY'
3840 INPUT_FAULTS = 'FAULTS'
3941 INPUT_STRATI_COLUMN = 'STRATIGRAPHIC_COLUMN'
42+ INPUT_IGNORE_UNITS = 'IGNORE_UNITS'
4043 OUTPUT = "BASAL_CONTACTS"
4144
4245 def name (self ) -> str :
@@ -83,12 +86,25 @@ def initAlgorithm(self, config: Optional[dict[str, Any]] = None) -> None:
8386 optional = True ,
8487 )
8588 )
86-
89+ strati_settings = QgsSettings ()
90+ last_strati_column = strati_settings .value ("m2l/strati_column" , "" )
91+ self .addParameter (
92+ QgsProcessingParameterMatrix (
93+ name = self .INPUT_STRATI_COLUMN ,
94+ description = "Stratigraphic Order" ,
95+ headers = ["Unit" ],
96+ numberRows = 0 ,
97+ defaultValue = last_strati_column
98+ )
99+ )
100+ ignore_settings = QgsSettings ()
101+ last_ignore_units = ignore_settings .value ("m2l/ignore_units" , "" )
87102 self .addParameter (
88- QgsProcessingParameterString (
89- self .INPUT_STRATI_COLUMN ,
90- "Stratigraphic Column Names" ,
91- defaultValue = "" ,
103+ QgsProcessingParameterMatrix (
104+ self .INPUT_IGNORE_UNITS ,
105+ "Unit(s) to ignore" ,
106+ headers = ["Unit" ],
107+ defaultValue = last_ignore_units ,
92108 optional = True
93109 )
94110 )
@@ -107,25 +123,35 @@ def processAlgorithm(
107123 feedback : QgsProcessingFeedback ,
108124 ) -> dict [str , Any ]:
109125
126+ feedback .pushInfo ("Loading data..." )
110127 geology = self .parameterAsVectorLayer (parameters , self .INPUT_GEOLOGY , context )
111128 faults = self .parameterAsVectorLayer (parameters , self .INPUT_FAULTS , context )
112- strati_column = self .parameterAsString (parameters , self .INPUT_STRATI_COLUMN , context )
113-
114- if strati_column and strati_column .strip ():
115- strati_column = [unit .strip () for unit in strati_column .split (',' )]
116-
129+ strati_column = self .parameterAsMatrix (parameters , self .INPUT_STRATI_COLUMN , context )
130+ ignore_units = self .parameterAsMatrix (parameters , self .INPUT_IGNORE_UNITS , context )
131+ # if strati_column and strati_column.strip():
132+ # strati_column = [unit.strip() for unit in strati_column.split(',')]
133+ # Save stratigraphic column settings
134+ strati_column_settings = QgsSettings ()
135+ strati_column_settings .setValue ('m2l/strati_column' , strati_column )
136+
137+ ignore_settings = QgsSettings ()
138+ ignore_settings .setValue ("m2l/ignore_units" , ignore_units )
139+
117140 unit_name_field = self .parameterAsString (parameters , 'UNIT_NAME_FIELD' , context )
118141
119142 geology = qgsLayerToGeoDataFrame (geology )
120-
143+ mask = ~ geology ['Formation' ].astype (str ).str .strip ().isin (ignore_units )
144+ geology = geology [mask ].reset_index (drop = True )
145+
121146 faults = qgsLayerToGeoDataFrame (faults ) if faults else None
122147 if unit_name_field != 'UNITNAME' and unit_name_field in geology .columns :
123148 geology = geology .rename (columns = {unit_name_field : 'UNITNAME' })
124-
149+
125150 feedback .pushInfo ("Extracting Basal Contacts..." )
126151 contact_extractor = ContactExtractor (geology , faults )
127152 basal_contacts = contact_extractor .extract_basal_contacts (strati_column )
128153
154+ feedback .pushInfo ("Exporting Basal Contacts Layer..." )
129155 basal_contacts = GeoDataFrameToQgsLayer (
130156 self ,
131157 contact_extractor .basal_contacts ,
0 commit comments