예제 #1
0
        /// <summary>
        /// Save a feature layer of IPolygon to Ipe
        /// </summary>
        public static string TranCpgToIpe(CPolygon cpg, IFillSymbol pFillSymbol,
                                          IEnvelope pFLayerEnv, CEnvelope pIpeEnv, string strBoundWidth = "normal")
        {
            //get the color of the filled part
            //we are not allowed to directly use "var pFillRgbColor = pFillSymbol.Color as IRgbColor;"
            //Nor can we use "var pFillRgbColor = pFillSymbol.Color.RGB as IRgbColor;"
            //pFillSymbol.Color.RGB has type 'int'
            IColor pFillSymbolColor = new RgbColorClass();

            pFillSymbolColor.RGB = pFillSymbol.Color.RGB;
            CColor cColor            = new CUtility.CColor(pFillSymbolColor as IRgbColor);
            var    pSimpleFillSymbol = pFillSymbol as ISimpleFillSymbol;

            if (pSimpleFillSymbol != null)
            {
                if (pSimpleFillSymbol.Style == esriSimpleFillStyle.esriSFSHollow ||
                    pSimpleFillSymbol.Style == esriSimpleFillStyle.esriSFSNull)
                {
                    cColor = null;
                }
            }


            //get the color of the out line
            var pOutlineRgbColor = pFillSymbol.Outline.Color as IRgbColor;

            if (strBoundWidth == "")
            {
                strBoundWidth = pFillSymbol.Outline.Width.ToString();
            }

            //append the string
            return(CIpeDraw.DrawCpg(cpg, pFLayerEnv, pIpeEnv, new CColor(pOutlineRgbColor), cColor, strBoundWidth));
        }
예제 #2
0
        private List <CPoint> GenerateFieldCpt(CDCEL pDCEL)
        {
            CEnvelope pEnvelope   = pDCEL.pEdgeGrid.pEnvelope;
            double    dblCellSize = pDCEL.pEdgeGrid.dblCellWidth / 3;
            int       intRow      = Convert.ToInt32(Math.Truncate(pEnvelope.Height / dblCellSize)) + 1;
            int       intCol      = Convert.ToInt32(Math.Truncate(pEnvelope.Width / dblCellSize)) + 1;

            List <CPoint> FieldCptLt = new List <CPoint>(intRow * intCol);
            double        dblX       = pEnvelope.XMin;
            double        dblY       = pEnvelope.YMin;
            int           intCount   = 0;

            for (int i = 0; i < intRow; i++)
            {
                dblX = pEnvelope.XMin;
                for (int j = 0; j < intCol; j++)
                {
                    FieldCptLt.Add(new CPoint(intCount, dblX, dblY));
                    dblX += dblCellSize;
                    intCount++;
                }
                dblY += dblCellSize;
            }

            pDCEL.DetectCloestLeftCorrectCEdge(FieldCptLt);

            return(FieldCptLt);
        }
예제 #3
0
        /// <summary>
        /// Save a feature layer of IPolygon to Ipe
        /// </summary>
        public static string TranIpgBoundToIpe(IPolygon ipg,
                                               IEnvelope pFLayerEnv, CEnvelope pIpeEnv, CColor StrokeColor,
                                               string strBoundWidth = "normal", string strDash = "normal")
        {
            ////get the color of the filled part
            ////we are not allowed to directly use "var pFillRgbColor = pFillSymbol.Color as IRgbColor;"
            ////Nor can we use "var pFillRgbColor = pFillSymbol.Color.RGB as IRgbColor;"
            ////pFillSymbol.Color.RGB has type 'int'
            //IColor pFillSymbolColor = new RgbColorClass();
            //pFillSymbolColor.RGB = pFillSymbol.Color.RGB;
            //var pFillSymbolRgbColor = pFillSymbolColor as IRgbColor;

            ////get the color of the out line
            //var pOutlineRgbColor = pFillSymbol.Outline.Color as IRgbColor;
            //if (strBoundWidth == "")
            //{
            //    strBoundWidth = pFillSymbol.Outline.Width.ToString();
            //}

            //get the feature
            CPolygon cpg = new CPolygon(0, ipg as IPolygon4);

            //append the string
            return(CIpeDraw.DrawCpgBound(cpg, pFLayerEnv, pIpeEnv, StrokeColor, strBoundWidth, strDash));
        }
