예제 #1
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);
        }
예제 #2
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();
        }