Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 27 additions & 4 deletions m2l/processing/algorithms/extract_basal_contacts.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,17 @@ def initAlgorithm(self, config: Optional[dict[str, Any]] = None) -> None:
)
)

self.addParameter(
QgsProcessingParameterField(
'FORMATION_FIELD',
'Formation Field',
parentLayerParameterName=self.INPUT_GEOLOGY,
type=QgsProcessingParameterField.String,
defaultValue='formation',
optional=True
)
)

self.addParameter(
QgsProcessingParameterFeatureSource(
self.INPUT_FAULTS,
Expand Down Expand Up @@ -127,7 +138,14 @@ def processAlgorithm(
geology = self.parameterAsVectorLayer(parameters, self.INPUT_GEOLOGY, context)
faults = self.parameterAsVectorLayer(parameters, self.INPUT_FAULTS, context)
strati_column = self.parameterAsMatrix(parameters, self.INPUT_STRATI_COLUMN, context)
ignore_units = self.parameterAsMatrix(parameters, self.INPUT_IGNORE_UNITS, context)
ignore_units = self.parameterAsMatrix(parameters, self.INPUT_IGNORE_UNITS, context)

if not strati_column or all(isinstance(unit, str) and not unit.strip() for unit in strati_column):
raise QgsProcessingException("no stratigraphic column found")

if not ignore_units or all(isinstance(unit, str) and not unit.strip() for unit in ignore_units):
feedback.pushInfo("no units to ignore specified")

# if strati_column and strati_column.strip():
# strati_column = [unit.strip() for unit in strati_column.split(',')]
# Save stratigraphic column settings
Expand All @@ -138,10 +156,15 @@ def processAlgorithm(
ignore_settings.setValue("m2l/ignore_units", ignore_units)

unit_name_field = self.parameterAsString(parameters, 'UNIT_NAME_FIELD', context)
formation_field = self.parameterAsString(parameters, 'FORMATION_FIELD', context)

geology = qgsLayerToGeoDataFrame(geology)
mask = ~geology['Formation'].astype(str).str.strip().isin(ignore_units)
geology = geology[mask].reset_index(drop=True)
if formation_field and formation_field in geology.columns:
mask = ~geology[formation_field].astype(str).str.strip().isin(ignore_units)
geology = geology[mask].reset_index(drop=True)
feedback.pushInfo(f"filtered by formation field: {formation_field}")
else:
feedback.pushInfo(f"no formation field found: {formation_field}")

faults = qgsLayerToGeoDataFrame(faults) if faults else None
if unit_name_field != 'UNITNAME' and unit_name_field in geology.columns:
Expand All @@ -154,7 +177,7 @@ def processAlgorithm(
feedback.pushInfo("Exporting Basal Contacts Layer...")
basal_contacts = GeoDataFrameToQgsLayer(
self,
contact_extractor.basal_contacts,
basal_contacts,
parameters=parameters,
context=context,
output_key=self.OUTPUT,
Expand Down
4 changes: 2 additions & 2 deletions m2l/processing/algorithms/sorter.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ def initAlgorithm(self, config: Optional[dict[str, Any]] = None) -> None:
self.addParameter(
QgsProcessingParameterFeatureSink(
self.OUTPUT,
self.tr("Stratigraphic column"),
"Stratigraphic column",
)
)

Expand Down Expand Up @@ -177,7 +177,7 @@ def build_input_frames(layer: QgsVectorLayer, feedback) -> tuple:
(units_df, relationships_df, contacts_df, map_data)
"""
import pandas as pd
from m2l.map2loop.mapdata import MapData # adjust import path if needed
from map2loop.map2loop.mapdata import MapData # adjust import path if needed

# Example: convert the geology layer to a very small units_df
units_records = []
Expand Down