示例#1
0
        public List <Jzx> SetJzxBs()
        {
            Dictionary <string, string> dictionary = ExcelUtils.ReadExcelToDic("C:\\ZJDTemplete\\行政代码.xls", 0);
            List <Jzx> list   = new List <Jzx>();
            Editor     editor = this.utils.GetEditor();

            TypedValue[] array = new TypedValue[]
            {
                new TypedValue(8, "JZD"),
                new TypedValue(0, "LWPOLYLINE")
            };
            SelectionFilter        selectionFilter        = new SelectionFilter(array);
            PromptSelectionOptions promptSelectionOptions = new PromptSelectionOptions();

            promptSelectionOptions.MessageForAdding = ("\n请选择要生成标示表的JZD图层的权属线");
            PromptSelectionResult selection = editor.GetSelection(promptSelectionOptions, selectionFilter);
            List <Jzx>            result;

            if (selection.Status == PromptStatus.Cancel)
            {
                result = list;
            }
            else
            {
                DBObjectCollection entityCollection = this.utils.GetEntityCollection(selection);
                if (entityCollection.Count == 0)
                {
                    editor.WriteMessage("\n你没有选择对象");
                    result = list;
                }
                else
                {
                    Database workingDatabase = HostApplicationServices.WorkingDatabase;
                    using (Transaction transaction = workingDatabase.TransactionManager.StartTransaction())
                    {
                        foreach (DBObject dBObject in entityCollection)
                        {
                            if (dBObject is Polyline)
                            {
                                Jzx jzx = new Jzx("");
                                if (dBObject is Polyline)
                                {
                                    Polyline     polyline     = (Polyline)transaction.GetObject(dBObject.ObjectId, OpenMode.ForWrite, true);
                                    ResultBuffer resultBuffer = polyline.XData;
                                    if (!(resultBuffer == null))
                                    {
                                        resultBuffer = polyline.GetXDataForApplication("SOUTH");
                                        TypedValue[] array2 = resultBuffer.AsArray();
                                        if (array2 != null && array2.Length >= 5)
                                        {
                                            if (!polyline.Closed)
                                            {
                                                editor.WriteMessage(array2[2].Value.ToString() + ",多段线没有闭合\n");
                                            }
                                            else
                                            {
                                                jzx.setCbfbm(array2[2].Value.ToString());
                                                jzx.setCbfmc(array2[3].Value.ToString());
                                                Point3dCollection point3dCollection = new Point3dCollection();
                                                polyline.GetStretchPoints(point3dCollection);
                                                point3dCollection = this.utils.RePoint(point3dCollection);
                                                List <string> list2 = new List <string>();
                                                double        num;
                                                double        num2;
                                                double        num3;
                                                double        num4;
                                                string        text;
                                                for (int i = 0; i < point3dCollection.Count - 1; i++)
                                                {
                                                    num  = Math.Round(point3dCollection[i].X, 3);
                                                    num2 = Math.Round(point3dCollection[i].Y, 3);
                                                    num3 = Math.Round(point3dCollection[i + 1].X, 3);
                                                    num4 = Math.Round(point3dCollection[i + 1].Y, 3);
                                                    text = this.utils.selectFw_JzxSur(point3dCollection[i], point3dCollection[i + 1], polyline);
                                                    list2.Add(string.Concat(new object[]
                                                    {
                                                        "J",
                                                        i + 1,
                                                        "_J",
                                                        i + 2,
                                                        "_",
                                                        text,
                                                        "_",
                                                        Math.Round(this.utils.CalculateTwoPt(point3dCollection[i], point3dCollection[i + 1]), 6),
                                                        "_",
                                                        num,
                                                        ",",
                                                        num2,
                                                        "_",
                                                        num3,
                                                        ",",
                                                        num4
                                                    }));
                                                }
                                                num  = Math.Round(point3dCollection[point3dCollection.Count - 1].X, 3);
                                                num2 = Math.Round(point3dCollection[point3dCollection.Count - 1].Y, 3);
                                                num3 = Math.Round(point3dCollection[0].X, 3);
                                                num4 = Math.Round(point3dCollection[0].Y, 3);
                                                text = this.utils.selectFw_JzxSur(point3dCollection[point3dCollection.Count - 1], point3dCollection[0], polyline);
                                                list2.Add(string.Concat(new object[]
                                                {
                                                    "J",
                                                    point3dCollection.Count,
                                                    "_J1_",
                                                    text,
                                                    "_",
                                                    Math.Round(this.utils.CalculateTwoPt(point3dCollection[point3dCollection.Count - 1], point3dCollection[0]), 6),
                                                    "_",
                                                    num,
                                                    ",",
                                                    num2,
                                                    "_",
                                                    num3,
                                                    ",",
                                                    num4
                                                }));
                                                jzx.setJzxBs(list2);
                                                list.Add(jzx);
                                            }
                                        }
                                    }
                                }
                            }
                        }
                        transaction.Commit();
                    }
                    result = list;
                }
            }
            return(result);
        }
