Example #1
0
        private IEnumerable <OverlappingMeasures> GetOverlaps(
            [NotNull] object routeId,
            [NotNull] IEnumerable <CurveMeasureRange> ranges)
        {
            // TODO recursively intersect the overlaps? --> get all features in one overlap that have a given range in common

            IList <CurveMeasureRange> sorted = GetSorted(ranges);

            for (int i = 0; i < sorted.Count - 1; i++)
            {
                CurveMeasureRange range1 = sorted[i];

                int start = i + 1;
                for (int j = start; j < sorted.Count; j++)
                {
                    CurveMeasureRange range2 = sorted[j];

                    OverlappingMeasures overlap = GetOverlap(range1, range2, routeId);
                    if (overlap != null)
                    {
                        yield return(overlap);
                    }
                }
            }
        }
Example #2
0
        private double GetSquaredXyTolerance([NotNull] CurveMeasureRange r1,
                                             [NotNull] CurveMeasureRange r2)
        {
            double xyTolerance = GetXyTolerance(r1, r2);

            return(xyTolerance * xyTolerance);
        }
Example #3
0
        private OverlappingMeasures GetOverlap([NotNull] CurveMeasureRange r1,
                                               [NotNull] CurveMeasureRange r2,
                                               [NotNull] object routeId)
        {
            Assert.ArgumentCondition(r1.MMin <= r2.MMin,
                                     "r1.MMin must not be larger than r2.MMin");

            double mTolerance = GetMTolerance(r1, r2);

            if (r1.MMax < r2.MMin)
            {
                // not overlapping
                return(null);
            }

            if (r1.MMax - r2.MMin < mTolerance)
            {
                // r1 overlaps r2 by less than the m tolerance
                if (AreConnectedAtMMaxMMin(r1, r2))
                {
                    // ... and the end points are connected and correspond to r1.MMax and r2.Min
                    return(null);
                }
            }

            double mMin = Math.Max(r1.MMin, r2.MMin);
            double mMax = Math.Min(r1.MMax, r2.MMax);

            var result = new OverlappingMeasures(routeId, mMin, mMax);

            result.Add(GetTestRowReference(r1));
            result.Add(GetTestRowReference(r2));

            return(result);
        }
Example #4
0
        private bool AreConnectedAtMMaxMMin([NotNull] CurveMeasureRange r1,
                                            [NotNull] CurveMeasureRange r2)
        {
            if (r1.MMaxEndPoint == null || r2.MMinEndPoint == null)
            {
                return(false);
            }

            double distanceSquared =
                r1.MMaxEndPoint.GetSquaredDistanceTo(r2.MMinEndPoint);

            return(distanceSquared <= GetSquaredXyTolerance(r1, r2));
        }
Example #5
0
        private static void AssignEndPoint([NotNull] CurveMeasureRange curveMeasureRange,
                                           [NotNull] IPoint point, double mMin, double mMax)
        {
            double m = point.M;

            if (Math.Abs(m - mMin) < double.Epsilon)
            {
                curveMeasureRange.MMinEndPoint = GetLocation(point);
            }

            if (Math.Abs(m - mMax) < double.Epsilon)
            {
                curveMeasureRange.MMaxEndPoint = GetLocation(point);
            }
        }
Example #6
0
        public void Add([NotNull] object routeId,
                        [NotNull] CurveMeasureRange curveMeasureRange)
        {
            Assert.ArgumentNotNull(routeId, nameof(routeId));
            Assert.ArgumentNotNull(curveMeasureRange, nameof(curveMeasureRange));

            List <CurveMeasureRange> ranges;

            if (!_rangesByRoute.TryGetValue(routeId, out ranges))
            {
                ranges = new List <CurveMeasureRange>();

                _rangesByRoute.Add(routeId, ranges);
            }

            ranges.Add(curveMeasureRange);
        }
Example #7
0
        private static CurveMeasureRange CreateMeasureRange([NotNull] IPolyline polyline,
                                                            double mMin, double mMax,
                                                            int oid, int tableIndex,
                                                            int partIndex)
        {
            Assert.ArgumentNotNull(polyline, nameof(polyline));

            var result = new CurveMeasureRange(oid, tableIndex, mMin, mMax, partIndex);

            polyline.QueryFromPoint(_pointTemplate.Value);

            AssignEndPoint(result, _pointTemplate.Value, mMin, mMax);

            polyline.QueryToPoint(_pointTemplate.Value);

            AssignEndPoint(result, _pointTemplate.Value, mMin, mMax);

            return(result);
        }
Example #8
0
        public static IEnumerable <CurveMeasureRange> GetMeasureRanges(
            [NotNull] IPolyline polyline,
            int oid,
            int tableIndex)
        {
            Assert.ArgumentNotNull(polyline, nameof(polyline));

            var parts = polyline as IGeometryCollection;

            if (parts == null || parts.GeometryCount == 1)
            {
                CurveMeasureRange range = GetMeasureRange(polyline, oid, tableIndex);

                if (range != null)
                {
                    yield return(range);
                }
            }
            else
            {
                int partCount = parts.GeometryCount;
                for (var partIndex = 0; partIndex < partCount; partIndex++)
                {
                    IGeometry part = parts.Geometry[partIndex];

                    var partPolyline = (IPolyline)GeometryUtils.GetHighLevelGeometry(part);

                    CurveMeasureRange range = GetMeasureRange(
                        partPolyline, oid, tableIndex, partIndex);

                    if (range != null)
                    {
                        yield return(range);
                    }
                }
            }
        }
Example #9
0
 private static TestRowReference GetTestRowReference(
     [NotNull] CurveMeasureRange curveMeasureRange)
 {
     return(new TestRowReference(curveMeasureRange.ObjectId,
                                 curveMeasureRange.TableIndex));
 }
Example #10
0
 private double GetXyTolerance([NotNull] CurveMeasureRange r1,
                               [NotNull] CurveMeasureRange r2)
 {
     return(Math.Max(_xyTolerances[r1.TableIndex],
                     _xyTolerances[r2.TableIndex]));
 }