Ejemplo n.º 1
0
        /// <summary>
        /// 求父区间与若干子集并集的差集
        /// </summary>
        /// <param name="total">父集</param>
        /// <param name="source">子集集合</param>
        /// <returns>差集集合</returns>
        public static List <RoadInterval> InverseInterval(RoadInterval total, List <RoadInterval> source)
        {
            List <RoadInterval> result       = new List <RoadInterval>();
            List <RoadInterval> sortedSource = source.OrderBy(x => x.start).ToList();

            if (source.Count == 0)
            {
                result.Add(total);
                return(result);
            }
            if (total.start < sortedSource.First().start)
            {
                result.Add(new RoadInterval {
                    start = total.start, end = sortedSource[0].start
                });
            }
            for (int i = 0; i < sortedSource.Count - 1; i++)
            {
                if (sortedSource[i].end < sortedSource[i + 1].start)
                {
                    result.Add(new RoadInterval {
                        start = sortedSource[i].end, end = sortedSource[i + 1].start
                    });
                }
            }
            if (total.end > sortedSource.Last().end)
            {
                result.Add(new RoadInterval {
                    start = sortedSource.Last().end, end = total.end
                });
            }
            return(result);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 获取曲线子集
        /// </summary>
        /// <param name="curve">曲线</param>
        /// <param name="interval">曲线子集的长度区间</param>
        /// <returns>曲线子集</returns>
        public static Curve GetSubCurve(Curve curve, RoadInterval interval)
        {
            double             start  = curve.GetParamAtDist(interval.start);
            double             end    = curve.GetParamAtDist(interval.end);
            DBObjectCollection splits = curve.GetSplitCurves(new DoubleCollection(new double[] { start, end }));

            if (splits.Count == 1 || interval.start == 0)
            {
                return(splits[0] as Curve);
            }
            else
            {
                return(splits[1] as Curve);
            }
        }