예제 #4
0
        /// <summary>
        /// Save a feature layer of IPolygon to Ipe
        /// </summary>
        private static string TranIpgToIpe(IFeature pFeature, IFeatureRenderer pRenderer,
                                           IEnvelope pFLayerEnv, CEnvelope pIpeEnv, string strBoundWidth = "normal")
        {
            var pFillSymbol = pRenderer.SymbolByFeature[pFeature] as IFillSymbol;

            return(TranCpgToIpe(new CPolygon(0, (IPolygon4)pFeature.Shape), pFillSymbol, pFLayerEnv, pIpeEnv, strBoundWidth));
        }
예제 #5
0
        public void btnRun_Click(object sender, EventArgs e)
        {
            //get parameters
            CParameterInitialize ParameterInitialize = _DataRecords.ParameterInitialize;
            IEnvelope            pFLayerEnv          = ParameterInitialize.m_mapFeature
                                                       .get_Layer(ParameterInitialize.cboLayerLt[0].SelectedIndex).AreaOfInterest;
            CEnvelope pIpeEnv = new CEnvelope(
                Convert.ToDouble(this.txtIpeMinX.Text), Convert.ToDouble(this.txtIpeMinY.Text),
                Convert.ToDouble(this.txtIpeMaxX.Text), Convert.ToDouble(this.txtIpeMaxY.Text));

            string strBoundWidth = this.cboSize.SelectedItem.ToString();

            if (chkOverrideWidth.Checked == false)
            {
                strBoundWidth = "";
            }

            //save path
            CHelpFunc.SetSavePath(ParameterInitialize);

            var pFLayerLt = CHelpFunc.GetVisibleLayers(ParameterInitialize);

            CToIpe.SaveToIpe(pFLayerLt, pFLayerEnv, pIpeEnv,
                             this.chkGroup.Checked, strBoundWidth, ParameterInitialize);
        }
예제 #6
0
        public void Class_can_serialized_to_xml()
        {
            var fs        = File.Open("C:/git/XmlClassGenerator/XmlClassGenerator.Tests/Resources/dbc.new.xml", FileMode.Create);
            var s         = new XmlSerializer(typeof(CEnvelope));
            var cEnvelope = new CEnvelope();

            s.Serialize(fs, cEnvelope);
        }
예제 #7
0
        private List <CValPair <int, int> > HandleNoXDiff(CEdge cedge, double dblCellWidth,
                                                          double dblCellHeight, CEnvelope pEnvelope, List <CEdge>[,] aCEdgeLtCell)
        {
            int intFrRow = GetRow(cedge.FrCpt.Y);
            int intToRow = GetRow(cedge.ToCpt.Y);
            int intCol   = GetCol(cedge.FrCpt.X);

            return(RecordIntoOneColumn(cedge, intCol, intFrRow, intToRow, aCEdgeLtCell));
        }
예제 #8
0
        /// <summary>
        /// Save a feature layer of IPolyline to Ipe
        /// </summary>
        private static string TranIptToIpe(IFeature pFeature, IFeatureRenderer pRenderer, IEnvelope pFLayerEnv,
                                           CEnvelope pIpeEnv, string strBoundWidth = "normal")
        {
            var pMarkerSymbol         = pRenderer.SymbolByFeature[pFeature] as IMarkerSymbol;
            var pMarkerSymbolRgbColor = pMarkerSymbol.Color as IRgbColor;

            if (strBoundWidth == "")
            {
                strBoundWidth = pMarkerSymbol.Size.ToString();
            }

            var ipt = pFeature.Shape as IPoint;

            return(CIpeDraw.DrawIpt(ipt, pFLayerEnv, pIpeEnv, "disk", new CColor(pMarkerSymbolRgbColor), strBoundWidth));
        }
