Exemple #1
0
        /// <summary>
        /// 创建 dataPage页面,首先要传入  装载页面的容器 PageView,这个方法有缓存
        /// </summary>
        /// <param name="pLayer"></param>
        /// <returns></returns>
        public static PagerPage CreateMapDataPage(ILayer pLayer)
        {
            PagerPage page;

            if (userControlReids.TryGetValue(pLayer, out page))
            {
                for (int a = 0; a < pageView.Items.Count; a++)
                {
                    if ((pageView.Items[a] as PageViewItem).Header.Equals(pLayer.Name))
                    {
                        //pageView.SelectedIndex = a;
                        if (a != pageView.Items.Count - 1)
                        {
                            var temp = pageView.Items[a];
                            pageView.Items.RemoveAt(a);
                            pageView.Items.Add(temp);
                            pageView.SelectedIndex = pageView.Items.Count - 1;
                            //pageView.Items.Insert(0,temp);
                            // pageView.SelectedIndex = 0;
                        }
                        break;
                    }
                }
                return(page);
            }
            IList <IFeature> features = ArcGisUtils.GetFeatures(pLayer);

            page = CreateMapDataPage(pLayer, features);
            userControlReids.Add(pLayer, page);
            return(page);
        }
Exemple #2
0
        /// <summary>
        /// 设置图幅号
        /// </summary>
        /// <param name="features"></param>
        public static void SetTuFu(IFeatureLayer tufulayer, IList <IFeature> features, string filedName = "TuFu")
        {
            int index;

            if (features.Count != 0)
            {
                index = features[0].Fields.FindField(filedName);
            }
            else
            {
                return;
            }

            StringBuilder sb = new StringBuilder();

            foreach (IFeature feature in features)
            {
                IList <IFeature> tufus = ArcGisUtils.GetSeartchFeatures(tufulayer, feature.Shape, esriSpatialRelEnum.esriSpatialRelIntersects);

                TuFuOderByTuFuHao(tufus);

                for (int a = 0; a < tufus.Count; a++)
                {
                    if (a != 0)
                    {
                        sb.Append("、");
                    }
                    sb.Append(tufus[a].get_Value(3));
                }
                feature.Value[index] = sb.ToString();
                feature.Store();
                sb.Remove(0, sb.Length);
            }
        }
Exemple #3
0
        public static IList <JZD> GetMapJZD(string sql = "")
        {
            IFeatureLayer    jtLayer  = ArcGisUtils.GetFeatureLayer(JZDCustom.JZDLayer);
            IFeatureCursor   cur      = ArcGisUtils.GetEntitys(sql, jtLayer);
            IList <IFeature> features = ArcGisUtils.CursorToList(cur);

            return(FeatureToList(features));
        }
Exemple #4
0
        /// <summary>
        /// 将shp导出 成单个的 mxd
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void SpliceSHPToMxd_Click(object sender, ItemClickEventArgs e)
        {
            //打开map

            //得到选中的地块

            IList <IFeature> features = ArcGisUtils.GetInstance().GetSelectFeature();
            //得到模板mxd

            //导出mxd
        }
Exemple #5
0
 private static bool CheckBZPoint(IPoint pt1, IList <IFeatureLayer> layers, double radius)
 {
     foreach (IFeatureLayer layer in layers)
     {
         if (ArcGisUtils.CircleSelect(pt1, layer, radius).Count != 0)
         {
             return(false);
         }
     }
     return(true);
 }
Exemple #6
0
        /// <summary>
        /// pdf转换
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void Button_Click_2(object sender, RoutedEventArgs e)
        {
            IList <string> mxdPaths = ListView.DataContext as IList <string>;

            if (MyUtils.Utils.CheckListExists(mxdPaths))
            {
                ArcGisUtils.ExportPDFS(mxdPaths);
            }
            else
            {
                MessageBox.Show("无数据转换!!!");
            }
        }
Exemple #7
0
        public Dictionary <string, IList <JZD> > GetMapJZDS()
        {
            Dictionary <string, IList <JZD> > dic = new Dictionary <string, IList <JZD> >();
            IList <IFeature> features             = ArcGisUtils.GetEntitysList("", JZDCustom.JZDLayer);

            if (Utils.CheckListExists(features))
            {
                IList <JZD> jzds = JZDCustom.FeatureToList(features);
                return(Utils.GetGroupDicToList("ZDNUM", jzds));
            }
            else
            {
                return(dic);
            }
        }
