Ejemplo n.º 1
0
        public void ReadFromXml(XmlNode node)
        {
            if (node.Attributes != null)
            {
                _name      = node.Attributes["Name"] == null ? "" : node.Attributes["Name"].Value;
                _aliasName = node.Attributes["AliasName"] == null ? "" : node.Attributes["AliasName"].Value;
                _visible   = node.Attributes["Visible"] == null
                    ? true
                    : (node.Attributes["Visible"].Value.ToUpper().StartsWith("T") ? true : false);
                _dataType = node.Attributes["DataType"] == null
                    ? enumPipelineDataType.Point
                    : EnumHelper.ConvertDataTypeFromString(node.Attributes["DataType"].Value);
                _heightType = node.Attributes["HeightType"] == null
                    ? enumPipelineHeightType.Top
                    : EnumHelper.ConvertHeightTypeFromStr(node.Attributes["HeightType"].Value);
                _validateKeys = node.Attributes["ValidateKeys"] == null ? "" : node.Attributes["ValidateKeys"].Value;
                _templateName = node.Attributes["TemplateName"] == null ? "" : node.Attributes["TemplateName"].Value;
                _autoNames    = node.Attributes["AutoNames"].Value;
            }

            XmlNodeList fieldNodes = node.SelectNodes("Fields/Field");

            foreach (XmlNode fieldNode in fieldNodes)
            {
                IYTField field = new YTField(fieldNode);
                //需要检查已有的字段定义中有没有重名的
                IYTField findField = _fields.FirstOrDefault(c => c.Name == field.Name);
                if (findField != null)
                {
                    _fields.Remove(findField);
                }
                _fields.Add(field);
            }
        }
Ejemplo n.º 2
0
        public static bool ValidateLayerGeometryType(IFeatureLayer pLayer, enumPipelineDataType pType)
        {
            esriGeometryType geometryType = pLayer.FeatureClass.ShapeType;

            switch (pType)
            {
            case enumPipelineDataType.Point:
            case enumPipelineDataType.AssPoint:
                if (geometryType == esriGeometryType.esriGeometryPoint)
                {
                    return(true);
                }
                return(false);

                break;

            case enumPipelineDataType.Line:
            case enumPipelineDataType.AssLine:
                if (geometryType == esriGeometryType.esriGeometryPolyline)
                {
                    return(true);
                }
                return(false);

                break;

            case enumPipelineDataType.Point3D:
            case enumPipelineDataType.Line3D:
                if (geometryType == esriGeometryType.esriGeometryMultiPatch)
                {
                    return(true);
                }
                if (geometryType == esriGeometryType.esriGeometryTriangles)
                {
                    return(true);
                }
                break;

            case enumPipelineDataType.AnnoPoint:
            case enumPipelineDataType.AnnoLine:
            case enumPipelineDataType.Annotation:
                if (pLayer is IGeoFeatureLayer)
                {
                    return(true);
                }
                return(false);

                break;

            case enumPipelineDataType.Other:
                return(false);

                break;

            default:
                return(false);
            }
            return(false);
        }
Ejemplo n.º 3
0
        public IPipelineLayer GetPipelineLayer(string classAliasName, enumPipelineDataType dataType)
        {
            IBasicLayerInfo layer;

            foreach (IPipelineLayer pipelineLayer in _layers)
            {
                foreach (IBasicLayerInfo basicLayer in pipelineLayer.Layers)
                {
                    if (basicLayer.AliasName.Equals(classAliasName) && basicLayer.DataType == dataType)
                    {
                        return(pipelineLayer);
                    }
                }
            }
            return(null);
        }
Ejemplo n.º 4
0
        public IPipelineLayer GetPipelineLayer(string classAliasName, enumPipelineDataType dataType)
        {
            IBasicLayerInfo layer;

            foreach (IPipelineLayer pipelineLayer in _layers)
            {
                layer =
                    pipelineLayer.Layers.FirstOrDefault(
                        c => c.FeatureClass.AliasName == classAliasName || c.EsriClassName == classAliasName);
                if (layer != null)
                {
                    if (layer.DataType == dataType)
                    {
                        return(pipelineLayer);
                    }
                }
            }
            return(null);
        }
