Esempio n. 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);
                    }
                }
            }
        }
Esempio n. 2
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);
        }
        private int ReportOverlap([NotNull] OverlappingMeasures overlap)
        {
            Assert.ArgumentNotNull(overlap, nameof(overlap));

            IPolyline   lineErrorGeometry;
            IMultipoint pointErrorGeometry;
            ICollection <InvolvedRow> involvedRows = GetInvolvedRows(overlap,
                                                                     out lineErrorGeometry,
                                                                     out pointErrorGeometry);

            string description =
                string.Format(
                    "Measures are not unique for route with id = '{0}'; from M: {1} to M: {2}",
                    overlap.RouteId, overlap.MMin, overlap.MMax);

            var errorCount = 0;

            if (lineErrorGeometry != null)
            {
                errorCount += ReportError(description, lineErrorGeometry,
                                          Codes[Code.MeasuresNotUnique_WithinRoute], null,
                                          involvedRows);
            }

            if (pointErrorGeometry != null)
            {
                errorCount += ReportError(description,
                                          pointErrorGeometry,
                                          Codes[Code.MeasuresNotUnique_WithinRoute], null,
                                          involvedRows);
            }

            if (lineErrorGeometry == null && pointErrorGeometry == null)
            {
                // unable to determine error geometry, but there are involved features -> report them anyway
                errorCount += ReportError(description, null,
                                          Codes[Code.MeasuresNotUnique_WithinRoute], null,
                                          involvedRows);
            }

            return(errorCount);
        }
        private ICollection <InvolvedRow> GetInvolvedRows(
            [NotNull] OverlappingMeasures overlap,
            [CanBeNull] out IPolyline lineErrorGeometry,
            [CanBeNull] out IMultipoint pointErrorGeometry)
        {
            Assert.ArgumentNotNull(overlap, nameof(overlap));

            var involvedRows = new List <InvolvedRow>();
            var polylines    = new List <IPolyline>();
            var allPoints    = new List <IPoint>();

            foreach (TestRowReference testRowReference in overlap.Features)
            {
                IFeature feature = GetFeature(testRowReference);

                involvedRows.Add(new InvolvedRow(feature));

                var polyline = (IPolyline)feature.Shape;

                IList <IPoint> points;
                IPolyline      subcurves = MeasureUtils.GetSubcurves(polyline,
                                                                     overlap.MMin,
                                                                     overlap.MMax,
                                                                     out points);

                allPoints.AddRange(points);
                if (subcurves != null)
                {
                    polylines.Add(subcurves);
                }
            }

            lineErrorGeometry  = GetErrorGeometry(polylines);
            pointErrorGeometry = allPoints.Count > 0
                                                     ? GeometryFactory.CreateMultipoint(allPoints)
                                                     : null;

            return(involvedRows);
        }