Exemple #8
0
        public IList <JZD> ExtractJZD_Intersectant(JTSYQ jtsyq, IList <JZD> jzds)
        {
            IFeature    feature = jtsyq.Feature;
            IList <JZD> jzds1   = ExtractJzd(jtsyq, ArcGisUtils.GetFeatureLayer(JTSYQCustom.JTSYQLayerName), ArcGisUtils.GetFeatureLayer(JZDCustom.JZDLayer));

            foreach (JZD jzd in jzds1)
            {
                jzd.ZDNUM         = jtsyq.BM;
                jzd.JTSYQOBJECTID = jtsyq.OBJECTID;
                //jzd.Feature.Shape = jzd.Point;
                //JZDCustom.SaveMap(jzd);
            }
            JZDCustom.SaveMap(jzds1);
            return(null);
        }
Exemple #9
0
        private void ok()
        {
            if (siziE == null || jtsyq == null)
            {
                return;
            }
            JTSYQCustom jTSYQCustom = new JTSYQCustom(jtsyq);
            Dictionary <string, IList <IFeature> > featuresDic = ArcGisUtils.GetFeatureDicByLayer(features);
            //其他集体所有权
            IList <IFeature> siziFeatures;

            if (featuresDic.TryGetValue(JTSYQCustom.JTSYQLayerName, out siziFeatures))
            {
                IList <JTSYQ> sizeJTSYQS = JTSYQCustom.FeaturesToJTSYQ(siziFeatures);
                jTSYQCustom.SetSiZi(siziE, sizeJTSYQS);
            }
            jTSYQCustom.ArcGisSave();
        }
Exemple #10
0
        private void axMapControl1_OnMouseDown(object sender, IMapControlEvents2_OnMouseDownEvent e)
        {
            IGeometry geometry;

            switch (MapMouseDownFlag)
            {
            case 3:
                IFeatureLayer tufulayer = ArcGisUtils.GetFeatureLayer("TuFu");
                if (tufulayer != null)
                {
                    IFeatureClass tufuFeatureClass = tufulayer.FeatureClass;
                    geometry = axMapControl1.TrackRectangle();
                    TuFu.CreateTuFuFeautre(geometry.Envelope, tufuFeatureClass);
                    axMapControl1.ActiveView.Refresh();
                }
                break;
            }
        }
Exemple #11
0
        /// <summary>
        /// 设置界址线标注
        /// </summary>
        /// <param name="map"></param>
        /// <param name="jzxs"></param>
        public static void SaveJZXBZMap(IMap map, IList <JZX> jzxs)
        {
            ITextSymbol        textSymbol = ArcGisUtils.CreateTextSymbol(10, "宋体");
            IGraphicsContainer pGraph     = map as IGraphicsContainer;

            foreach (JZX jzx in jzxs)
            {
                string bz = jzx.QLR + "\n" + jzx.BM;
                if (bz != null)
                {
                    bz = bz.Replace("成都高新区", "");
                    IPointCollection pc = jzx.Polyline as IPointCollection;
                    IPoint           pt = ArcGisUtils.GetPolyCore(pc);
                    var textELment      = ArcGisUtils.CreateTextElement(bz, pt, textSymbol);
                    pGraph.AddElement(textELment as IElement, 0);
                }
            }
        }
Exemple #12
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);
            }
        }
Exemple #13
0
        /// <summary>
        /// 设置多个四至
        /// </summary>
        /// <param name="features"></param>
        private void SetJTSYQSiZi(PreviewKeyDownEventArgs e)
        {
            if (CurrentJTSYQ == null)
            {
                return;
            }
            IList <IFeature> features = ArcGisUtils.GetInstance().GetSelectFeature();

            if (!MyUtils.Utils.CheckListExists(features))
            {
                return;
            }
            JTSYQCustom jTSYQCustom = new JTSYQCustom(CurrentJTSYQ);
            Dictionary <string, IList <IFeature> > featuresDic = ArcGisUtils.GetFeatureDicByLayer(features);
            //其他集体所有权
            IList <IFeature> siziFeatures;

            if (featuresDic.TryGetValue(JTSYQCustom.JTSYQLayerName, out siziFeatures))
            {
                IList <JTSYQ> siziJTSYQS = JTSYQCustom.FeaturesToJTSYQ(siziFeatures);
                if (!MyUtils.Utils.CheckListExists(siziJTSYQS))
                {
                    return;
                }
                //移除自身地块
                int count = siziJTSYQS.Count;
                for (int a = 0; a < count; a++)
                {
                    JTSYQ round = siziJTSYQS[a];
                    if (round.Feature.OID == CurrentJTSYQ.Feature.OID)
                    {
                        siziJTSYQS.RemoveAt(a);
                        count--;
                        a--;
                    }
                }
                jTSYQCustom.SetSiZi(e, siziJTSYQS);
            }

            jTSYQCustom.ArcGisSave();

            //更新显示的table中 的josn数据
        }
