Exemple #1
0
        /// <summary>
        /// 三点夹角的判定条件,输出为满足条件的成员的ID所组成的ID数组
        /// </summary>
        /// <param name="aFeat"></param>
        /// <returns></returns>
        private static OSGeo.OGR.Geometry JID(Point[] aFeat, double userSet, int seleTime)
        {
            List <Point[]> pjGroupL = new List <Point[]>();
            List <Point[]> zjGroupL = new List <Point[]>();

            List <Point> pjGroup = new List <Point>();
            List <Point> zjGroup = new List <Point>();

            for (int i = 0; i < aFeat.Length; i++)
            {
                int    frontId, thisId, backId;
                bool[] yon = new bool[seleTime];
                for (int t = 1; t <= seleTime; t++)
                {
                    frontId = i < t ? aFeat.Length - 1 + i - t : i - t;

                    thisId = i;

                    backId = i > aFeat.Length - 1 - t ? i - (aFeat.Length - 1) + t : backId = i + t;

                    double jiaodu = cosCalculator(aFeat[frontId], aFeat[thisId], aFeat[backId]);

                    yon[t - 1] = jiaodu > userSet;
                }

                if (yon.Contains(true))
                {
                    pjGroup.Add(aFeat[i]);
                }
                else
                {
                    zjGroup.Add(aFeat[i]);
                }
            }

            OSGeo.OGR.Geometry outGeom = new OSGeo.OGR.Geometry(OSGeo.OGR.wkbGeometryType.wkbPolygon);
            OSGeo.OGR.Geometry subGeom = new OSGeo.OGR.Geometry(OSGeo.OGR.wkbGeometryType.wkbLinearRing);

            for (int g = 0; g < zjGroup.Count(); g++)
            {
                Point a = zjGroup[g];
                subGeom.AddPoint(a.X, a.Y, a.Z);
            }
            if (subGeom.GetPointCount() < 4)
            {
                return(null);
            }
            subGeom.CloseRings();
            outGeom.AddGeometry(subGeom);
            return(outGeom);
        }
Exemple #2
0
        /// <summary>
        /// 三点夹角的判定条件,输出为满足条件的成员的ID所组成的ID数组
        /// </summary>
        /// <param name="aFeat"></param>
        /// <returns></returns>
        private static OSGeo.OGR.Feature JID(Point[] aFeat)
        {
            int            userSet  = 165;
            int            seleTime = 10;
            List <Point[]> pjGroupL = new List <Point[]>();
            List <Point[]> zjGroupL = new List <Point[]>();

            List <Point> pjGroup = new List <Point>(); //平角
            List <Point> zjGroup = new List <Point>(); //平角

            for (int i = 0; i < aFeat.Length; i++)
            {
                int    frontId, thisId, backId;
                bool[] yon = new bool[seleTime];
                for (int t = 1; t <= seleTime; t++)
                {
                    if (i < t)
                    {
                        frontId = aFeat.Length - 1 + i - t;
                    }
                    else
                    {
                        frontId = i - t;
                    }

                    thisId = i;

                    if (i > aFeat.Length - 1 - t)
                    {
                        backId = i - (aFeat.Length - 1) + t;
                    }
                    else
                    {
                        backId = i + t;
                    }
                    double jiaodu = cosCalculator(aFeat[frontId], aFeat[thisId], aFeat[backId]);//求角度
                    yon[t - 1] = jiaodu > userSet;
                }

                //判定条件为:以上两条件满足其一则被选为平角,并输出为结果

                //当两有任意一个角度大于 160度. 则认为是平角
                if (yon.Contains(true))
                {
                    //if (zjGroup.Count != null)
                    //{
                    //    zjGroupL.Add(zjGroup.ToArray());
                    //    zjGroup.Clear();
                    //}
                    pjGroup.Add(aFeat[i]);
                }
                //否则认为是直角
                else
                {
                    //if (pjGroup.Count >3 )
                    //{
                    //    pjGroupL.Add(pjGroup.ToArray());
                    //    pjGroup.Clear();
                    //}
                    zjGroup.Add(aFeat[i]);
                }
            }

            ///输出Featuer

            OSGeo.OGR.FeatureDefn featDf  = new OSGeo.OGR.FeatureDefn("");
            OSGeo.OGR.Feature     outFeat = new OSGeo.OGR.Feature(featDf);
            OSGeo.OGR.Geometry    outGeom = new OSGeo.OGR.Geometry(OSGeo.OGR.wkbGeometryType.wkbPolygon);
            OSGeo.OGR.Geometry    subGeom = new OSGeo.OGR.Geometry(OSGeo.OGR.wkbGeometryType.wkbLinearRing);

            for (int g = 0; g < zjGroup.Count(); g++)
            {
                Point a = zjGroup[g];
                subGeom.AddPoint(a.X, a.Y, a.Z);
            }
            if (subGeom.GetPointCount() < 4)
            {
                return(null);
            }
            subGeom.CloseRings();
            outGeom.AddGeometry(subGeom);
            outFeat.SetGeometry(outGeom);
            return(outFeat);
        }