예제 #9
0
        public CEdgeGrid(List <CEdge> CEdgeLt)
        {
            CEnvelope pEnvelope = CGeoFunc.GetEnvelope(CEdgeLt);

            CEdgeLt.ForEach(cedge => cedge.JudgeAndSetSlope());
            double dblCellSize = Math.Sqrt(pEnvelope.Width * pEnvelope.Height / Convert.ToDouble(CEdgeLt.Count)); //dblRowCount*dblColCount==n

            _intRowCount   = Convert.ToInt32(Math.Truncate(pEnvelope.Height / dblCellSize)) + 1;                  //+1, so that the bordered point can be covered
            _intColCount   = Convert.ToInt32(Math.Truncate(pEnvelope.Width / dblCellSize)) + 1;                   //+1, so that the bordered point can be covered
            _pEnvelope     = pEnvelope;
            _CEdgeLt       = CEdgeLt;
            _dblCellWidth  = dblCellSize;
            _dblCellHeight = dblCellSize;

            FillCEdgeLtInGrid();
        }
예제 #10
0
        public static string GetScaleLegend(IEnvelope pFLayerEnv, CEnvelope pIpeEnv, string strMapUnits)
        {
            double dblFactorIpeToLayer = pIpeEnv.Height / pFLayerEnv.Height;
            double dblLegend16         = 16 / dblFactorIpeToLayer;

            if (dblLegend16 < 1)
            {
                dblLegend16 = 1;
            }
            int    intLegendInt = CMath.GetNumberTidy(dblLegend16);
            double dblLegentInt = intLegendInt * dblFactorIpeToLayer;

            ////add legend (unit and a sample line), draw a line with length 16 in ipe
            return(CIpeDraw.writeIpeText("$" + intLegendInt + @"\,$" + strMapUnits, 320, 32) +
                   CIpeDraw.drawIpePath(new double[] { 320, 320, 320 + dblLegentInt, 320 + dblLegentInt },
                                        new double[] { 20, 16, 16, 20 }));
        }
예제 #11
0
        /// <summary>
        /// Save a feature layer of IPolyline to Ipe
        /// </summary>
        private static string TranIplToIpe(IFeature pFeature, IFeatureRenderer pRenderer, IEnvelope pFLayerEnv,
                                           CEnvelope pIpeEnv, string strBoundWidth = "normal")
        {
            var pLineSymbol         = pRenderer.SymbolByFeature[pFeature] as ILineSymbol;
            var pLineSymbolRgbColor = pLineSymbol.Color as IRgbColor;

            if (strBoundWidth == "")
            {
                strBoundWidth = pLineSymbol.Width.ToString();
            }

            //get the feature
            CPolyline cpl = new CPolyline(0, pFeature.Shape as IPolyline5);

            //append the string
            return(CIpeDraw.DrawCpl(cpl, pFLayerEnv, pIpeEnv,
                                    new CColor(pLineSymbolRgbColor), strBoundWidth));
        }
예제 #12
0
        public static string GetDataOfFeatureLayer(IFeatureLayer pFLayer, IEnvelope pFLayerEnv,
                                                   CEnvelope pIpeEnv, string strBoundWidth = "normal", bool blnDrawBound = false)
        {
            string str = "";

            if (blnDrawBound == true)
            {
                //add legend (unit and a sample line), draw a line with length 32 in ipe
                //so that we can easily compare shrinks with other figures
                //if the text of an object is above, then the object is under other objects
                //this bound line should be under all other objectss
                str += CIpeDraw.drawIpeEdge(pIpeEnv.XMin, pIpeEnv.YMin, pIpeEnv.XMin, pIpeEnv.YMax, "white");
            }
            string         strName         = pFLayer.Name;
            IFeatureClass  pFeatureClass   = pFLayer.FeatureClass;
            int            intFeatureCount = pFeatureClass.FeatureCount(null);
            IFeatureCursor pFeatureCursor  = pFeatureClass.Search(null, false);   //注意此处的参数(****,false)!!!
            var            pRenderer       = (pFLayer as IGeoFeatureLayer).Renderer;

            for (int i = 0; i < intFeatureCount; i++)
            {
                //at the last round of this loop, pFeatureCursor.NextFeature() will return null
                IFeature pFeature = pFeatureCursor.NextFeature();
                switch (pFeatureClass.ShapeType)
                {
                case esriGeometryType.esriGeometryPoint:
                    str += TranIptToIpe(pFeature, pRenderer, pFLayerEnv, pIpeEnv, strBoundWidth);
                    break;

                case esriGeometryType.esriGeometryPolyline:
                    str += TranIplToIpe(pFeature, pRenderer, pFLayerEnv, pIpeEnv, strBoundWidth);
                    break;

                case esriGeometryType.esriGeometryPolygon:
                    str += TranIpgToIpe(pFeature, pRenderer, pFLayerEnv, pIpeEnv, strBoundWidth);
                    break;

                default:
                    break;
                }
            }

            return(str);
        }