Exemple #14
0
        /// <summary>
        /// 表格双击
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        public override void Table_Click(object sender, MouseButtonEventArgs e)
        {
            GridControl         gridControl = sender as GridControl;
            GridColumn          column      = gridControl.CurrentColumn as GridColumn;
            MapTabDictoryCustom row         = gridControl.CurrentItem as MapTabDictoryCustom;

            if (column.VisibleIndex == objectIndex)
            {
            }
            //图形缩放
            var      obj      = gridControl.CurrentItem;
            int      objectId = (int)row.Dic["OBJECTID"];
            IFeature feature  = featureDic[objectId];

            if (pLayer.Name == JTSYQCustom.JTSYQLayerName)
            {
                MapForm.CurrentJTSYQ = JTSYQCustom.FeaturesToJTSYQ(feature);
                MapForm.CurrentJTSYQ.MapTabDictoryCustom = row;
            }
            ArcGisUtils.ExtentShp(feature, pLayer, 2);
        }
Exemple #15
0
        public static void DeleteTuFuKuang()
        {
            IFeatureLayer tufulayer = ArcGisUtils.GetFeatureLayer("TuFu");

            if (tufulayer != null)
            {
                IFeatureClass  tufuFeatureClass = tufulayer.FeatureClass;
                IFeatureCursor curs             = tufuFeatureClass.Update(new QueryFilterClass(), true);
                IFeature       feautre          = curs.NextFeature();
                while (feautre != null)
                {
                    curs.DeleteFeature();
                    feautre = curs.NextFeature();
                }
                mapForm.axMapControl1.ActiveView.Refresh();
            }
            else
            {
                MessageBox.Show("没有这个图层:TuFu");
            }
        }
Exemple #16
0
        private void FlushTuFu_Click(object sender, ItemClickEventArgs e)
        {
            AddDocument(MapFormCustom.GetInstance());
            IList <JTSYQ> jtsyqs = GetSelectJTSYQS();

            if (jtsyqs != null)
            {
                List <IFeature> list = new List <IFeature>();
                foreach (JTSYQ jtsyq in jtsyqs)
                {
                    foreach (JTSYQ child in jtsyq.GroupJTSYQ)
                    {
                        list.Add(child.Feature);
                    }
                }
                TuFu.SetTuFu(ArcGisUtils.GetFeatureLayer("TuFu"), list);
            }
            else
            {
                MessageBox.Show("你没有选择行政区");
            }
        }
Exemple #17
0
        /// <summary>
        /// 界址点近顺序编码
        /// </summary>
        /// <param name="jtsyq"></param>
        /// <param name="jzds"></param>
        /// <param name="featureLayer"></param>
        public static void SetBM(int startBH, JTSYQ jtsyq, IList <JZD> jzds, IFeatureLayer featureLayer)
        {
            if (jzds == null)
            {
                return;
            }
            //找到西北角第一点
            IPolygon pl = jtsyq.Feature.Shape as IPolygon;

            int[] fourPoint  = ArcGisUtils.GetFourPointsIndex(pl);
            int   index      = PointDiMin(fourPoint[0], jzds);
            int   startIndex = index;
            int   id         = jtsyq.OBJECTID;

            if (jzds.Count == 0)
            {
                MessageBox.Show("你选择的图中有没有界址点的,宗地是:" + jtsyq.QLR + ", 编码是:" + jtsyq.BM);
                return;
            }
            while (startIndex < jzds.Count)
            {
                JZD jzd = jzds[startIndex];
                jzd.JTSYQOBJECTID = id;
                jzd.JZDH          = startBH++;
                startIndex++;
            }
            int min = 0;

            while (min < index)
            {
                JZD jzd = jzds[min];
                jzd.JTSYQOBJECTID = id;
                jzd.JZDH          = startBH++;
                min++;
            }
            //修改
            Update(jzds);
        }
