예제 #1
0
        /// <summary>
        /// 根据指定要素获取要素对应的图层的全部标志字段和标志值
        /// </summary>
        /// <param name="pFeature">要素</param>
        /// <param name="sArrField">全部标志字段</param>
        /// <param name="nArrValue">全部标志值</param>
        /// <returns>是否存在分层字段</returns>
        public static bool GetUniqueFieldValue(IFeature pFeature, out string[] sArrField, out string[] nArrValue)
        {
            IFeatureLayer pfLayer = GeoDbUtils.GetFeatureLayer(pFeature);

            if (pfLayer != null && GetUniqueFields(pfLayer, out sArrField) == true)
            {
                if (sArrField != null && sArrField.Length > 0)
                {
                    nArrValue = new string[sArrField.Length];
                    for (int i = 0; i < sArrField.Length; i++)
                    {
                        object o = GeoDbUtils.GetFieldValue(pFeature, sArrField[i]);
                        if (o == null)
                        {
                            nArrValue[i] = "0";
                        }
                        else
                        {
                            nArrValue[i] = o.ToString();
                        }
                    }
                    return(true);
                }
            }
            sArrField = null;
            nArrValue = null;
            return(false);
        }
예제 #2
0
        /// <summary>
        /// 判断给定标志值(e.g. 1,0)是否属于要素对应图层的标志值
        /// </summary>
        /// <param name="pFeature">要素</param>
        /// <param name="sValue">标志值</param>
        /// <returns>是否属于</returns>
        public static bool UniueValueEqual(IFeature pFeature, string sValue)
        {
            IFeatureLayer    pfLayer    = GeoDbUtils.GetFeatureLayer(pFeature);
            IGeoFeatureLayer pGeoFLayer = pfLayer as IGeoFeatureLayer;
            IFeatureRenderer pfRenderer = pGeoFLayer.Renderer;

            string[] arrsField = null;
            if (GetUniqueFields(pfLayer, out arrsField) && arrsField != null)
            {
                string[] arrsValue   = sValue.Split(',');
                int      nField      = arrsField.Length;
                string   sFieldValue = null;
                for (int i = 0; i < nField; i++)
                {
                    GeoDbUtils.GetFieldValue(pFeature, arrsField[i], ref sFieldValue);
                    if (sFieldValue != arrsValue[i])
                    {
                        return(false);
                    }
                }
            }
            return(true);
        }