private function convertLegends(array $properties, IMetaModel $metaModel, array $conditions): array
    {
        $result = [];
        $label  = [];
        if ($trans = $metaModel->isTranslated()) {
            foreach ($metaModel->getAvailableLanguages() as $availableLanguage) {
                $label[$availableLanguage] = $metaModel->getName();
            }
        } else {
            $label[$metaModel->getActiveLanguage()] = $metaModel->getName();
        }

        $legend = [
            'label'      => $label,
            'hide'       => false,
            'properties' => []
        ];

        $condition = function ($property) use ($conditions) {
            if (!isset($conditions[$property['id']])) {
                return null;
            }

            return [
                'type'     => 'conditionand',
                'children' => $conditions[$property['id']]
            ];
        };

        foreach ($properties as $property) {
            switch ($property['dcatype']) {
                case 'legend':
                    $this->convertLegend($property, $trans, $condition, $legend, $result);
                    break;
                case 'attribute':
                    $this->convertAttribute($property, $condition, $legend);
                    break;
                default:
                    break;
            }
        }
        if (!empty($legend['properties'])) {
            $result['legend' . (\count($result) + 1)] = $legend;
        }

        return $result;
    }