Exemple #18
0
        /// <summary>
        /// 得到图幅号
        /// </summary>
        /// <param name="ev"></param>
        /// <returns></returns>
        public static void CreateTuFuFeautre(IEnvelope ev, IFeatureClass featureClass)
        {
            IPoint pt1 = ev.UpperLeft;

            if (pt1.IsEmpty)
            {
                return;
            }
            IPoint         pt2  = ev.UpperRight;
            IPoint         pt4  = ev.LowerRight;
            IList <string> list = new List <string>();
            double         y1   = pt1.Y;
            double         y4   = pt4.Y;

            IFeatureBuffer featureBuffer = featureClass.CreateFeatureBuffer();
            IFeatureCursor cursor        = featureClass.Insert(true);
            int            index         = cursor.FindField("TuFu");

            while (y1 > y4)
            {
                double x1 = pt1.X;
                double x2 = pt2.X;
                while (x1 < x2)
                {
                    string tufu = GetTuFu(x1, y1);
                    list.Add(tufu);
                    IPointCollection pc      = GeTuPointCollection(x1, y1);
                    IPolygon         polygon = ArcGisUtils.CreatePolygon(pc);

                    featureBuffer.Shape = polygon;
                    featureBuffer.set_Value(3, tufu);
                    cursor.InsertFeature(featureBuffer);

                    x1 += 500;
                }
                y1 -= 500;
            }
        }
Exemple #19
0
        /// <summary>
        /// 增加界址点标注
        /// </summary>
        /// <param name="groupJTSYQ"></param>
        public static void SaveJZDBZMap(IMap map, IList <JZD> jzds)
        {
            ITextSymbol        textSymbol = ArcGisUtils.CreateTextSymbol(10, "宋体");
            IGraphicsContainer pGraph     = map as IGraphicsContainer;

            IList <IFeatureLayer> layers = new List <IFeatureLayer>();

            for (int a = 0; a < map.LayerCount; a++)
            {
                layers.Add(map.Layer[a] as IFeatureLayer);
            }
            foreach (JZD jzd in jzds)
            {
                string bz = "J" + jzd.JZDH;
                if (bz != null)
                {
                    IPoint       pt         = GetBZPoint(jzd, layers);
                    ITextElement textELment = ArcGisUtils.CreateTextElement(bz, pt, textSymbol);

                    pGraph.AddElement(textELment as IElement, 0);
                }
            }
        }
Exemple #20
0
        public void ExportCun_GongShiTuActions(XZDM cunXZDM, string saveDir)
        {
            //IList<JTSYQ> jtsyqs = null;
            //得到所有界址短线
            IList <JZX> jzxs = JZXCustom.SetJZX(cunXZDM.JTSYQS);

            //从中删除本村的界址短线
            for (int a = 0; a < jzxs.Count; a++)
            {
                JZX    jzx = jzxs[a];
                string str = jzx.BM.Substring(0, 12);
                if (str == cunXZDM.DJZQDM)
                {
                    jzxs.RemoveAt(a);
                    a--;
                }
            }

            string mxdPath = saveDir + "\\" + System.IO.Path.GetFileName(JTSYQCustom.JTSYQGSTMxd);
            string mdbPath = saveDir + "\\" + System.IO.Path.GetFileName(JTSYQCustom.JTSYQGSTMDB);

            //1、复制maxd
            FileUtils.CopyFile(JTSYQCustom.JTSYQGSTMxd, mxdPath);
            //2、复制数据库
            FileUtils.CopyFile(JTSYQCustom.JTSYQZDTMdb, mdbPath);

            //打开工作文件
            MapDocumentClass mapDocument = new MapDocumentClass();

            mapDocument.Open(mxdPath, "");
            AxMapControl mapControl = ArcGisUtils.axMapControl;
            IMap         map        = mapDocument.Map[0];

            mapControl.Map = map;
            //3、设置数据源,数据源是相对路径,不需要设置
            //4、复制 本村的界址线shap
            JTSYQCustom.SaveMap(cunXZDM.JTSYQS);
            //设置本村的界址点标注
            JTSYQCustom.SaveJTSYQBZMap(map, cunXZDM.JTSYQS);


            JZXCustom.SaveJZXMap(jzxs);
            JZXCustom.SaveJZXBZMap(map, jzxs);

            double scale = 100.0;

            // mapControl.Extent = JTSYQCustom.SetExtent(cunXZDM.JTSYQS);
            ArcGisUtils.axMapControl.Extent = JTSYQCustom.GetLayer().AreaOfInterest;
            double num = (double)((int)((map.MapScale + 30.0) / scale) * scale + scale);

            //mapControl.MapScale = 329;
            ArcGisUtils.ChangeMapScale(mapDocument, num);
            //5、替换文字内容,
            Dictionary <string, XMLObject> xmlObjectDic = XMLRead.XmlToObjects(JTSYQCustom.XZDM_Reflect, true);
            XMLObject xmlObject = new XMLObject {
                Column = "BLC", Deafult = "1:" + num
            };

            xmlObjectDic.Add("BLC", xmlObject);
            ArcGisService.ReplaceText(cunXZDM, xmlObjectDic, mapDocument);
            //使用的xml缓存,必须移除
            xmlObjectDic.Remove("BLC");
            //6、工程文件保留
            mapDocument.Save();
            mapDocument.Close();
            ArcGisUtils.Refresh();
        }