Ejemplo n.º 5
0
        public void ReadFromXml(XmlNode xmlNode)
        {
            if (xmlNode.Attributes != null)
            {
                _name     = xmlNode.Attributes["Name"].Value;
                _caption  = xmlNode.Attributes["Caption"].Value;
                _dataType = xmlNode.Attributes["DataType"] == null
                    ? enumPipelineDataType.Point
                    : EnumHelper.ConvertDataTypeFromString(xmlNode.Attributes["DataType"].Value);
            }
            XmlNodeList nodeList =
                xmlNode.SelectNodes($"/PipelineConfig/LayerTemplates/Template[@Name='{_name}']/Fields/Field");

            foreach (XmlNode node in nodeList)
            {
                IYTField field = new YTField(node);
                _fields.Add(field);
            }
        }
Ejemplo n.º 6
0
        public static string ConvertDataTypeToString(enumPipelineDataType type)
        {
            switch (type)
            {
            case enumPipelineDataType.Point:
                return("POINT");

            case enumPipelineDataType.Line:
                return("LINE");

            case enumPipelineDataType.Network:
                return("NETWORK");

            case enumPipelineDataType.Junction:
                return("JUNCTION");

            case enumPipelineDataType.Point3D:
                return("POINT3D");

            case enumPipelineDataType.Line3D:
                return("LINE3D");

            case enumPipelineDataType.AssPoint:
                return("ASSPOINT");

            case enumPipelineDataType.AssLine:
                return("ASSLINE");

            case enumPipelineDataType.AnnoPoint:
                return("ANNOPOINT");

            case enumPipelineDataType.AnnoLine:
                return("ANNOLINE");

            case enumPipelineDataType.Annotation:
                return("ANNOTATION");

            case enumPipelineDataType.Other:
            default:
                return("OTHER");
            }
        }
Ejemplo n.º 7
0
 public BasicLayerInfo(IBasicLayerInfo info, bool keepClass)
 {
     _name         = info.Name;
     _autoNames    = info.AutoNames;
     _aliasName    = info.AliasName;
     _visible      = info.Visible;
     _dataType     = info.DataType;
     _heightType   = info.HeightType;
     _validateKeys = info.ValidateKeys;
     _templateName = info.TemplateName;
     _fields       = new List <IYTField>();
     foreach (IYTField infoField in info.Fields)
     {
         _fields.Add(infoField.Clone(keepClass));
     }
     if (keepClass)
     {
         _featureClass  = info.FeatureClass;
         _esriClassName = info.EsriClassName;
     }
 }
Ejemplo n.º 8
0
        public bool IsPipelineLayer(string classAliasName, enumPipelineDataType dataType)
        {
            IBasicLayerInfo layer;

            foreach (IPipelineLayer pipelineLayer in _layers)
            {
                try
                {
                    foreach (IBasicLayerInfo basicLayer in pipelineLayer.Layers)
                    {
                        if (basicLayer.AliasName.Equals(classAliasName) && basicLayer.DataType == dataType)
                        {
                            return(true);
                        }
                    }
                }
                catch (Exception ex)
                {
                    return(false);
                }
            }
            return(false);
        }
Ejemplo n.º 9
0
        public bool IsPipelineLayer(string classAliasName, enumPipelineDataType dataType)
        {
            IBasicLayerInfo layer;

            foreach (IPipelineLayer pipelineLayer in _layers)
            {
                try
                {
                    layer = pipelineLayer.Layers.FirstOrDefault(c => c.FeatureClass.AliasName == classAliasName);
                    if (layer != null)
                    {
                        if (layer.DataType == dataType)
                        {
                            return(true);
                        }
                    }
                }
                catch (Exception)
                {
                    return(false);
                }
            }
            return(false);
        }
Ejemplo n.º 10
0
 public List <IBasicLayerInfo> GetLayers(enumPipelineDataType dataType)
 {
     return((from c in _layers where c.DataType == dataType select c).ToList());
 }
