Beispiel #1
0
        private static void AddAttributes(XPathNavigator dataLayerPath, ClassifierStruct.DataLayer dataLayer, string itemId)
        {
            // Получение атрибутов и правил атрибутов
            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));

                // Получение правил атрибутов
                XPathNodeIterator attributesRulesPaths =
                    dataLayerPath.Select(
                        "./ItemRules[@item_id='" + itemId + "']/AttributeRule[@field_name='" + attribute.Field_name + "']");
                foreach (XPathNavigator attributeRulePath in attributesRulesPaths)
                {
                    if (attributeRulePath.GetAttribute("required", string.Empty) != string.Empty)
                    {
                        attribute.AttributeRules.Requried = attributeRulePath.GetAttribute("required", string.Empty);
                    }

                    //Проверка домена
                    XPathNodeIterator codeDefsPaths = attributeRulePath.Select("./CodedDomain/CodeDef");
                    foreach (XPathNavigator codeDefPath in codeDefsPaths)
                    {
                        attribute.AttributeRules.CodedDomain.Add(
                            new ClassifierStruct.DomainCodeDef(
                                codeDefPath.GetAttribute("code", string.Empty), codeDefPath.GetAttribute("name", string.Empty)));
                    }
                }

                // Добавление атрибута в DataLayer
                dataLayer.Attributes.Add(attribute);
            }
        }
Beispiel #2
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);
            }
        }
Beispiel #3
0
        /// <summary>
        /// Получить описание слоя
        /// </summary>
        /// <param name="dataLayersPaths">
        /// The data Layers Paths.
        /// </param>
        /// <param name="itemId">
        /// The item Id.
        /// </param>
        /// <returns>
        /// The <see cref="ClassifierStruct.DataLayer"/>.
        /// </returns>
        private static ClassifierStruct.DataLayer GetDataLayer(XPathNodeIterator dataLayersPaths, string itemId)
        {
            ClassifierStruct.DataLayer dataLayer = null;
            foreach (XPathNavigator dataLayerPath in dataLayersPaths)
            {
                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 (appereanceLineWeight != string.Empty && appereanceLineWeight.ToLower() != "none")
                        {
                            dataLayer.AutoCadAppearance.LineWeight = double.Parse(appereanceLineWeight, System.Globalization.CultureInfo.InvariantCulture);
                        }
                        else
                        {
                            dataLayer.AutoCadAppearance.LineWeight = double.MinValue;
                        }

                        // Получаем глобальную толщину полилинии
                        string appereanceLineWidth = appearancePath.GetAttribute("line_width", string.Empty);
                        if (string.IsNullOrEmpty(appereanceLineWidth) || string.Equals(appereanceLineWidth, "none", StringComparison.OrdinalIgnoreCase))
                        {
                            dataLayer.AutoCadAppearance.LineWidth = double.NaN;
                        }
                        else
                        {
                            dataLayer.AutoCadAppearance.LineWidth = double.Parse(appereanceLineWidth, System.Globalization.CultureInfo.InvariantCulture);
                        }
                    }
                    catch (Exception ex)
                    {
                        throw new Exception("Неправильные аттрибуты для AutoCad Appearance:" + ex.Message);
                    }
                }

                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 (textHeight == string.Empty)
                    {
                        dataLayer.AutoCadAnnotation.TextHeight = double.MinValue;
                    }
                    else
                    {
                        dataLayer.AutoCadAnnotation.TextHeight = double.Parse(
                            annotationPath.GetAttribute("text_height", string.Empty), System.Globalization.CultureInfo.InvariantCulture);
                    }
                }

                AddAttributes(dataLayerPath, dataLayer, itemId);
            }

            return(dataLayer);
        }