public PerpendicularSegmentPair([NotNull] AzimuthSegment baseSegment,
                                 [NotNull] AzimuthSegment perpendicularSegment)
 {
     BaseSegment          = baseSegment;
     PerpendicularSegment = perpendicularSegment;
     AzimuthDifference    = Math.Abs(perpendicularSegment.Azimuth - baseSegment.Azimuth);
 }
            protected IEnumerable <ParallelSegmentPair> GetParallelSegmentPairs(
                IEnumerable <SegmentProxy> segments)
            {
                List <AzimuthSegment> horizontalSegments = ReadHorizontalSegments(segments);

                horizontalSegments.Sort(AzimuthSegment.CompareAzimuth);
                List <AzimuthSegment> sortedHorizontalSegments = horizontalSegments;

                for (var baseIndex = 0; baseIndex < sortedHorizontalSegments.Count; baseIndex++)
                {
                    AzimuthSegment baseSegment = sortedHorizontalSegments[baseIndex];
                    double         baseAzimuth = baseSegment.Azimuth;

                    double minSearchAzimuth = baseAzimuth - _nearAngleRad;
                    double maxSearchAzimuth = baseAzimuth + _nearAngleRad;
                    for (int parallelIndex = baseIndex + 1;
                         parallelIndex < sortedHorizontalSegments.Count;
                         parallelIndex++)
                    {
                        AzimuthSegment candidate = sortedHorizontalSegments[parallelIndex];
                        if (candidate.Azimuth < maxSearchAzimuth ||
                            candidate.Azimuth - Math.PI > minSearchAzimuth)
                        {
                            yield return(new ParallelSegmentPair(baseSegment, candidate));
                        }
                    }
                }
            }
        protected override int ExecuteCore(IRow row, int tableIndex)
        {
            var errorCount = 0;
            var feature    = row as IFeature;

            if (feature == null)
            {
                return(errorCount);
            }

            var multiPatch = feature.Shape as IMultiPatch;

            if (multiPatch == null)
            {
                return(errorCount);
            }

            var errorSegments = new List <PerpendicularSegmentPair>();
            PerpendicularSegmentsProvider perpendicularSegmentsProvider =
                GetPerpendicularSegmentsProvider(feature);

            foreach (PerpendicularSegmentPair perpendicularSegmentPair in
                     perpendicularSegmentsProvider.ReadPerpendicularSegments())
            {
                double nonPerpendicularAngle =
                    Math.Abs(Math.PI / 2 - perpendicularSegmentPair.AzimuthDifference);
                if (nonPerpendicularAngle <= _azimuthToleranceRad)
                {
                    continue;
                }

                AzimuthSegment baseSegment          = perpendicularSegmentPair.BaseSegment;
                AzimuthSegment perpendicularSegment =
                    perpendicularSegmentPair.PerpendicularSegment;

                double baseResolution          = baseSegment.GetAzimuthResolution();
                double perpendicularResolution = perpendicularSegment.GetAzimuthResolution();
                double angleResolution         = Math.Max(baseResolution, perpendicularResolution);
                if (angleResolution > _azimuthToleranceRad &&
                    nonPerpendicularAngle < angleResolution)
                {
                    continue;
                }

                errorSegments.Add(perpendicularSegmentPair);
            }

            errorCount += ReportErrors(errorSegments, row);

            return(errorCount);
        }
            public ParallelSegmentPair([NotNull] AzimuthSegment baseSegment,
                                       [NotNull] AzimuthSegment parallelSegment)
            {
                BaseSegment     = baseSegment;
                ParallelSegment = parallelSegment;
                double azimuthDifference = Math.Abs(parallelSegment.Azimuth - baseSegment.Azimuth);

                if (azimuthDifference > Math.PI / 2.0)
                {
                    azimuthDifference = Math.PI - azimuthDifference;
                }

                AzimuthDifference = azimuthDifference;
            }
            GetPerpendicularSegmentPairs()
            {
                for (var baseIndex = 0; baseIndex < _sortedHorizontalSegments.Count; baseIndex++)
                {
                    AzimuthSegment baseSegment = _sortedHorizontalSegments[baseIndex];

                    double baseAzimuth = baseSegment.Azimuth;

                    WKSPointZ baseStart =
                        QaGeometryUtils.GetWksPoint(baseSegment.Segment.GetStart(true));

                    WKSPointZ baseEnd =
                        QaGeometryUtils.GetWksPoint(baseSegment.Segment.GetEnd(true));

                    double exactPerpendicularAzimuth = baseAzimuth + Math.PI / 2;
                    double minSearchAzimuth          = exactPerpendicularAzimuth - NearAngleRad;
                    double maxSearchAzimuth          = exactPerpendicularAzimuth + NearAngleRad;

                    for (int perpendicularIndex = baseIndex + 1;
                         perpendicularIndex < _sortedHorizontalSegments.Count;
                         perpendicularIndex++)
                    {
                        AzimuthSegment candidate = _sortedHorizontalSegments[perpendicularIndex];

                        if (candidate.Azimuth <= minSearchAzimuth)
                        {
                            continue;
                        }

                        if (candidate.Azimuth >= maxSearchAzimuth)
                        {
                            break;
                        }

                        WKSPointZ candidateStart =
                            QaGeometryUtils.GetWksPoint(candidate.Segment.GetStart(true));

                        WKSPointZ candidateEnd =
                            QaGeometryUtils.GetWksPoint(candidate.Segment.GetEnd(true));

                        if (IsConnected(baseStart, candidateStart) ||
                            IsConnected(baseStart, candidateEnd) ||
                            IsConnected(baseEnd, candidateStart) ||
                            IsConnected(baseEnd, candidateEnd))
                        {
                            yield return(new PerpendicularSegmentPair(baseSegment, candidate));
                        }
                    }
                }
            }
            GetPerpendicularSegmentPairs()
            {
                List <AzimuthSegment> horizontalSegments = ReadAllHorizontalSegments(_multiPatch);

                horizontalSegments.Sort(AzimuthSegment.CompareAzimuth);

                List <AzimuthSegment> sortedHorizontalSegments = horizontalSegments;

                for (var baseIndex = 0; baseIndex < sortedHorizontalSegments.Count; baseIndex++)
                {
                    AzimuthSegment baseSegment = sortedHorizontalSegments[baseIndex];
                    double         baseAzimuth = baseSegment.Azimuth;

                    double exactPerpendicularAzimuth = baseAzimuth + Math.PI / 2;
                    double minSearchAzimuth          = exactPerpendicularAzimuth - NearAngleRad;
                    double maxSearchAzimuth          = exactPerpendicularAzimuth + NearAngleRad;

                    for (int perpendicularIndex = baseIndex + 1;
                         perpendicularIndex < sortedHorizontalSegments.Count;
                         perpendicularIndex++)
                    {
                        AzimuthSegment candidate = sortedHorizontalSegments[perpendicularIndex];
                        if (candidate.Azimuth <= minSearchAzimuth)
                        {
                            continue;
                        }

                        if (candidate.Azimuth >= maxSearchAzimuth)
                        {
                            break;
                        }

                        yield return(new PerpendicularSegmentPair(baseSegment, candidate));
                    }
                }
            }
Example #7
0
 public static int CompareAzimuth(AzimuthSegment x, AzimuthSegment y)
 {
     return(x.Azimuth.CompareTo(y.Azimuth));
 }