Beispiel #1
0
            private bool HandleAsFlat(NeighboredSegmentsSubpart segmentPart,
                                      double fullFraction,
                                      ContinuationFinder continuationFinder)
            {
                var p = new FeaturePoint(segmentPart.BaseFeature, segmentPart.TableIndex,
                                         segmentPart.PartIndex, fullFraction);

                List <NeighboredSegmentsSubpart> continuations =
                    continuationFinder.GetContinuations(p, new List <SegmentsSubpart>(), false);

                if (continuations == null)
                {
                    return(AdaptUnconnected);
                }

                var junctionSegments = new List <NeighboredSegmentsSubpart>();

                foreach (NeighboredSegmentsSubpart continuation in continuations)
                {
                    if (p.Feature == continuation.BaseFeature &&
                        p.TableIndex == continuation.TableIndex &&
                        p.Part == continuation.PartIndex &&
                        Math.Abs(p.FullFraction - continuation.FullStartFraction) < 0.01)
                    {
                        junctionSegments.Add(continuation);
                        continue;
                    }

                    if (NotReportedCondition != null &&
                        NotReportedCondition.IsFulfilled(segmentPart.BaseFeature,
                                                         segmentPart.TableIndex,
                                                         continuation.BaseFeature,
                                                         continuation.TableIndex))
                    {
                        continue;
                    }

                    if (string.IsNullOrEmpty(JunctionIsEndExpression))
                    {
                        return(false);
                    }

                    junctionSegments.Add(continuation);
                }

                if (junctionSegments.Count > 0)
                {
                    var rule = new QaConnectionRule(new[] { junctionSegments[0].BaseFeature.Table },
                                                    new List <string> {
                        JunctionIsEndExpression
                    });
                    TableView[] tableFilterHelpers;
                    IList <QaConnectionRuleHelper> helpers = QaConnectionRuleHelper.CreateList(
                        new[] { rule },
                        out
                        tableFilterHelpers);

                    foreach (NeighboredSegmentsSubpart junctionSegment in junctionSegments)
                    {
                        int tableIndex = junctionSegment.TableIndex;

                        TableView baseHelper = tableFilterHelpers[tableIndex];

                        DataRow helperRow = baseHelper.Add(junctionSegment.BaseFeature);
                        Assert.NotNull(helperRow, "no row returned");

                        {
                            helperRow[QaConnections.StartsIn] = segmentPart.FullStartFraction <
                                                                segmentPart.FullEndFraction;
                        }
                    }

                    foreach (QaConnectionRuleHelper ruleHelper in helpers)
                    {
                        // check if all rows comply to the current rule
                        int connectedElementsCount = junctionSegments.Count;
                        var matchingRowsCount      = 0;
                        for (var tableIndex = 0; tableIndex < 1; tableIndex++)
                        {
                            matchingRowsCount += ruleHelper
                                                 .MainRuleFilterHelpers[tableIndex]
                                                 .FilteredRowCount;
                        }

                        Assert.True(matchingRowsCount <= connectedElementsCount,
                                    "Unexpected matching rows count: {0}; total connected rows: {1}",
                                    matchingRowsCount, connectedElementsCount);

                        if (matchingRowsCount == connectedElementsCount &&
                            ruleHelper.VerifyCountRules())
                        {
                            // all rows comply to the current rule,
                            // so one rule if fulfilled and no further checking needed
                            return(true);
                        }
                    }
                }

                return(AdaptUnconnected);
            }
Beispiel #2
0
            private IEnumerable <SegmentProxyInfo> GetSegmentProxies(
                [NotNull] NeighboredSegmentsSubpart segmentsSubpart,
                [NotNull] ContinuationFinder continuationFinder,
                bool atStart)
            {
                FeaturePoint continuationKey;

                if (atStart)
                {
                    for (int iSegment = segmentsSubpart.FullMinFraction;
                         iSegment < segmentsSubpart.FullMaxFraction;
                         iSegment++)
                    {
                        yield return(GetSegmentproxyInfo(segmentsSubpart, iSegment));
                    }

                    continuationKey = new FeaturePoint(segmentsSubpart.BaseFeature,
                                                       segmentsSubpart.TableIndex,
                                                       segmentsSubpart.PartIndex,
                                                       segmentsSubpart.FullMaxFraction);
                }
                else
                {
                    for (int iSegment = segmentsSubpart.FullMaxFraction - 1;
                         iSegment >= segmentsSubpart.FullMinFraction;
                         iSegment--)
                    {
                        yield return(GetSegmentproxyInfo(segmentsSubpart, iSegment));
                    }

                    continuationKey = new FeaturePoint(segmentsSubpart.BaseFeature,
                                                       segmentsSubpart.TableIndex,
                                                       segmentsSubpart.PartIndex,
                                                       segmentsSubpart.FullMinFraction);
                }

                List <NeighboredSegmentsSubpart> continuations =
                    continuationFinder.GetContinuations(continuationKey,
                                                        new List <SegmentsSubpart>(), false);

                if (continuations == null)
                {
                    yield break;
                }

                foreach (NeighboredSegmentsSubpart continuation in continuations)
                {
                    if (continuation.BaseFeature.OID != segmentsSubpart.BaseFeature.OID ||
                        continuation.TableIndex != segmentsSubpart.TableIndex ||
                        continuation.PartIndex != segmentsSubpart.PartIndex)
                    {
                        continue;
                    }

                    if (atStart &&
                        continuation.FullMinFraction != segmentsSubpart.FullMaxFraction)
                    {
                        continue;
                    }

                    if (!atStart &&
                        continuation.FullMaxFraction != segmentsSubpart.FullMinFraction)
                    {
                        continue;
                    }

                    foreach (
                        SegmentProxyInfo segmentProxy in
                        GetSegmentProxies(continuation, continuationFinder, atStart))
                    {
                        yield return(segmentProxy);
                    }
                }
            }