Exemple #21
0
        private IList <JZD> ExtractJzd(JTSYQ dk, IFeatureLayer dkLayer, IFeatureLayer jzdLayer)
        {
            IFeature         feature         = dk.Feature;
            IPolygon         polygon         = feature.Shape as IPolygon;
            IPointCollection pointCollection = polygon as IPointCollection;
            IList <JZD>      list            = new List <JZD>();

            int    num   = pointCollection.PointCount - 2;
            IPoint point = new PointClass();

            point.X = 0.0;
            point.Y = 0.0;
            IList <JTSYQ> list2  = JTSYQCustom.FeaturesToJTSYQ(ArcGisUtils.CircleSelect(pointCollection.get_Point(num), dkLayer));
            IList <JTSYQ> list3  = JTSYQCustom.FeaturesToJTSYQ(ArcGisUtils.CircleSelect(pointCollection.get_Point(0), dkLayer));
            IList <JTSYQ> entity = JTSYQCustom.FeaturesToJTSYQ(ArcGisUtils.CircleSelect(pointCollection.get_Point(1), dkLayer));

            for (int i = 0; i <= num; i++)
            {
                IPoint point2 = pointCollection.get_Point(i);
                int    num2   = list3.Count <JTSYQ>();
                bool   flag2  = num2 > list2.Count || num2 > entity.Count;
                if (flag2)
                {
                    JZD JZD = new JZD();
                    JZD.JZDIndex = i;
                    JZD.Point    = point2;
                    list.Add(JZD);
                    point = point2;
                }
                else
                {
                    bool flag3 = num2 != 1 && this.DifferentDks(list3, list2);
                    if (flag3)
                    {
                        JZD JZD = new JZD();
                        JZD.JZDIndex = i;
                        JZD.Point    = point2;
                        list.Add(JZD);
                        point = point2;
                    }
                    else
                    {
                        double num3  = ArcGisUtils.CalculateTwoPt(point2, point);
                        bool   flag4 = i == 0;
                        double num4  = -1;

                        if (flag4)
                        {
                            num4 = ArcGisUtils.Angle(point2, pointCollection.get_Point(num), pointCollection.get_Point(1));
                        }
                        else
                        {
                            bool flag5 = i == num;
                            if (flag5)
                            {
                                num4 = ArcGisUtils.Angle(point2, pointCollection.get_Point(i - 1), pointCollection.get_Point(0));
                                double num5  = ArcGisUtils.CalculateTwoPt(point2, pointCollection.get_Point(0));
                                bool   flag6 = num5 < num3;
                                if (flag6)
                                {
                                    num3 = num5;
                                }
                            }
                            else
                            {
                                num4 = ArcGisUtils.Angle(point2, pointCollection.get_Point(i - 1), pointCollection.get_Point(i + 1));
                            }
                        }

                        bool flag7 = num4 < 150;
                        if (flag7)
                        {
                            bool flag8 = num4 <130.0 || num3> 2.0;
                            if (flag8)
                            {
                                //检查与上一个
                                int count = list.Count - 1;
                                if (count >= 0)
                                {
                                    double di = ArcGisUtils.CalculateTwoPt(point2, list[count].Point);
                                    if (di > 1)

                                    {
                                        //有上一个点的话,要大于50距离才增加
                                        JZD JZD = new JZD();
                                        JZD.JZDIndex = i;
                                        JZD.Point    = point2;
                                        list.Add(JZD);
                                        point = point2;
                                    }
                                }
                                else
                                {
                                    JZD JZD = new JZD();
                                    JZD.JZDIndex = i;
                                    JZD.Point    = point2;
                                    list.Add(JZD);
                                    point = point2;
                                }
                            }
                            else
                            {
                                IList <IFeature> featureCursor = ArcGisUtils.CircleSelect(point2, jzdLayer);

                                if (Utils.CheckListExists(featureCursor))
                                {
                                    JZD JZD = new JZD();
                                    JZD.JZDIndex = i;
                                    JZD.Point    = point2;
                                    list.Add(JZD);
                                    point = point2;
                                }
                            }
                        }
                    }
                }
                list2 = list3;
                list3 = entity;
                bool flag10 = i != num;
                if (flag10)
                {
                    entity = JTSYQCustom.FeaturesToJTSYQ(ArcGisUtils.CircleSelect(pointCollection.get_Point(i + 2), dkLayer));
                }
                else
                {
                    entity = JTSYQCustom.FeaturesToJTSYQ(ArcGisUtils.CircleSelect(pointCollection.get_Point(0), dkLayer));
                }
            }

            return(list);
        }
