Beispiel #1
0
        public static IList <T> FindEntitys <T>(string layerName, string sql, string configName)
        {
            IFeatureCursor          pCursor  = ArcGisDao.FindDatabseCussor(layerName, sql);
            Dictionary <int, Clazz> clazzDic = ArcGisDao.GetTitleClzz <T>(pCursor.Fields, configName);

            return(ArcGisDao.GetEntity <T>(clazzDic, pCursor));
        }
Beispiel #2
0
        /// <summary>
        /// 得到字段对应的 clazzDic
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="fields"></param>
        /// <returns></returns>
        public static Dictionary <int, Clazz> GetTitleClzz(object obj, IFields fields, bool retainEditable = true)
        {
            Dictionary <string, Clazz> clazzDic = ReflectUtils.MethodToFunction(obj);

            Dictionary <String, int> filed      = ArcGisDao.FeatureTitileToDic(fields, retainEditable);
            Dictionary <int, Clazz>  titleClazz = ArcGisDao.GetTitleClzz(clazzDic, filed);

            return(titleClazz);
        }
Beispiel #3
0
        public static void SetEntity(IFeature f, string configName, object obj)
        {
            if (f == null)
            {
                return;
            }
            Dictionary <int, Clazz> clazzDic = ArcGisDao.GetTitleClzz(obj, f.Fields, configName);

            ArcGisDao.SetEntity(obj, clazzDic, f);
        }
Beispiel #4
0
        public static IList <T> FeatureToObj <T>(IList <IFeature> fs, string configName)
        {
            if (fs == null || fs.Count == 0)
            {
                return(null);
            }
            Dictionary <int, Clazz> clazzDic = ArcGisDao.GetTitleClzz <T>(fs[0].Fields, configName);

            return(ArcGisDao.GetEntity <T>(clazzDic, fs));
        }
Beispiel #5
0
        public static IList <IFeature> ObjToFeature <T>(IList <T> list, Dictionary <int, Clazz> dic)
        {
            IList <IFeature> features = new List <IFeature>();

            foreach (T t in list)
            {
                IFeature feature = (IFeature)dic[-1].GetMethodInfo.Invoke(t, null);
                if (feature == null)
                {
                    continue;
                }
                features.Add(ArcGisDao.ObjToFeature <T>(t, dic));
            }
            return(features);
        }
Beispiel #6
0
        public static IList <IFeature> ObjToFeature <T>(IList <T> list, string configName)
        {
            if (list.Count > 0)
            {
                Dictionary <string, Clazz> clazzDic = ReflectUtils.MethodToFunction <T>();
                IFeature feature = (IFeature)clazzDic["Feature"].GetMethodInfo.Invoke(list[0], null);

                IFields fs = feature.Fields;
                Dictionary <int, Clazz> dic = ArcGisDao.GetTitleClzz <T>(fs, configName);

                RemoveEditUnAble(dic, fs);
                return(ObjToFeature(list, dic));
            }
            return(null);
        }
Beispiel #7
0
        public void ExcelToShp(string path)
        {
            if (Utils.CheckFileExists(path))
            {
                string zjdShpTemplte = System.AppDomain.CurrentDomain.BaseDirectory + "ArcGisTemplete\\宅基地模板shp";
                string saveDir       = path.Substring(0, path.LastIndexOf(".")) + "SHP";
                FileUtils.CopyDir(zjdShpTemplte, saveDir, true);
                while (axMapControl.LayerCount > 0)
                {
                    axMapControl.DeleteLayer(0);
                }
                axMapControl.AddShapeFile(saveDir, "ZJD.shp");

                IFeatureLayer  featureLayer  = ArcGisUtils.GetFeatureLayer2("ZJD");
                IFeatureClass  featureClass  = featureLayer.FeatureClass;
                IWorkspaceEdit workspaceEdit = ArcGisUtils.StratEdit(featureClass);

                IFeatureCursor featureCursor = featureClass.Insert(false);
                IFeatureBuffer featureBuffer = featureClass.CreateFeatureBuffer();
                ISheet         sheet         = ExcelManager.ExcelRead.ReadExcelSheet(path, 0);

                foreach (NPOI.SS.UserModel.IRow row in sheet)
                {
                    IPointCollection pc         = new Polygon();
                    string[]         pcStrArray = row.GetCell(2).StringCellValue.Split(',');
                    foreach (string ptStr in pcStrArray)
                    {
                        string[] ptArray = ptStr.Split(':');
                        IPoint   point   = new PointClass();
                        point.PutCoords(double.Parse(ptArray[0]), double.Parse(ptArray[1]));
                        pc.AddPoint(point);
                    }
                    IPolygon polygon = ArcGisUtils.CreatePolygon(pc);
                    featureBuffer.Shape    = polygon;
                    featureBuffer.Value[3] = row.GetCell(0).StringCellValue;
                    featureBuffer.Value[4] = row.GetCell(1).StringCellValue;
                    featureCursor.InsertFeature(featureBuffer);
                }

                //IList<IFeature> list = ArcGisUtils.GetEntitysList("", "ZJD");
                ArcGisDao.EndEdit(workspaceEdit);
            }
        }
Beispiel #8
0
 /// <summary>
 /// feature 转换为 T
 /// </summary>
 /// <typeparam name="T"></typeparam>
 /// <param name="features"></param>
 /// <param name="titleDic"></param>
 /// <returns></returns>
 public static IList <T> ObjToFeature <T>(IList <IFeature> features, Dictionary <int, Clazz> titleDic)
 {
     return(ArcGisDao.GetEntity <T>(titleDic, features));
 }