예제 #13
0
        private string strDataOfLayers(int intLayerNum, List <string> strLayerNameLt, IFeatureLayer pFLayer,
                                       IEnvelope pFLayerEnv, CEnvelope pIpeEnv, string strBoundWidth,
                                       string strSimplification, string strBufferStyle, double dblMiterLimit)
        {
            //for the first layer, we add all the patches
            string strDataAllLayers = CIpeDraw.SpecifyLayerByWritingText(strLayerNameLt[0], "removable", 320, 64);

            strDataAllLayers += CToIpe.GetScaleLegend(pFLayerEnv, pIpeEnv, CHelpFunc.GetUnits(_ParameterInitialize.m_mapControl.MapUnits));
            strDataAllLayers += CIpeDraw.writeIpeText(strLayerNameLt[0], 320, 128)
                                + "<group>\n" + CToIpe.GetDataOfFeatureLayer(pFLayer, pFLayerEnv, pIpeEnv, strBoundWidth, true) + "</group>\n";

            //for each of other layers, we only add the new patch
            for (int i = 1; i < strLayerNameLt.Count; i++)
            {
                strDataAllLayers += CIpeDraw.SpecifyLayerByWritingText(strLayerNameLt[i], "removable", 320, 64);

                //draw a rectangle to cover the patch number of the last layer
                strDataAllLayers += CIpeDraw.drawIpeBox(304, 112, 384, 160, "white");

                //add layer name and a text of patch numbers
                strDataAllLayers += CIpeDraw.writeIpeText(strLayerNameLt[i], 320, 128);

                strDataAllLayers += CToIpe.GetScaleLegend(pFLayerEnv, pIpeEnv,
                                                          CHelpFunc.GetUnits(_ParameterInitialize.m_mapControl.MapUnits));

                //add the Content of animations
                strDataAllLayers += "<group>\n";
                strDataAllLayers += CIpeDraw.drawIpeEdge(pIpeEnv.XMin, pIpeEnv.YMin, pIpeEnv.XMin, pIpeEnv.YMax, "white");
                foreach (var cpg in GetResultCpgEb(this.MergedCpgLt, Convert.ToDouble(strLayerNameLt[i]),
                                                   strSimplification, strBufferStyle, dblMiterLimit))
                {
                    strDataAllLayers += CIpeDraw.DrawCpg(cpg, pFLayerEnv, pIpeEnv,
                                                         new CUtility.CColor(0, 0, 0), new CUtility.CColor(230, 230, 230), strBoundWidth);
                }
                strDataAllLayers += "</group>\n";
                //strDataAllLayers += CToIpe.TranIpgToIpe(IpgLt[i - 1], pFillSymbolLt[i - 1], pFLayerEnv, pIpeEnv, strBoundWidth);
            }

            return(strDataAllLayers);
        }