Exemple #22
0
        private void Import(String filename = null)
        {
            var rasterFile = filename;

            if (rasterFile == null)
            {
                LandCoverTableViewModel.BufferDistance = BankModificationIndicator.BufferDistance;
                LandCoverTableViewModel.ImportStep     = false;
                var id = new LandCoverImportWindow {
                    Owner = Application.Current.MainWindow, DataContext = LandCoverTableViewModel
                };
                if (id.ShowDialog() != true)
                {
                    return;
                }
                BankModificationIndicator.BufferDistance = LandCoverTableViewModel.BufferDistance;
                var dialog = new OpenFileDialog
                {
                    Title           = "Import Land Cover GeoTIFF",
                    DefaultExt      = ".tif",
                    CheckFileExists = true
                };
                if (dialog.ShowDialog() != true)
                {
                    return;
                }
                rasterFile = dialog.FileName;
            }

            if (String.IsNullOrWhiteSpace(rasterFile))
            {
                return;
            }

            GdalConfiguration.ConfigureOgr();
            GdalConfiguration.ConfigureGdal();

            var ci = Model.EcosystemVitality.FetchIndicator <ConnectivityIndicator>();

            if (!(ci?.Reaches?.Count > 0))
            {
                MessageBox.Show(
                    "You must have reaches for the Connectivity Indicator imported in order to process the channel modification.");
                return;
            }

            var raster = Gdal.Open(rasterFile, Access.GA_ReadOnly);

            var progress = new ProgressDialog
            {
                Label           = $"Processing Channel Modification:\n{raster.GeoTiffDescription()}",
                Owner           = Application.Current.MainWindow,
                IsCancellable   = true,
                IsIndeterminate = false
            };

            var result = new Dictionary <byte, int>();

            progress.Execute((ct, p) =>
            {
                var ip          = new Progress <int>();
                var reachNumber = 0;
                var sr          = new SpatialReference(ArcGisUtils.WkidToWktxt(Model.Attributes.Wkid));

                foreach (var reach in ci.Reaches)
                {
                    var line = new Geometry(wkbGeometryType.wkbLineString);

                    line.AssignSpatialReference(sr);
                    foreach (var node in reach.Nodes)
                    {
                        line.AddPoint_2D(node.Location.Longitude, node.Location.Latitude);
                    }
                    // convert from the user specified buffer distance (in meters) to the projected buffer units. no idea how well this works in general.
                    var distance = sr.IsGeographic() == 1 ?  BankModificationIndicator.BufferDistance / 110000 * Math.Abs(Math.Cos(sr.GetAngularUnits() * reach.Nodes[0].Location.Latitude)) : BankModificationIndicator.BufferDistance / sr.GetLinearUnits();
                    GdalRasterUtils.ReadRasterRows(raster, line.Buffer(distance, 5), out var tally, ct, ip);

                    foreach (var key in tally.Keys)
                    {
                        if (!result.ContainsKey(key))
                        {
                            result[key] = 0;
                        }
                        result[key] += tally[key];
                    }

                    p.Report((int)(100.0 * reachNumber++ / ci.Reaches.Count));
                }
            });

            var message = new TextWindow
            {
                Owner = Application.Current.MainWindow,
                Text  = "Histogram of extracted data:\n" + GdalRasterUtils.DumpResult(result) +
                        "\n\n--- Raster File Details ---\n" + GdalRasterUtils.DumpDatasetInfo(raster)
            };

            message.ShowDialog();

            BankModificationIndicator.Notes = message.Text;
            var coverage = BankModificationIndicator.Coverage.Clone();

            foreach (var item in coverage)
            {
                item.Area = 0.0;
                if (item.Mapping == null)
                {
                    continue;
                }

                foreach (var map in item.Mapping)
                {
                    if (result.ContainsKey(map))
                    {
                        item.Area += result[map];
                    }
                }
            }
            var total = coverage.Sum(x => x.Area);

            for (var i = 0; i < coverage.Count; i++)
            {
                BankModificationIndicator.Coverage[i].Area = 100.0 * coverage[i].Area / total;
            }
        }
Exemple #23
0
 public static IFeatureLayer GetJZDLayer()
 {
     return(ArcGisUtils.GetFeatureLayer2(JZDLayer));
 }
