Ensure Split-Generated Plan Layers Are Recognized by the Topology Checker
Summary
The topology checker (topo-check.py) only recognizes plan layers that have the plugin-specific custom property f"{PLUGIN_DIR_NAME}/layer_type" == "plan". Split-generated Innen and Außen plans from the split tool do not get this property until they are persisted via the XMAS-App to the database, so they are not available for topology validation unless they are already saved to the DB.
Steps to reproduce
- Load a plan into the project via the plan manager (
add_plan()). - Open the topology checker dialog and verify that the plan appears in the
comboBox_plans. - Use the split tool to generate Innen and Außen plans from that plan.
- Do not persist these split layers to the database (i.e. keep them only in the current QGIS project).
- Reopen or refresh the topology checker.
- Observe that the split Innen/Außen layers do not appear in the plan dropdown, and thus cannot be selected for topology checking.
What is the current behavior?
- The topology checker’s plan combobox is populated only with layers that have the custom property
f"{PLUGIN_DIR_NAME}/layer_type" == "plan". - This property is set when plans are added via the plan manager (
add_plan()). - Split-generated Innen/Außen layers do not initially receive this custom property, and therefore are not recognized as valid plans by the topology checker unless they have been persisted and reloaded as proper plan layers.
What is the expected correct behavior?
- Split-generated Innen and Außen layers that represent valid plan geometries should be selectable in the topology checker without requiring a prior DB persistence + reload cycle.
- In other words, as soon as the split operation creates these layers in the project, they should be treated like plan layers by the topology checker.
Relevant logs and/or screenshots
The relevant logic in the topology checker confirms that only layers with the plugin-specific custom property are considered:
# combobox handling
self.comboBox_plans: QComboBox = self.parent.findChild(
QComboBox, "comboBox_plans"
)
QgsProject.instance().layersAdded.connect(self.on_layers_added)
QgsProject.instance().layersWillBeRemoved.connect(self.on_layers_removed)
self.comboBox_plans.currentIndexChanged.connect(self.on_current_plan_changed)
# initial population of combobox
self.on_layers_added(list(QgsProject.instance().mapLayers().values()))
def on_layers_added(self, layers: list[QgsVectorLayer]) -> None:
"""Update combobox items when plan layers are added."""
for layer in layers:
if layer.customProperty(f"{PLUGIN_DIR_NAME}/layer_type") != "plan":
continue
plan_data = {"plan_id": layer.customProperty(f"{PLUGIN_DIR_NAME}/plan_id")}
try:
plan_name = next(layer.getFeatures())["properties"]["name"]
plan_data["qgis_layerid"] = layer.id()
self.comboBox_plans.addItem(plan_name, plan_data)
except StopIteration:
return
This shows that only layers with layer_type == "plan" are added to comboBox_plans.
Possible fixes
The simplest conceptual fix is to ensure that split-generated layers receive the same plugin-specific custom properties as regular plan layers at creation time.
Set custom properties in the split algorithm (preferred)
In the split tool, when creating the Innen and Außen QgsVectorLayer instances, immediately set:
layer.setCustomProperty(f"{PLUGIN_DIR_NAME}/layer_type", "plan")- plus any other required properties (e.g.
plan_id) so they are indistinguishable from plans loaded viaadd_plan()from the topology checker’s perspective.
This makes the split layers appear in comboBox_plans as soon as they are added to the project, without requiring persistence/reload.
Alternative (if needed, to be evaluated)
Keep the current custom-property-based filter, but define a shared helper function for marking a layer as a plan, used in both add_plan() and the split tool, to prevent divergence.
This must include a check on how plan_id is assigned and ensure consistent semantics between the original plan and its split results.
The exact property values (especially plan_id handling) and the correct location for invoking the helper need to be clarified and implemented in this ticket.
Note
A discussion is ongoing about making the topology checker editable in future iterations — e.g. offering automatic insertion of missing vertices or similar corrective actions. This ticket represents the first step toward enabling such improvements by ensuring all relevant plan layers are properly detected.