示例#2
0
        public List <Jzx> createJzxList(object[] formText)
        {
            List <Jzx> list   = new List <Jzx>();
            Editor     editor = this.utils.GetEditor();

            TypedValue[] array = new TypedValue[]
            {
                new TypedValue(8, "JZD"),
                new TypedValue(0, "LWPOLYLINE")
            };
            SelectionFilter        selectionFilter        = new SelectionFilter(array);
            PromptSelectionOptions promptSelectionOptions = new PromptSelectionOptions();

            promptSelectionOptions.MessageForAdding = ("\n请选择要生成四至的JZD图层权属线");
            PromptSelectionResult selection = editor.GetSelection(promptSelectionOptions, selectionFilter);
            List <Jzx>            result;

            if (selection.Status == PromptStatus.Cancel)
            {
                result = list;
            }
            else
            {
                DBObjectCollection entityCollection = this.utils.GetEntityCollection(selection);
                if (entityCollection.Count == 0)
                {
                    editor.WriteMessage("\n你没有选择对象");
                    result = list;
                }
                else
                {
                    Database workingDatabase = HostApplicationServices.WorkingDatabase;
                    using (Transaction transaction = workingDatabase.TransactionManager.StartTransaction())
                    {
                        Dictionary <string, string> addressDic = ExcelUtils.ReadExcelToDic((string)formText[0], 0);
                        foreach (DBObject dBObject in entityCollection)
                        {
                            if (dBObject is Polyline)
                            {
                                Polyline     polyline     = (Polyline)transaction.GetObject(dBObject.ObjectId, OpenMode.ForWrite, true);
                                string       surAddress   = this.jzdSrevice.GetSurAddress(polyline, addressDic);
                                Jzx          jzx          = new Jzx(surAddress);
                                ResultBuffer resultBuffer = polyline.XData;
                                if (!(resultBuffer == null))
                                {
                                    resultBuffer = polyline.GetXDataForApplication("SOUTH");
                                    TypedValue[] array2 = resultBuffer.AsArray();
                                    if (array2 != null && array2.Length >= 5)
                                    {
                                        jzx.setCbfbm(array2[2].Value.ToString());
                                        jzx.setCbfmc(array2[3].Value.ToString());
                                        this.jzdSrevice.GetSurAddress(polyline, addressDic);
                                        Point3dCollection point3dCollection = new Point3dCollection();
                                        polyline.GetStretchPoints(point3dCollection);
                                        point3dCollection = this.utils.RePoint(point3dCollection);
                                        double[]          dou = this.utils.FindFourPoints(point3dCollection);
                                        Point3dCollection point3dCollection2 = this.utils.createFourPoint(dou);
                                        Polyline3d        polyline3d         = this.utils.CreatePolye(point3dCollection2, false);
                                        int   num    = this.utils.PolyDiPoly(point3dCollection, point3dCollection2);
                                        int[] array3 = new int[4];
                                        if (num > 3)
                                        {
                                            int[]   array4 = this.utils.FindPointsDic(point3dCollection);
                                            int[]   array5 = this.utils.FindPointsDic(point3dCollection, point3dCollection2);
                                            int[][] max    = new int[][]
                                            {
                                                array4,
                                                array5
                                            };
                                            int num2 = this.utils.SelectPc1PC2(max, point3dCollection);
                                            if (num2 == 0)
                                            {
                                                array3 = array4;
                                            }
                                            else if (num2 == 1)
                                            {
                                                array3 = array5;
                                            }
                                        }
                                        else
                                        {
                                            array3 = this.utils.FindPointsDic(point3dCollection, point3dCollection2);
                                        }
                                        List <string> list2 = new List <string>();
                                        list2.AddRange(this.GetJzxSm(point3dCollection, array3[0], array3[1], surAddress, polyline, (double)formText[2]));
                                        if (list2.Count != 0 && !list2[list2.Count - 1].Equals("partition"))
                                        {
                                            list2.Add("partition");
                                        }
                                        list2.AddRange(this.GetJzxSm(point3dCollection, array3[1], array3[2], surAddress, polyline, (double)formText[2]));
                                        if (list2.Count != 0 && !list2[list2.Count - 1].Equals("partition"))
                                        {
                                            list2.Add("partition");
                                        }
                                        if (array3[2] < array3[3])
                                        {
                                            list2.AddRange(this.GetJzxSm(point3dCollection, array3[2], array3[3], surAddress, polyline, (double)formText[2]));
                                            if (list2.Count != 0 && !list2[list2.Count - 1].Equals("partition"))
                                            {
                                                list2.Add("partition");
                                            }
                                        }
                                        if (array3[3] != 0)
                                        {
                                            if (array3[3] < array3[2])
                                            {
                                                list2.AddRange(this.GetJzxSm(point3dCollection, array3[2], point3dCollection.Count - 1, surAddress, polyline, (double)formText[2]));
                                                list2.AddRange(this.GetJzxSm(point3dCollection, point3dCollection.Count - 1, array3[3], surAddress, polyline, (double)formText[2]));
                                            }
                                            else
                                            {
                                                list2.AddRange(this.GetJzxSm(point3dCollection, array3[3], point3dCollection.Count - 1, surAddress, polyline, (double)formText[2]));
                                            }
                                        }
                                        else
                                        {
                                            list2.AddRange(this.GetJzxSm(point3dCollection, array3[2], point3dCollection.Count - 1, surAddress, polyline, (double)formText[2]));
                                        }
                                        list2.AddRange(this.GetSingleJzxSm(point3dCollection, point3dCollection.Count - 1, 0, surAddress, polyline, (double)formText[2]));
                                        if (list2.Count != 0 && !list2[list2.Count - 1].Equals("partition"))
                                        {
                                            list2.Add("partition");
                                        }
                                        if (this.findJzDh(list2, "J1_") == -1 || this.findJzDh(list2, "J1-") == -1)
                                        {
                                            list2.AddRange(this.GetJzxSm(point3dCollection, 0, array3[0], surAddress, polyline, (double)formText[2]));
                                            if (list2.Count != 0 && !list2[list2.Count - 1].Equals("partition"))
                                            {
                                                list2.Add("partition");
                                            }
                                        }
                                        jzx.setJzxSm(list2);
                                        list.Add(jzx);
                                    }
                                }
                            }
                        }
                        transaction.Commit();
                    }
                    result = list;
                }
            }
            return(result);
        }