Exemplo n.º 1
0
        /// <summary>
        /// 将线要素切割
        /// </summary>
        /// <param name="pFeature">被切割的线要素</param>
        /// <param name="pPoint">切割点</param>
        /// <returns>切割后的线要素</returns>
        public static IFeature SplitPolyLine(IFeature pFeature, IPoint pPoint)
        {
            IGeometry pGeometry = pFeature.Shape;

            if (((IPolyline)pGeometry).FromPoint.X == pPoint.X && ((IPolyline)pGeometry).FromPoint.Y == pPoint.Y)
            {
                return(pFeature);
            }
            if (((IPolyline)pGeometry).ToPoint.X == pPoint.X && ((IPolyline)pGeometry).ToPoint.Y == pPoint.Y)
            {
                return(pFeature);
            }
            try
            {
                IWorkspaceEdit pEditor = GeoDbUtils.InitWorkspace() as IWorkspaceEdit;
                pEditor.StartEditOperation();
                IFeatureEdit pEditFeature = pFeature as IFeatureEdit;
                ISet         pSet         = pEditFeature.Split(pPoint);
                pSet.Reset();
                IFeature pRetFeature = pSet.Next() as IFeature;
                pGeometry = pRetFeature.Shape;
                if (((IPointCollection)(IPolyline)pGeometry).PointCount == 2)
                {
                    pRetFeature = pSet.Next() as IFeature;
                }

                pEditor.StopEditOperation();
                return(pRetFeature);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
                return(null);
            }
        }
Exemplo n.º 2
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);
        }
Exemplo n.º 3
0
        /// <summary>
        /// 设置指定要素的标志值
        /// </summary>
        /// <param name="pFeature">要素</param>
        /// <param name="arrsField">标志字段</param>
        /// <param name="sValue">标志值(分隔符为',')</param>
        public static void SetUniqueValue(IFeature pFeature, string[] arrsField, string sValue)
        {
            int nField = arrsField.Length;

            if (nField > 0)
            {
                string[] arrsValue = sValue.Split(',');
                for (int i = 0; i < nField; i++)
                {
                    GeoDbUtils.SetFieldValue(pFeature, arrsField[i], arrsValue[i]);
                }
                pFeature.Store();
            }
        }
Exemplo n.º 4
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);
        }