예제 #14
0
        public void btnRun_Click(object sender, EventArgs e)
        {
            //get parameters
            double dblFactor = Convert.ToDouble(this.txtFactor.Text);

            //get the data of the layers
            string               strSelectedLayer    = this.cboLayer.Text;
            IFeatureLayer        pFeatureLayer       = null;
            CParameterInitialize ParameterInitialize = _DataRecords.ParameterInitialize;

            //get the selected features layers
            try
            {
                for (int i = 0; i < ParameterInitialize.m_mapFeature.LayerCount; i++)
                {
                    if (strSelectedLayer == ParameterInitialize.m_mapFeature.get_Layer(i).Name)
                    {
                        pFeatureLayer = (IFeatureLayer)ParameterInitialize.m_mapFeature.get_Layer(i);
                    }
                }
            }
            catch (Exception)
            {
                MessageBox.Show("Please select a feature layer");
                return;
            }

            //dialogue for saving
            SaveFileDialog SFD = new SaveFileDialog();

            SFD.ShowDialog();
            string strPath = SFD.FileName;

            //string strName=SFD.
            ParameterInitialize.pWorkspace = CHelpFunc.OpenWorkspace(strPath);


            long lngStartTime = System.Environment.TickCount; //record the start time


            if ((pFeatureLayer.FeatureClass != null) &&
                (pFeatureLayer.FeatureClass.ShapeType == esriGeometryType.esriGeometryPoint))
            {
                List <CPoint> cptlt = CHelpFunc.GetCPtLtFromPointFeatureLayer(pFeatureLayer);
                if (dblFactor == -1)
                {
                    CEnvelope pEnvelope = CGeoFunc.GetEnvelope(cptlt);
                    dblFactor = Math.Sqrt(pEnvelope.Width * pEnvelope.Height / Convert.ToDouble(cptlt.Count)); //Average Distance
                    this.txtAverageDis.Text = dblFactor.ToString();
                }
                double dblFactor3 = dblFactor / 6;  //suppose that 3*StandardDeviation = dblAverageDis/2, where StandardDeviation = 1 (Notice that dblFactor3 is not StandardDeviation)


                List <CPoint> GPcptlt = new List <CPoint>(cptlt.Count);  //cptlt by Gaussian Perturbation
                Random        rand    = new Random();
                foreach (CPoint cpt in cptlt)
                {
                    double dblGPX, dblGPY;
                    CMathStatistic.BoxMuller(rand, out dblGPX, out dblGPY);
                    CPoint gpcpt = new CPoint(cpt.ID, cpt.X + dblFactor3 * dblGPX, cpt.Y + dblFactor3 * dblGPY);
                    gpcpt.SetPoint();
                    GPcptlt.Add(gpcpt);
                }
                //CSaveFeature.SaveCGeoEb(GPcptlt, esriGeometryType.esriGeometryPoint, "GPcptlt", ParameterInitialize.pWorkspace, ParameterInitialize.m_mapControl);


                for (int i = 0; i < 10; i++)
                {
                    double        dblProbalibity = (i + 1) * 0.1;
                    List <CPoint> subcptlt, gpsubcptlt;
                    CreateSubSet(cptlt, GPcptlt, dblProbalibity, rand, out subcptlt, out gpsubcptlt);

                    subcptlt.AddRange(gpsubcptlt);
                    //CHelpFunc.SaveESRIObjltfast(subcptlt, esriGeometryType.esriGeometryPoint, "MixedPoint" + i.ToString(), ParameterInitialize.pWorkspace, ParameterInitialize.m_mapControl);
                    //CSaveFeature.SaveCGeoEb(subcptlt, esriGeometryType.esriGeometryPoint, "MixedPoint" + i.ToString() + "_" + subcptlt.Count.ToString(), ParameterInitialize.pWorkspace, ParameterInitialize.m_mapControl);
                }



                //if (dblFactor ==-1)
                //{
                //    C5.LinkedList<CCorrCpts> CCorrCptsLk = CGeoFunc.LookingForNeighboursByGrids(cptlt, 0.00003);
                //    double dblMinDis = cptlt[0].DistanceTo(cptlt[1]);
                //    foreach (CCorrCpts pCorrCpts in CCorrCptsLk)
                //    {
                //        double dblDis = pCorrCpts.FrCpt.DistanceTo(pCorrCpts.ToCpt);
                //        if (dblDis==0)
                //        {
                //            int ss = 5;
                //        }
                //        if (dblDis < dblMinDis && dblDis>0)
                //        {
                //            dblMinDis = dblDis;
                //        }
                //    }
                //    dblFactor = dblMinDis;
                //}
            }
            else if ((pFeatureLayer.FeatureClass != null) && (pFeatureLayer.FeatureClass.ShapeType == esriGeometryType.esriGeometryPolyline))
            {
                //List<CPolyline> CPlLt = CHelpFunc.GetCPlLtByFeatureLayer(pFeatureLayer);
                //List<CPolyline> CPlLtNew = new List<CPolyline>(CPlLt.Count);
                //for (int i = 0; i < CPlLt.Count; i++)
                //{
                //    List<CPoint> newcptlt = new List<CPoint>(CPlLt[i].CptLt.Count);
                //    for (int j = 0; j < CPlLt[i].CptLt.Count; j++)
                //    {
                //        double dblnewX = dblX + (CPlLt[i].CptLt[j].X - dblLongtitudeDegree) * dblFactorX;
                //        double dblnewY = dblY + (CPlLt[i].CptLt[j].Y - dblLatitudeDegree) * dblFactorY;
                //        CPoint newcpt = new CPoint(j, dblnewX, dblnewY);
                //        newcptlt.Add(newcpt);
                //    }
                //    CPolyline newcpl = new CPolyline(i, newcptlt);
                //    CPlLtNew.Add(newcpl);
                //}

                //CHelpFunc.SaveCPlLt(CPlLtNew, pFeatureLayer.Name + "_Transformed", ParameterInitialize.pWorkspace, ParameterInitialize.m_mapControl);
            }
            else if ((pFeatureLayer.FeatureClass != null) && (pFeatureLayer.FeatureClass.ShapeType == esriGeometryType.esriGeometryPolygon))
            {
                //----------------------------------------------------------------------------------------------//
                //-------------------------------王航请注意---代码写在这里---------------------------------------//
                //----------------------------------------------------------------------------------------------//

                ////获取多边形数组
                //List<CPolygon> CPolygonLt = CHelpFunc.GetCPolygonLtByFeatureLayer(pFeatureLayer);
                //List<CPolygon> CPolygonLtNew = new List<CPolygon>();
                //for (int i = 0; i < CPolygonLt.Count; i++)
                //{
                //    List<CPoint> newcptlt = new List<CPoint>();
                //    for (int j = 0; j < CPolygonLt[i].CptLt.Count; j++)
                //    {
                //        double dblnewX = CPolygonLt[i].CptLt[j].X * dblEnlargementFactor;
                //        double dblnewY = CPolygonLt[i].CptLt[j].Y * dblEnlargementFactor;
                //        CPoint newcpt = new CPoint(j, dblnewX, dblnewY);
                //        newcptlt.Add(newcpt);
                //    }
                //    CPolygon newcpg = new CPolygon(i, newcptlt);
                //    CPolygonLtNew.Add(newcpg);
                //}

                //CHelpFunc.SaveCPolygons(CPolygonLtNew, pFeatureLayer.Name + "_Transformed", ParameterInitialize.pWorkspace, ParameterInitialize.m_mapControl);
            }



            long lngEndTime = System.Environment.TickCount;                                                                         //记录结束时间

            _DataRecords.ParameterInitialize.tsslTime.Text = "Running Time: " + Convert.ToString(lngEndTime - lngStartTime) + "ms"; //显示运行时

            MessageBox.Show("Done!");
        }
