Пример #1
0
        /// <summary>
        /// Обновление информации о масштабах из заголовка классификатора
        /// </summary>
        /// <param name="classifier">
        /// The classifier.
        /// </param>
        private void UpdateScales(ClassifierStruct classifier)
        {
            XPathNodeIterator dataSetRequirements = _navigator.Select("/RNGIS_DataSet/DataSet_Requirement");

            foreach (XPathNavigator dataSetRequirement in dataSetRequirements)
            {
                string contents = dataSetRequirement.GetAttribute("contents", string.Empty);
                int    index    = contents.IndexOf(':');
                if (index < 2)
                {
                    //log.Error("Невозможно определить масштаб :" + contents);
                    continue;
                }

                string scaleContents = contents.Substring(index - 1);
                if (classifier.Scales.Contains(scaleContents))
                {
                    //log.Error("Классификатор уже содержит масштаб :" + scaleContents);
                }
                else
                {
                    classifier.Scales.Add(scaleContents);
                    classifier.ScalesDescription.Add(contents);
                }
            }
        }
Пример #2
0
        private ClassifierStruct ReadDocument(string platform)
        {
            var classifierStruct             = new ClassifierStruct();
            XPathNodeIterator classificators = _navigator.Select("//Classificator");                                    //select Classificator

            foreach (XPathNavigator classificator in classificators)
            {
                NumSection = classificator.Select("//ClassSection").Count;
                this.FillClassSections(classificator, null, classifierStruct, platform);
            }

            UpdateDataLayers(classifierStruct);
            UpdateAutocadAttributes(classifierStruct);
            UpdateScales(classifierStruct);
            return(classifierStruct);
        }
Пример #3
0
        /// <summary>
        /// Извлечь разделы ClassSection из pathSections и вставить в структуру
        /// </summary>
        /// <param name="pathSections">XML-раздел, из которого нужно извлечь ClassSections</param>
        /// <param name="parentSection">Секция верхнего уровня (родитель) для извлекаемых секций. Для первого уровня будет null.</param>
        /// <param name="classifierStruct">Структура классификатора</param>
        /// <param name="platform">Платформа (GIS или Autocad)</param>
        private void FillClassSections(XPathNavigator pathSections, ClassifierStruct.Section parentSection,
                                       ClassifierStruct classifierStruct, string platform)
        {
            XPathNodeIterator classSections = pathSections.Select("./ClassSection");                            //select ClassSection

            foreach (XPathNavigator classSection in classSections)
            {
                CurSection++;
                var section = new ClassifierStruct.Section(classSection.GetAttribute("name", string.Empty), parentSection);
                CurSectionName = section.Name;                                                                                                          //can use for show progress
                if (parentSection != null)
                {
                    parentSection.Subsections.Add(section);
                }

                classifierStruct.Sections.Add(section);

                // рекурсивно ищем вложенные секции
                this.FillClassSections(classSection, section, classifierStruct, platform);

                // заполняем ClassItems секции
                FillClassItems(classSection, section, platform);
            }
        }
Пример #4
0
        /// <summary>
        /// Дополнительные члены класса классификатора
        /// </summary>
        /// <param name="classifier">
        /// The classifier.
        /// </param>
        private void UpdateDataLayers(ClassifierStruct classifier)
        {
            XPathNodeIterator datalayersPaths = _navigator.Select("/RNGIS_DataSet/DataStorage/DataLayer");

            foreach (XPathNavigator datalayerPath in datalayersPaths)
            {
                var dataLayer = new ClassifierStruct.DataLayer(
                    datalayerPath.GetAttribute("layer_id", string.Empty),
                    datalayerPath.GetAttribute("name", string.Empty),
                    datalayerPath.GetAttribute("table_name", string.Empty),
                    datalayerPath.GetAttribute("description", string.Empty),
                    datalayerPath.GetAttribute("geom_type", string.Empty),
                    datalayerPath.GetAttribute("z_order", string.Empty),
                    datalayerPath.GetAttribute("comment", string.Empty),
                    datalayerPath.GetAttribute("status", string.Empty));

                // Получение атрибутов.
                XPathNodeIterator appearancesPaths = datalayerPath.Select("./Appearance");
                foreach (XPathNavigator appearancePath in appearancesPaths)
                {
                    try
                    {
                        dataLayer.AutoCadAppearance = new ClassifierStruct.DataLayer.AutoCadAppearanceDef();
                        string appereanceColor = appearancePath.GetAttribute("color", string.Empty);

                        if (!int.TryParse(appereanceColor, out dataLayer.AutoCadAppearance.Color))
                        {
                            dataLayer.AutoCadAppearance.Color = int.MinValue;
                        }

                        dataLayer.AutoCadAppearance.Pattern = appearancePath.GetAttribute("pattern", string.Empty);
                        string appereanceLineWeight = appearancePath.GetAttribute("line_weight", string.Empty);
                        if (string.IsNullOrEmpty(appereanceLineWeight) || string.Equals(appereanceLineWeight, "none", StringComparison.OrdinalIgnoreCase))
                        {
                            dataLayer.AutoCadAppearance.LineWeight = double.MinValue;
                        }
                        else
                        {
                            dataLayer.AutoCadAppearance.LineWeight = double.Parse(
                                appereanceLineWeight, System.Globalization.CultureInfo.InvariantCulture);
                        }
                    }
                    catch (Exception ex)
                    {
                        throw new Exception("Не правильные аттрибуты для AutoCad Appearance.", ex);
                    }
                }

                XPathNodeIterator annotationsPaths = datalayerPath.Select("./Annotation");
                foreach (XPathNavigator annotationPath in annotationsPaths)
                {
                    dataLayer.AutoCadAnnotation = new ClassifierStruct.DataLayer.AutoCadAnnotationDef();
                    string textHeight = annotationPath.GetAttribute("text_height", string.Empty);
                    if (string.IsNullOrEmpty(textHeight))
                    {
                        dataLayer.AutoCadAnnotation.TextHeight = double.MinValue;
                    }
                    else
                    {
                        dataLayer.AutoCadAnnotation.TextHeight = double.Parse(
                            annotationPath.GetAttribute("text_height", string.Empty), System.Globalization.CultureInfo.InvariantCulture);
                    }
                }

                // Мы не получаем правила для атрибутов для вспомогательного члена структуры
                XPathNodeIterator attributesLayerPaths = datalayerPath.Select("./Attribute");
                foreach (XPathNavigator attributeLayerPath in attributesLayerPaths)
                {
                    var attribute =
                        new ClassifierStruct.Attribute(
                            attributeLayerPath.GetAttribute("name", string.Empty),
                            attributeLayerPath.GetAttribute("field_name", string.Empty),
                            attributeLayerPath.GetAttribute("field_type", string.Empty),
                            attributeLayerPath.GetAttribute("comment", string.Empty),
                            attributeLayerPath.GetAttribute("status", string.Empty));

                    // Добавление атрибута в DataLayer
                    dataLayer.Attributes.Add(attribute);
                }

                // Добавление DataLayer в спомогательную стуктуру
                classifier.DataLayers.Add(dataLayer);
            }
        }
