2222 QgsProcessingFeedback ,
2323 QgsProcessingParameterFeatureSink ,
2424 QgsProcessingParameterFeatureSource ,
25- QgsProcessingParameterMapLayer ,
2625 QgsProcessingParameterString ,
2726 QgsProcessingParameterField ,
2827 QgsProcessingParameterMatrix ,
29- QgsVectorLayer ,
3028 QgsSettings
3129)
3230# Internal imports
@@ -51,15 +49,15 @@ def name(self) -> str:
5149
5250 def displayName (self ) -> str :
5351 """Return the algorithm display name."""
54- return "Basal Contacts"
52+ return "Loop3d: Basal Contacts"
5553
5654 def group (self ) -> str :
5755 """Return the algorithm group name."""
58- return "Contact Extractors "
56+ return "Loop3d "
5957
6058 def groupId (self ) -> str :
6159 """Return the algorithm group ID."""
62- return "Contact_Extractors "
60+ return "Loop3d "
6361
6462 def initAlgorithm (self , config : Optional [dict [str , Any ]] = None ) -> None :
6563 """Initialize the algorithm parameters."""
@@ -100,12 +98,15 @@ def initAlgorithm(self, config: Optional[dict[str, Any]] = None) -> None:
10098 optional = True ,
10199 )
102100 )
101+ strati_settings = QgsSettings ()
102+ last_strati_column = strati_settings .value ("m2l/strati_column" , "" )
103103 self .addParameter (
104- QgsProcessingParameterFeatureSource (
105- self .INPUT_STRATI_COLUMN ,
106- "Stratigraphic Order" ,
107- [QgsProcessing .TypeVector ],
108- defaultValue = 'formation' ,
104+ QgsProcessingParameterMatrix (
105+ name = self .INPUT_STRATI_COLUMN ,
106+ description = "Stratigraphic Order" ,
107+ headers = ["Unit" ],
108+ numberRows = 0 ,
109+ defaultValue = last_strati_column
109110 )
110111 )
111112 ignore_settings = QgsSettings ()
@@ -144,33 +145,34 @@ def processAlgorithm(
144145 feedback .pushInfo ("Loading data..." )
145146 geology = self .parameterAsVectorLayer (parameters , self .INPUT_GEOLOGY , context )
146147 faults = self .parameterAsVectorLayer (parameters , self .INPUT_FAULTS , context )
147- strati_column = self .parameterAsSource (parameters , self .INPUT_STRATI_COLUMN , context )
148+ strati_column = self .parameterAsMatrix (parameters , self .INPUT_STRATI_COLUMN , context )
148149 ignore_units = self .parameterAsMatrix (parameters , self .INPUT_IGNORE_UNITS , context )
149150
150-
151- if isinstance (strati_column , QgsProcessingParameterMapLayer ) :
152- raise QgsProcessingException ("Invalid stratigraphic column layer" )
153-
154- elif strati_column is not None :
155- # extract unit names from strati_column
156- field_name = "unit_name"
157- strati_order = [f [field_name ] for f in strati_column .getFeatures ()]
151+ if not strati_column or all (isinstance (unit , str ) and not unit .strip () for unit in strati_column ):
152+ raise QgsProcessingException ("no stratigraphic column found" )
158153
159154 if not ignore_units or all (isinstance (unit , str ) and not unit .strip () for unit in ignore_units ):
160155 feedback .pushInfo ("no units to ignore specified" )
156+
157+ # if strati_column and strati_column.strip():
158+ # strati_column = [unit.strip() for unit in strati_column.split(',')]
159+ # Save stratigraphic column settings
160+ strati_column_settings = QgsSettings ()
161+ strati_column_settings .setValue ('m2l/strati_column' , strati_column )
161162
162163 ignore_settings = QgsSettings ()
163164 ignore_settings .setValue ("m2l/ignore_units" , ignore_units )
164165
165166 unit_name_field = self .parameterAsString (parameters , 'UNIT_NAME_FIELD' , context )
167+ formation_field = self .parameterAsString (parameters , 'FORMATION_FIELD' , context )
166168
167169 geology = qgsLayerToGeoDataFrame (geology )
168- if unit_name_field and unit_name_field in geology .columns :
169- mask = ~ geology [unit_name_field ].astype (str ).str .strip ().isin (ignore_units )
170+ if formation_field and formation_field in geology .columns :
171+ mask = ~ geology [formation_field ].astype (str ).str .strip ().isin (ignore_units )
170172 geology = geology [mask ].reset_index (drop = True )
171- feedback .pushInfo (f"filtered by unit name field: { unit_name_field } " )
173+ feedback .pushInfo (f"filtered by formation field: { formation_field } " )
172174 else :
173- feedback .pushInfo (f"no unit name field found: { unit_name_field } " )
175+ feedback .pushInfo (f"no formation field found: { formation_field } " )
174176
175177 faults = qgsLayerToGeoDataFrame (faults ) if faults else None
176178 if unit_name_field != 'UNITNAME' and unit_name_field in geology .columns :
@@ -179,7 +181,7 @@ def processAlgorithm(
179181 feedback .pushInfo ("Extracting Basal Contacts..." )
180182 contact_extractor = ContactExtractor (geology , faults )
181183 all_contacts = contact_extractor .extract_all_contacts ()
182- basal_contacts = contact_extractor .extract_basal_contacts (strati_order )
184+ basal_contacts = contact_extractor .extract_basal_contacts (strati_column )
183185
184186 feedback .pushInfo ("Exporting Basal Contacts Layer..." )
185187 basal_contacts = GeoDataFrameToQgsLayer (
0 commit comments