Ejemplo n.º 11
0
        public List <IPipelineLayer> ReadLayersFromDatabase()
        {
            List <IPipelineLayer> layers = new List <IPipelineLayer>();
            ITable     pCodeTable        = _workspace.OpenTable("YT_PIPE_CODE");
            ITableSort tableSort         = new TableSortClass();

            tableSort.Table  = pCodeTable;
            tableSort.Fields = "Priority";
            tableSort.Sort(null);

            ICursor pCursor  = tableSort.Rows;
            IRow    pRow     = pCursor.NextRow();
            int     codeIdx  = pCursor.FindField("PipeCode");
            int     classIdx = pCursor.FindField("ClassCode");
            int     nameIdx  = pCursor.FindField("PipeName");
            int     autoIdx  = pCursor.FindField("AutoNames");
            int     priIdx   = pCursor.FindField("Priority");

            while (pRow != null)
            {
                IPipelineLayer oneLayer = new PipelineLayer()
                {
                    Code      = pRow.Value[codeIdx].ToString(),
                    Name      = pRow.Value[nameIdx].ToString(),
                    AutoNames = pRow.Value[autoIdx].ToString(),
                    Layers    = new List <IBasicLayerInfo>(),
                    ClassCode = pRow.Value[classIdx].ToString()
                };
                layers.Add(oneLayer);
                pRow = pCursor.NextRow();
            }
            Marshal.ReleaseComObject(pCursor);
            Marshal.ReleaseComObject(tableSort);
            Marshal.ReleaseComObject(pCodeTable);

            List <IYTDomain> domains = new List <IYTDomain>();

            pCodeTable = _workspace.OpenTable("YT_PIPE_DOMAIN");
            pCursor    = pCodeTable.Search(null, false);
            pRow       = pCursor.NextRow();
            nameIdx    = pCursor.FindField("DomainName");
            autoIdx    = pCursor.FindField("DomainValues");

            while (pRow != null)
            {
                string    domainName   = pRow.Value[nameIdx].ToString();
                string    domainValues = pRow.Value[autoIdx].ToString();
                IYTDomain onedomain    = new YTDomain(domainName, domainValues);
                domains.Add(onedomain);
                pRow = pCursor.NextRow();
            }
            Marshal.ReleaseComObject(pCursor);
            Marshal.ReleaseComObject(pCodeTable);

            List <IPipelineTemplate> templates = new List <IPipelineTemplate>();

            //! 先读取模板
            pCodeTable       = _workspace.OpenTable("YT_PIPE_FIELD");
            tableSort        = new TableSortClass();
            tableSort.Table  = pCodeTable;
            tableSort.Fields = "TemplateName";

            tableSort.Sort(null);
            pCursor = tableSort.Rows;
            string oldTemplate = "";

            int[] fieldIndexes = new int[10];
            pRow            = pCursor.NextRow();
            fieldIndexes[0] = pRow.Fields.FindField("TemplateName");
            fieldIndexes[1] = pRow.Fields.FindField("TypeName");
            fieldIndexes[2] = pRow.Fields.FindField("FieldName");
            fieldIndexes[3] = pRow.Fields.FindField("FieldAliasName");
            fieldIndexes[4] = pRow.Fields.FindField("FieldType");
            fieldIndexes[5] = pRow.Fields.FindField("FieldLength");
            fieldIndexes[6] = pRow.Fields.FindField("FieldPrecision");
            fieldIndexes[7] = pRow.Fields.FindField("AllowNull");
            fieldIndexes[8] = pRow.Fields.FindField("AutoValues");
            fieldIndexes[9] = pRow.Fields.FindField("IsKey");
            //  fieldIndexes[10] = pRow.Fields.FindField("Domains");


            IPipelineTemplate oneTemplate = null;

            while (pRow != null)
            {
                string templateName = pRow.Value[fieldIndexes[0]].ToString();
                if (!templateName.Equals(oldTemplate))
                {
                    if (oneTemplate != null)
                    {
                        templates.Add(oneTemplate);
                    }
                    oneTemplate = new PipelineTemplate()
                    {
                        Name = templateName, Fields = new List <IYTField>()
                    };
                    oldTemplate = templateName;
                }
                IYTField field = new YTField()
                {
                    TypeName  = pRow.Value[fieldIndexes[1]].ToString(),
                    Name      = pRow.Value[fieldIndexes[2]].ToString(),
                    AliasName = pRow.Value[fieldIndexes[3]].ToString(),
                    Length    = Convert.ToInt32(pRow.Value[fieldIndexes[5]].ToString()),
                    Precision = Convert.ToInt32(pRow.Value[fieldIndexes[6]].ToString()),
                    AllowNull = Convert.ToInt32(pRow.Value[fieldIndexes[7]].ToString()) == -1 ? true : false,
                    AutoNames = pRow.Value[fieldIndexes[8]].ToString(),
                    FieldType = FieldHelper.ConvertFromString(pRow.Value[fieldIndexes[4]].ToString())
                };
                oneTemplate.Fields.Add(field);
                pRow = pCursor.NextRow();
            }
            if (oneTemplate != null)
            {
                templates.Add(oneTemplate);
            }
            Marshal.ReleaseComObject(pCursor);
            Marshal.ReleaseComObject(tableSort);
            Marshal.ReleaseComObject(pCodeTable);

            List <IBasicLayerInfo> basicInfos = new List <IBasicLayerInfo>();

            pCodeTable       = _workspace.OpenTable("YT_PIPE_LAYER");
            tableSort        = new TableSortClass();
            tableSort.Table  = pCodeTable;
            tableSort.Fields = "Priority,LayerName";
            tableSort.Sort(null);
            pCursor      = tableSort.Rows;
            pRow         = pCursor.NextRow();
            fieldIndexes = new int[8];

            fieldIndexes[0] = pRow.Fields.FindField("PipeCode");
            fieldIndexes[1] = pRow.Fields.FindField("BasicName");
            fieldIndexes[2] = pRow.Fields.FindField("LayerName");
            fieldIndexes[3] = pRow.Fields.FindField("AutoNames");
            fieldIndexes[4] = pRow.Fields.FindField("Priority");
            fieldIndexes[5] = pRow.Fields.FindField("DataType");
            fieldIndexes[6] = pRow.Fields.FindField("Template");
            fieldIndexes[7] = pRow.Fields.FindField("Domains");
            while (pRow != null)
            {
                string         pipeCode = pRow.Value[fieldIndexes[0]].ToString();
                IPipelineLayer oneLayer = layers.Find(c => c.Code == pipeCode);
                if (oneLayer == null)
                {
                    pRow = pCursor.NextRow();
                    continue;
                }
                enumPipelineDataType dataType =
                    Yutai.Pipeline.Config.Helpers.EnumHelper.ConvertDataTypeFromString(
                        pRow.Value[fieldIndexes[5]].ToString().Trim());
                IBasicLayerInfo basicLayer = new BasicLayerInfo()
                {
                    Name         = pRow.Value[fieldIndexes[1]].ToString(),
                    AliasName    = pRow.Value[fieldIndexes[2]].ToString(),
                    AutoNames    = pRow.Value[fieldIndexes[3]].ToString(),
                    DataType     = dataType,
                    TemplateName = pRow.Value[fieldIndexes[6]].ToString(),
                    Fields       = new List <IYTField>()
                };
                if (pRow.Value[fieldIndexes[6]] != null)
                {
                    IPipelineTemplate template = templates.Find(c => c.Name == basicLayer.TemplateName);
                    if (template != null)
                    {
                        foreach (IYTField field in template.Fields)
                        {
                            basicLayer.Fields.Add(new YTField(field));
                        }
                    }
                }

                string domainStr = pRow.Value[fieldIndexes[7]] == DBNull.Value
                    ? string.Empty
                    : pRow.Value[fieldIndexes[7]].ToString();
                if (!string.IsNullOrEmpty(domainStr))
                {
                    //获得Domainzhi值
                    string[] domainPairs = domainStr.Split('/');
                    for (int j = 0; j < domainPairs.Length; j++)
                    {
                        string[]  domainPair = domainPairs[j].Split(':');
                        string    fieldName  = domainPair[0];
                        string    domainName = domainPair[1];
                        IYTDomain findDomain = domains.FirstOrDefault(c => c.DomainName == domainName);
                        if (findDomain != null)
                        {
                            IYTField pField = basicLayer.Fields.FirstOrDefault(c => c.TypeName == fieldName);
                            if (pField != null)
                            {
                                pField.Domain = new YTDomain(findDomain.DomainName, findDomain.DomainValues);
                            }
                        }
                    }
                }

                oneLayer.Layers.Add(basicLayer);
                pRow = pCursor.NextRow();
            }
            Marshal.ReleaseComObject(pCursor);
            Marshal.ReleaseComObject(tableSort);
            Marshal.ReleaseComObject(pCodeTable);
            return(layers);
        }