예제 #15
0
        private void Grids(ref List <CPoint> cptlt, double dblThreshold, double dblGridSize, ref long lngTime, ref long lngMemory, ref int intOutPut)
        {
            lngTime = System.Environment.TickCount;
            CEnvelope pEnvelope = CGeoFunc.GetEnvelope(cptlt);

            dblGridSize = Math.Max(dblGridSize, dblThreshold);
            int intRow = Convert.ToInt32(Math.Truncate(pEnvelope.Height / dblGridSize)) + 1;  //+1, so that the bordered point can be covered
            int intCol = Convert.ToInt32(Math.Truncate(pEnvelope.Width / dblGridSize)) + 1;   //+1, so that the bordered point can be covered

            long lngTime2 = System.Environment.TickCount;

            SCG.LinkedList <int>[,] aintLLtGridContent = new SCG.LinkedList <int> [intRow, intCol];
            for (int i = 0; i < intRow; i++)
            {
                for (int j = 0; j < intCol; j++)
                {
                    aintLLtGridContent[i, j] = new SCG.LinkedList <int>();
                }
            }
            lngTime2 = System.Environment.TickCount - lngTime2;

            long lngTime3 = System.Environment.TickCount;

            foreach (CPoint cpt in cptlt)
            {
                int rownum = Convert.ToInt32(Math.Truncate((cpt.Y - pEnvelope.YMin) / dblGridSize));
                int colnum = Convert.ToInt32(Math.Truncate((cpt.X - pEnvelope.XMin) / dblGridSize));
                aintLLtGridContent[rownum, colnum].AddLast(cpt.GID);
            }

            for (int i = 0; i < intRow; i++)
            {
                for (int j = 0; j < intCol; j++)
                {
                    LookingForNeighboursInGridItself(ref cptlt, aintLLtGridContent[i, j], dblThreshold, ref intOutPut);

                    if (j + 1 < intCol)  //Right
                    {
                        LookingForNeighboursInGrids(ref cptlt, aintLLtGridContent[i, j], aintLLtGridContent[i, j + 1], dblThreshold, ref intOutPut);
                    }

                    if (i + 1 < intRow) //Upper
                    {
                        if (j - 1 >= 0) //UpperLeft
                        {
                            LookingForNeighboursInGrids(ref cptlt, aintLLtGridContent[i, j], aintLLtGridContent[i + 1, j - 1], dblThreshold, ref intOutPut);
                        }
                        //UpperMiddle
                        LookingForNeighboursInGrids(ref cptlt, aintLLtGridContent[i, j], aintLLtGridContent[i + 1, j], dblThreshold, ref intOutPut);

                        if (j + 1 < intCol)  //UpperRight
                        {
                            LookingForNeighboursInGrids(ref cptlt, aintLLtGridContent[i, j], aintLLtGridContent[i + 1, j + 1], dblThreshold, ref intOutPut);
                        }
                    }
                }
            }
            lngTime3  = System.Environment.TickCount - lngTime3;
            lngTime   = System.Environment.TickCount - lngTime;
            lngMemory = GC.GetTotalMemory(true) - lngMemory;
            ////Dispose
            //for (int i = 0; i < intRow; i++)
            //{
            //    for (int j = 0; j < intCol; j++)
            //    {
            //        aintLLtGridContent[i, j].Dispose();
            //    }

            //}
        }