Exemple #24
0
        public static IList <JZD> SearchOrCreateJZD(JTSYQ jtsyq, IFeatureLayer featureLayer)
        {
            IList <JZD>      list    = new List <JZD>();
            string           bm      = jtsyq.BM;
            IPolygon         polygon = jtsyq.Feature.Shape as IPolygon;
            IPointCollection pc      = polygon as IPointCollection;
            //减少一个收尾的 因闭合多一个点
            int max = pc.PointCount - 1;

            for (int a = 0; a < max; a++)
            {
                IPoint pt1 = pc.Point[a];

                IList <JZD> oldJZDS = JZDCustom.FeatureToList(ArcGisUtils.CircleSelect(pc.get_Point(a), featureLayer));

                if (!Utils.CheckListExists(oldJZDS))
                {
                    continue;
                }
                else if (oldJZDS.Count >= 2)
                {
                    RemoveMoreJZD(oldJZDS);
                }
                bool flag = true;
                foreach (JZD jzd in oldJZDS)
                {
                    flag = false;
                    string jzdbm = jzd.ZDNUM;
                    //如果有空编码 或者 本宗地 直接添加
                    if (Utils.IsStrNull(jzdbm) || jzdbm.Equals(bm))
                    {
                        jzd.JZDIndex = a;
                        jzd.ZDNUM    = bm;
                        bool hasJzd = true;
                        //检查重复是不有重复点
                        foreach (JZD jzd1 in list)
                        {
                            double dx = Math.Abs(pc.get_Point(a).X - (jzd1.Feature.Shape as IPoint).X);
                            if (dx < 0.01)
                            {
                                double dy = Math.Abs(pc.get_Point(a).Y - (jzd1.Feature.Shape as IPoint).Y);
                                hasJzd = false;
                                break;
                            }
                        }
                        if (hasJzd)
                        {
                            list.Add(jzd);
                        }


                        break;
                    }
                }
                if (flag)
                {
                    IPoint JTSYQJZD = pc.get_Point(a);
                    //检查完才能确定,是否有其他宗地编码,则创建
                    JZD   jzd   = new JZD();
                    Point point = new PointClass();
                    point.PutCoords(JTSYQJZD.X, JTSYQJZD.Y);
                    jzd.ZDNUM    = bm;
                    jzd.JZDIndex = a;
                    jzd.Point    = point;
                    SaveMap(jzd);
                    list.Add(jzd);
                }
            }


            return(list);
        }
Exemple #25
0
        public void ExportZu_ZhongDiTu(JTSYQ jtsyqGroup, string saveDir)
        {
            IList <JZX> jzxs    = JZXCustom.SetJZX(jtsyqGroup.GroupJTSYQ);
            string      mxdPath = saveDir + "\\" + System.IO.Path.GetFileName(JTSYQCustom.JTSYQZDTMxd);
            string      mdbPath = saveDir + "\\" + System.IO.Path.GetFileName(JTSYQCustom.JTSYQZDTMdb);

            //1、复制maxd
            FileUtils.CopyFile(JTSYQCustom.JTSYQZDTMxd, mxdPath);
            //2、复制数据库
            FileUtils.CopyFile(JTSYQCustom.JTSYQZDTMdb, mdbPath);
            //打开工作文件
            MapDocumentClass mapDocument = new MapDocumentClass();

            mapDocument.Open(mxdPath, "");
            AxMapControl mapControl = ArcGisUtils.axMapControl;
            IMap         map        = mapDocument.Map[0];

            mapControl.Map = map;
            //3、设置数据源,数据源是相对路径,不需要设置
            //4、复制shap

            JTSYQCustom.SaveMap(jtsyqGroup.GroupJTSYQ);
            JTSYQCustom.SaveJTSYQBZMap(map, jtsyqGroup.GroupJTSYQ);
            IList <JZD> jzds = JZDCustom.SaveMap(jtsyqGroup);

            JZXCustom.SaveJZXMap(jzxs);
            JZXCustom.SaveJZXBZMap(map, jzxs);
            JZDCustom.SaveJZDBZMap(map, jzds);

            double scale = 100.0;

            mapControl.Extent = JTSYQCustom.SetExtent(jtsyqGroup.GroupJTSYQ);

            double num = (double)((int)((map.MapScale + 30.0) / scale) * scale + scale);

            //mapControl.MapScale = 329;
            ArcGisUtils.ChangeMapScale(mapDocument, num);
            //5、替换文字内容,
            int index = 0;

            for (int a = 0; a > -1; a++)
            {
                string tufu = jtsyqGroup.TuFu;
                if (Utils.IsStrNull(tufu))
                {
                    MessageBox.Show("你还没有生成图幅号!!!:" + jtsyqGroup.QLR);
                    ArcGisUtils.Refresh();
                    return;
                }
                index = tufu.IndexOf("、", index + 1);
                if (index == -1)
                {
                    break;
                }
                if (a % 2 != 0)
                {
                    jtsyqGroup.TuFu = tufu.Insert(index + 1, "\n");
                }
            }
            Dictionary <string, XMLObject> xmlObjectDic = XMLRead.XmlToObjects(JTSYQCustom.JTSYQ_Reflect, true);
            XMLObject xmlObject = new XMLObject {
                Column = "BLC", Deafult = "1:" + num
            };

            xmlObjectDic.Add("BLC", xmlObject);
            ArcGisService.ReplaceText(jtsyqGroup, xmlObjectDic, mapDocument);
            //使用的xml缓存,必须移除
            xmlObjectDic.Remove("BLC");
            //6、工程文件保留
            mapDocument.Save();
            mapDocument.Close();
            ArcGisUtils.Refresh();
        }
