# -*- coding: utf-8 -*-
"""Multipart geometry checker."""
from .base import BaseChecker


class MultipartChecker(BaseChecker):
    name = "multipart"
    display_name_en = "Multipart"
    display_name_vi = "Da phan (Multipart)"

    def check(self, layer, params):
        errors = []
        for feat in layer.getFeatures():
            g = feat.geometry()
            if g and not g.isNull() and g.isMultipart():
                if g.constGet().numGeometries() > 1:
                    errors.append(g)
        return {"error_geometries": errors, "error_features": [], "details": []}

    def fix(self, input_path, output_path, params):
        """Pass through — multipart features are detected but not auto-split.

        native:multiparttosingleparts changes feature count (increases it),
        which can cause data integrity issues. User should decide manually.
        """
        import shutil
        shutil.copy2(input_path, output_path)
        return output_path