예제 #16
0
 /// <summary>
 /// Save a feature layer of IPolygon to Ipe
 /// </summary>
 public static string TranIpgToIpe(IPolygon4 ipg, IFillSymbol pFillSymbol,
                                   IEnvelope pFLayerEnv, CEnvelope pIpeEnv, string strBoundWidth = "normal")
 {
     return(TranCpgToIpe(new CPolygon(0, ipg), pFillSymbol, pFLayerEnv, pIpeEnv, strBoundWidth));
 }
예제 #17
0
        public static void SaveToIpe(List <IFeatureLayer> pFLayerLt, IEnvelope pFLayerEnv, CEnvelope pIpeEnv,
                                     bool blnGroup, string strBoundWidth, CParameterInitialize ParameterInitialize, bool blnLayerToLeft = true)
        {
            var strContent = GetScaleLegend(pFLayerEnv, pIpeEnv, CHelpFunc.GetUnits(ParameterInitialize.m_mapControl.MapUnits));

            for (int i = 0; i < pFLayerLt.Count; i++)
            {
                var pFLayer         = pFLayerLt[i] as IFeatureLayer;
                var strDataOfFLayer = CToIpe.GetDataOfFeatureLayer(pFLayer, pFLayerEnv, pIpeEnv, strBoundWidth, true);

                if (blnGroup == true)
                {
                    strDataOfFLayer = "<group>\n" + strDataOfFLayer + "</group>\n";
                }
                strContent += strDataOfFLayer;

                if (blnLayerToLeft == true)
                {
                    pIpeEnv.XMin -= pIpeEnv.Width;
                    pIpeEnv.XMax -= pIpeEnv.Width;
                }
            }

            string strFullName = ParameterInitialize.strSavePath + "\\" + CHelpFunc.GetTimeStamp() + ".ipe";

            using (var writer = new System.IO.StreamWriter(strFullName, true))
            {
                writer.Write(CIpeDraw.GenerateIpeXMLWithContent(strContent));
            }

            System.Diagnostics.Process.Start(@strFullName);
        }