Exemple #26
0
 public JTSYQDao()
 {
     arcGisUtils = ArcGisManager.ArcGisUtils.GetInstance();
 }
Exemple #27
0
        /// <summary>
        /// 设置周围的界址线
        /// </summary>
        /// <param name="jtsyqs"></param>
        public static List <JZX> SetJZX(IList <JTSYQ> jtsyqs)
        {
            List <JZX>    list        = new List <JZX>();
            IList <JTSYQ> otherJTSYQS = new List <JTSYQ>();

            foreach (JTSYQ jtsyq in jtsyqs)
            {
                IGeometry geometry = jtsyq.Feature.Shape;
                //相交的面
                IList <IFeature> intersectFeature = ArcGisUtils.GetSeartchFeatures(JTSYQCustom.GetLayer(), geometry.Envelope, esriSpatialRelEnum.esriSpatialRelIntersects);
                IList <JTSYQ>    interJTSYQS      = JTSYQCustom.FeaturesToJTSYQ(intersectFeature);
                IList <JZX>      jzxs             = new List <JZX>();
                foreach (JTSYQ inter in interJTSYQS)
                {
                    if (JTSYQHasObject(inter.OBJECTID, jtsyqs))
                    {
                        continue;
                    }
                    JZX jzx = new JZX();
                    jzx.BM            = inter.BM;
                    jzx.QLR           = inter.QLR;
                    jzx.JTSYQOBJECTID = inter.OBJECTID;
                    IEnvelope envelope = jtsyq.Feature.Shape.Envelope;

                    IPolyline pl2          = ArcGisUtils.PolygonToPolyline(inter.Feature.Shape as IPolygon);
                    IGeometry clipGeometry = ArcGisUtils.GeometryClip(pl2, ArcGisUtils.ScaleEnvelope(envelope, 1.2));
                    jzx.Polyline = clipGeometry as IPolyline;
                    jzxs.Add(jzx);
                    inter.SelfJZX = jzx;
                    otherJTSYQS.Add(inter);
                }
                jtsyq.JZXS = jzxs;
            }

            //移除重复的地块
            int count = otherJTSYQS.Count;

            /* for (int a =0; a < count; a++)
             * {
             *   JTSYQ j1 = otherJTSYQS[a];
             *
             *   for (int b= a+1; b < count;b++)
             *   {
             *       JTSYQ j2 = otherJTSYQS[b];
             *       if(j1.OBJECTID == j2.OBJECTID)
             *       {
             *           otherJTSYQS.RemoveAt(b);
             *           b--;
             *           count--;
             *       }
             *   }
             *
             * }*/

            //移除被大地块所包含的
            for (int a = 0; a < count; a++)
            {
                JTSYQ            j1 = otherJTSYQS[a];
                IList <IFeature> containsFeature = ArcGisUtils.GetSeartchFeatures(JTSYQCustom.GetLayer(), ArcGisUtils.ScaleEnvelope(j1.Feature.Shape.Envelope, 0.9), esriSpatialRelEnum.esriSpatialRelContains);
                IList <JTSYQ>    containsJTSYQS  = JTSYQCustom.FeaturesToJTSYQ(containsFeature);
                if (containsJTSYQS != null)
                {
                    for (int c = 0; c < containsJTSYQS.Count; c++)
                    {
                        for (int b = 0; b < count; b++)
                        {
                            if (a == b)
                            {  //除自己
                                continue;
                            }
                            JTSYQ j2 = otherJTSYQS[b];
                            if (containsJTSYQS[c].OBJECTID == j2.OBJECTID)
                            {
                                otherJTSYQS.RemoveAt(b);
                                b--;
                                count--;
                            }
                        }
                    }
                }
            }
            List <JZX> lastJZXS = new List <JZX>();

            foreach (JTSYQ jtsyq in otherJTSYQS)
            {
                lastJZXS.Add(jtsyq.SelfJZX);
            }
            //groupJTSYQ.JZXS = lastJZXS;
            return(lastJZXS);
        }