Пример #5
0
        /// <summary>
        /// Дополнительные члены класса классификатора AutoCad
        /// </summary>
        /// <param name="classifier">
        /// The classifier.
        /// </param>
        private void UpdateAutocadAttributes(ClassifierStruct classifier)
        {
            XmlNodeList xmlAttributeGroups = _xmlDocument.SelectNodes("//AttributeGroup");

            if (xmlAttributeGroups == null)
            {
                return;
            }

            foreach (XmlNode xmlAttributeGroup in xmlAttributeGroups)
            {
                var attributeGroup = new ClassifierStruct.AttributeGroup();

                var dataLayerAttributes = new List <ClassifierStruct.Attribute>();

                // Записываем аттрибуты
                XmlNodeList xmlAttributes = xmlAttributeGroup.SelectNodes("./Attribute");
                if (xmlAttributes != null)
                {
                    foreach (XmlNode xmlAttr in xmlAttributes)
                    {
                        var attribute = new ClassifierStruct.Attribute(
                            GetAttrNode(xmlAttr, "name"),
                            GetAttrNode(xmlAttr, "field_name"),
                            GetAttrNode(xmlAttr, "field_type"),
                            GetAttrNode(xmlAttr, "comment"),
                            GetAttrNode(xmlAttr, "status"));
                        //string fieldName = this.GetAttrNode(xmlAttr, "field_name");
                        dataLayerAttributes.Add(attribute);
                    }
                }

                // Записываем все классы
                XmlNodeList xmlClassItems = xmlAttributeGroup.SelectNodes(".//ClassItem");
                if (xmlClassItems != null)
                {
                    foreach (XmlNode xmlClassItem in xmlClassItems)
                    {
                        var itemAttrs = new List <ClassifierStruct.Attribute>();

                        var classItem = new ClassifierStruct.AttributeClassItem(
                            GetAttrNode(xmlClassItem, "code"), GetAttrNode(xmlClassItem, "geom_type"));

                        foreach (ClassifierStruct.Attribute attribute in dataLayerAttributes)
                        {
                            var newAttr = new ClassifierStruct.Attribute(
                                attribute.Name, attribute.Field_name, attribute.Field_type.Text, attribute.Comment, attribute.Status);

                            XmlNode attrRule = xmlClassItem.SelectSingleNode("./AttributeRule[@field_name='" + attribute.Field_name + "']");
                            if (attrRule != null && attrRule.Attributes != null)
                            {
                                if (attrRule.Attributes["required"] != null)
                                {
                                    newAttr.AttributeRules.Requried = attrRule.Attributes["required"].Value;
                                }

                                // Проверка домена
                                XmlNodeList codeDefsPaths = attrRule.SelectNodes("./CodedDomain/CodeDef");
                                if (codeDefsPaths != null)
                                {
                                    foreach (XmlNode codeDefPath in codeDefsPaths)
                                    {
                                        newAttr.AttributeRules.CodedDomain.Add(
                                            new ClassifierStruct.DomainCodeDef(
                                                GetAttrNode(codeDefPath, "code"), GetAttrNode(codeDefPath, "name")));
                                    }
                                }
                            }

                            itemAttrs.Add(newAttr);
                        }

                        classItem.Attributes = itemAttrs;
                        attributeGroup.Items.Add(classItem);
                    }
                }

                classifier.AttributeGroups.Add(attributeGroup);
            }
        }