예제 #18
0
        public static void SaveToIpe(List <IFeatureLayer> pFLayerLt, IEnvelope pFLayerEnv, CEnvelope pIpeEnv,
                                     bool blnGroup, string strBoundWidth, CParameterInitialize ParameterInitialize, bool blnLayerToLeft = true)
        {
            //save path
            //CHelpFunc.SetSavePath(ParameterInitialize);

            //        double dblFactorIpeToLayer = pIpeEnv.Height / pFLayerEnv.Height;
            //        double dblLegend16 = 16 / dblFactorIpeToLayer;
            //        int intLegendInt = CMath.GetNumberTidy(dblLegend16);
            //        double dblLegentInt = intLegendInt * dblFactorIpeToLayer;


            //        //add legend (unit and a sample line), draw a line with length 32 in ipe
            //        string strData = CIpeDraw.writeIpeText(dblLegend16 + " " + ParameterInitialize.m_mapControl.MapUnits.ToString(), 320, 80) +
            //            CIpeDraw.drawIpeEdge(320, 64, 336, 64);

            //        strData += CIpeDraw.writeIpeText(intLegendInt + " " + ParameterInitialize.m_mapControl.MapUnits.ToString(), 320, 32) +
            //CIpeDraw.drawIpeEdge(320, 16, 320 + dblLegentInt, 16) +
            //CIpeDraw.drawIpeEdge(320, 16, 320, 20) + CIpeDraw.drawIpeEdge(320 + dblLegentInt, 16, 320 + dblLegentInt, 20);
            var strData = GetScaleLegend(pFLayerEnv, pIpeEnv, CHelpFunc.GetUnits(ParameterInitialize.m_mapControl.MapUnits));


            //var tt = ParameterInitialize.m_mapControl.
            for (int i = 0; i < pFLayerLt.Count; i++)
            {
                var pFLayer = pFLayerLt[i] as IFeatureLayer;

                if (blnGroup == true)
                {
                    strData += "<group>\n";
                }

                strData += CToIpe.GetDataOfFeatureLayer(pFLayer, pFLayerEnv, pIpeEnv, strBoundWidth, true);

                if (blnGroup == true)
                {
                    strData += "</group>\n";
                }

                if (blnLayerToLeft == true)
                {
                    pIpeEnv.XMin -= pIpeEnv.Width;
                    pIpeEnv.XMax -= pIpeEnv.Width;
                }
            }

            string strFullName = ParameterInitialize.strSavePath + "\\" + CHelpFunc.GetTimeStamp() + ".ipe";

            using (var writer = new System.IO.StreamWriter(strFullName, true))
            {
                writer.Write(CIpeDraw.GenerateIpeContentByData(strData));
            }

            System.Diagnostics.Process.Start(@strFullName);
        }
예제 #19
0
        private List <CValPair <int, int> > HandleWithXDiff(CEdge cedge, CEdge cedgeIncrX,
                                                            double dblCellWidth, double dblCellHeight, CEnvelope pEnvelope, List <CEdge>[,] aCEdgeLtCell)
        {
            int intFrRow = Convert.ToInt32(Math.Truncate((cedgeIncrX.FrCpt.Y - pEnvelope.YMin) / dblCellHeight));
            int intFrCol = Convert.ToInt32(Math.Truncate((cedgeIncrX.FrCpt.X - pEnvelope.XMin) / dblCellWidth));

            int intToRow = Convert.ToInt32(Math.Truncate((cedgeIncrX.ToCpt.Y - pEnvelope.YMin) / dblCellHeight));
            int intToCol = Convert.ToInt32(Math.Truncate((cedgeIncrX.ToCpt.X - pEnvelope.XMin) / dblCellWidth));

            cedgeIncrX.JudgeAndSetSlope();
            double dblYIncrement         = dblCellWidth * cedgeIncrX.dblSlope;
            double dblYIntersectVertical = cedgeIncrX.FrCpt.Y +
                                           cedgeIncrX.dblSlope * (GetCellXMin(intFrCol + 1) - cedgeIncrX.FrCpt.X);
            int intLastRow = intFrRow;

            var intRowColVpLt = new List <CValPair <int, int> >();

            //the columns before the last column
            //Note that if the FrCpt and ToCpt are in the same column (i.e., intFrCol == intToCol),
            //then this "for loop" will do nothing
            for (int i = intFrCol; i < intToCol; i++)
            {
                int intRowIntersect = Convert.ToInt32(Math.Truncate((dblYIntersectVertical - pEnvelope.YMin) / dblCellHeight));
                intRowColVpLt.AddRange(RecordIntoOneColumn(cedge, i, intLastRow, intRowIntersect, aCEdgeLtCell));

                dblYIntersectVertical += dblYIncrement;
                intLastRow             = intRowIntersect;
            }

            //the last column.
            intRowColVpLt.AddRange(RecordIntoOneColumn(cedge, intToCol, intLastRow, intToRow, aCEdgeLtCell));

            return(intRowColVpLt);
        }