获得图层元素的经纬度

2016-01-28 17:02:22  访问(1490) 赞(0) 踩(0)



        /// <summary>
        /// 获得图层元素的经纬度
        /// </summary>
        /// <param name="layerName"></param>
        /// <param name="dcName"></param>
        /// <returns></returns>
        public string Dev4GetLayerDataXY
            (
                string layerName,
                string dcName
            )
        {
            StringBuilder theResult =new StringBuilder();


            FeatureLayer lyr = FeatureLayerGetByName
                (
                    layerName
                );

            if (lyr == null)
            {
                throw new Exception
                    (
                        "方法:"
                        + MethodBase.GetCurrentMethod().ReflectedType.FullName
                        + " "
                        + MethodBase.GetCurrentMethod().ToString()
                        + " 发生异常:没有找到" + layerName + "图层"
                    );
            }

            Table tb = lyr.Table;

            if (tb == null)
            {
                throw new Exception
                    (
                        "方法:"
                        + MethodBase.GetCurrentMethod().ReflectedType.FullName
                        + " "
                        + MethodBase.GetCurrentMethod().ToString()
                        + " 发生异常:没有找到" + layerName + "图层对应的Table"
                    );
            }
             

            int idx = 0;

            foreach (Feature fcar in tb)
            {
                if (fcar == null)
                    continue;

                ++idx;

                theResult.AppendLine(idx.ToString() + "、" + fcar.Geometry.Centroid.x.ToString() + "/" + fcar.Geometry.Centroid.y.ToString());
            }

            return theResult.ToString();

        }


标签:获得图层元素的经纬度 

上一条:

下一条:


 

相关评论

评论加载中……
 

发表评论

类型:
内容:
  (Alt+Enter)