Ejemplo n.º 1
0
        public List <NeighborsSegment> GetCommonNeighborSegmentsByType(LandPolygon polygonNeighbor, TypeNeighbor typeNeighbor)
        {
            List <NeighborsSegment> neighborSegments = this.GetCommonNeighborSegments(polygonNeighbor);

            if (!this.IsAllPointsParcelCommonNeighbor(polygonNeighbor))
            {
                neighborSegments = ServiceNeighborsSegments.JoinAdjoiningSegments(neighborSegments, false);
            }

            return(neighborSegments.FindAll
                   (
                       delegate(NeighborsSegment segment)
            {
                return segment.TypeNeighbor == typeNeighbor;
            }
                   ));
        }
Ejemplo n.º 2
0
        public static Dictionary <LandPolygon, TypeContour> GetContours(LandPolygon polygon)
        {
            List <PolygonSegment>   allSegments = polygon.GetPolygonSegments();
            List <NeighborsSegment> segments    = new List <NeighborsSegment>();

            foreach (PolygonSegment segment in allSegments)
            {
                segments.Add(new NeighborsSegment(segment, TypeNeighbor.Undefined));
            }

            segments = ServiceNeighborsSegments.JoinAdjoiningSegments(segments, true);

            Dictionary <LandPolygon, TypeContour> contours = new Dictionary <LandPolygon, TypeContour>();

            NeighborsSegment curSegment;

            AcGe.Point2d backPoint = segments[0].MediumPoint;

            LandPolygon contour = new LandPolygon(polygon.Info);

            while (segments.Count > 0)
            {
                List <NeighborsSegment> findSegments = ServiceNeighborsSegments.FindNeighborSegments(segments, backPoint);

                if (findSegments.Count > 0)
                {
                    curSegment = findSegments[0];

                    contour.Points.Add(curSegment.MediumPoint);

                    backPoint = curSegment.FrontPoint;
                    segments.Remove(segments.Find(f => f.Equals(curSegment)));
                }
                else
                {
                    backPoint = segments[0].MediumPoint;

                    contours.Add(contour, TypeContour.Internal);
                    contour = new LandPolygon(polygon.Info);
                }
            }

            contours.Add(contour, TypeContour.Internal);

            return(contours);
        }
Ejemplo n.º 3
0
        public List <LandPolygon> GetNeighborLines(LandPolygon polygon)
        {
            if (this.IsCommonPoints(polygon))
            {
                List <LandPolygon> neighborLines = new List <LandPolygon>();
                LandPolygon        neighborLine  = new LandPolygon(polygon.Info);

                List <NeighborsSegment> startingNeighborSegments =
                    this.GetCommonNeighborSegmentsByType(polygon, TypeNeighbor.Starting);

                List <NeighborsSegment> endingNeighborSegments =
                    this.GetCommonNeighborSegmentsByType(polygon, TypeNeighbor.Ending);

                List <NeighborsSegment> onlyOnePointOutsideNeighborSegments =
                    this.GetCommonNeighborSegmentsByType(polygon, TypeNeighbor.OnlyOnePoint_Outside);

                List <NeighborsSegment> onlyOnePointInsideNeighborSegments =
                    this.GetCommonNeighborSegmentsByType(polygon, TypeNeighbor.OnlyOnePoint_Inside);

                List <NeighborsSegment> intermediateNeighborSegments =
                    this.GetCommonNeighborSegmentsByType(polygon, TypeNeighbor.Intermediate);

                if (this.Points.Count - intermediateNeighborSegments.Count == 0)
                {
                    neighborLines.Add(polygon);
                }
                else
                {
                    AcGe.Point2d backPoint = AcGe.Point2d.Origin;

                    foreach (NeighborsSegment startingNeighborSegment in startingNeighborSegments)
                    {
                        neighborLines.Add
                        (
                            ServiceNeighborsSegments
                            .ExtractNeighborByStartingSegment
                                (this, polygon, startingNeighborSegment)
                        );
                    }

                    AcGe.Point2d[] pointsOnlyOnePointOutside;

                    foreach (NeighborsSegment onlyOnePointOutsideNeighborSegment in onlyOnePointOutsideNeighborSegments)
                    {
                        pointsOnlyOnePointOutside = new AcGe.Point2d[]
                        {
                            onlyOnePointOutsideNeighborSegment.FrontPoint,
                            onlyOnePointOutsideNeighborSegment.MediumPoint,
                            onlyOnePointOutsideNeighborSegment.BackPoint
                        };
                        neighborLines.Add
                        (
                            new LandPolygon
                            (
                                polygon.Info,
                                new AcGe.Point2dCollection(pointsOnlyOnePointOutside)
                            )
                        );
                    }
                }

                return(neighborLines);
            }

            return(null);
        }