private static List <LandPolygon> SortingNeighbors(LandPolygon parcel, List <LandPolygon> neighbors) { List <LandPolygon> sortedNeighbors = new List <LandPolygon>(); List <LandPolygon> temp = new List <LandPolygon>(); AcGe.Point2d point0 = AcGe.Point2d.Origin; foreach (AcGe.Point2d pointParcel in parcel.Points) { temp = neighbors.FindAll ( delegate(LandPolygon neighbor) { return(neighbor.Points.ToArray()[1].GetDistanceTo(pointParcel) == 0); } ); /* * if (temp.Count == 1) * { * sortedNeighbors.Add(temp.ToArray()[0]); * } * else */ if (temp.Count > 0) { temp.Sort ( delegate(LandPolygon polygon1, LandPolygon polygon2) { AcGe.Line2d line0 = new AcGe.Line2d(pointParcel, point0); AcGe.Point2d point1 = polygon1.Points.ToArray()[0]; AcGe.Line2d line1 = new AcGe.Line2d(pointParcel, point1); AcGe.Point2d point2 = polygon2.Points.ToArray()[0]; AcGe.Line2d line2 = new AcGe.Line2d(pointParcel, point2); double angle1 = line0.Direction.GetAngleTo(line1.Direction); double angle2 = line0.Direction.GetAngleTo(line2.Direction); return(angle1.CompareTo(angle2)); } ); foreach (LandPolygon polygon in temp) { sortedNeighbors.Add(polygon); } } point0 = pointParcel; } return(sortedNeighbors); }
private static List <LandPolygon> GetLandPoligonsFromIn4Polygon <T>(List <T> list) where T : In4Polygon { List <LandPolygon> listLand = new List <LandPolygon>(); LandPolygon landPolygon; foreach (T land in list) { landPolygon = new LandPolygon(); landPolygon.Info = GetInfoFromIn4Polygon <T>(land); landPolygon.Points = GetPoints2dFromIn4Polygon(land); listLand.Add(landPolygon); } return(listLand); }
internal static HatchPolygon GetHatchLimiting(LandPolygon poligon) { List <HatchPolygon> list = ServiceXml.ReadXml <List <HatchPolygon> >(new LocalPath("LoSa_Land").FindFullPathFromXml("PathHatchPolygon")); string type = poligon.FindInfo("OK").Value; string name = poligon.FindInfo("OX").Value; HatchPolygon hatchPolygon = list.Find ( delegate(HatchPolygon hatchLimiting) { return(hatchLimiting.Type == type && hatchLimiting.Name == name); } ); return(hatchPolygon); }
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); }
public static List <LandPolygon> GetAllPolygons(BL blockLand) { List <LandPolygon> parcels = new List <LandPolygon>(); LandPolygon parcel = null; if (blockLand != null) { foreach (SR curSR in blockLand.SR) { parcel = new LandPolygon(); parcel.Info = GetInfoFromIn4Polygon <SR>(curSR); parcel.Points = GetPoints2dFromIn4Polygon(curSR); parcels.Add(parcel); } } return(parcels); }
private static List <LandPolygon> GetOtherLandForParcel(BL blockLand, SR curSR) { List <LandPolygon> otherLand = new List <LandPolygon>(); LandPolygon landPolygon; foreach (SR sr in blockLand.SR) { if (sr.SC.IndexOf(":-") > 0) { landPolygon = new LandPolygon(); landPolygon.Info = GetInfoFromIn4Polygon <SR>(sr); landPolygon.Points = GetPoints2dFromIn4Polygon(sr); otherLand.Add(landPolygon); } } return(otherLand); }
private static List <NeighborsAlongContour> GetNeighborsForParcel(BL blockLand, SR curSR) { List <NeighborsAlongContour> neighbors = new List <NeighborsAlongContour>(); LandPolygon polygonParcel = GetPolygonForCadarstralNumber(blockLand, curSR.SC); Dictionary <LandPolygon, TypeContour> contoursParcel = GetContours(polygonParcel); List <LandPolygon> allNeighbors = new List <LandPolygon>(); allNeighbors.AddRange(GetAllPolygons(blockLand)); allNeighbors.AddRange(GetBlockLandNeighbors(blockLand)); // Neighboring Parcels & BlockLandNeighbors foreach (KeyValuePair <LandPolygon, TypeContour> contourParcel in contoursParcel) { neighbors.Add(GetNeighborsAlongContour(allNeighbors, contourParcel.Key)); } return(neighbors); }
private static List <LandPolygon> GetBlockLandNeighbors(BL blockLand) { List <LandPolygon> neighbors = new List <LandPolygon>(); LandPolygon landPolygon; foreach (NB nb in blockLand.NB) { landPolygon = new LandPolygon(); landPolygon.Info = GetInfoFromIn4Polygon <NB>(nb); AcGe.Point2d[] pointsNeighbor = GetPoints2dFromIn4Polygon(nb).ToArray(); Array.Reverse(pointsNeighbor); landPolygon.Points = new AcGe.Point2dCollection(pointsNeighbor); neighbors.Add(landPolygon); } return(neighbors); }
internal static HatchPolygon GetHatchLand(LandPolygon poligon) { List <HatchPolygon> list = ServiceXml.ReadXml <List <HatchPolygon> >(new LocalPath("LoSa_Land").FindFullPathFromXml("PathHatchPolygon")); HatchPolygon hatchPolygon = null; LandInfo infoCC = poligon.FindInfo("CC"); if (infoCC != null) { string type = infoCC.Value; hatchPolygon = list.Find ( delegate(HatchPolygon hatchLand) { return(hatchLand.Type == type); } ); } return(hatchPolygon); }
public static List <NeighborsSegment> GetFirstStartingNeighborsSegments ( LandPolygon parcel, LandPolygon neighbor ) { List <NeighborsSegment> neighborsSegments = new List <NeighborsSegment>(); neighborsSegments.AddRange ( parcel.GetCommonNeighborSegmentsByType(neighbor, TypeNeighbor.Starting) ); neighborsSegments.AddRange ( parcel.GetCommonNeighborSegmentsByType(neighbor, TypeNeighbor.OnlyOnePoint_Outside) ); List <NeighborsSegment> foundSegments = new List <NeighborsSegment>(); foreach (AcGe.Point2d point in parcel.Points) { foundSegments = neighborsSegments.FindAll ( delegate(NeighborsSegment segment) { return(segment.MediumPoint.Equals(point)); } ); if (foundSegments.Count > 0) { break; } } return(foundSegments); }
public static LandPolygon ExtractNeighborByStartingSegment ( LandPolygon parcel, LandPolygon neighbor, NeighborsSegment startingSegment ) { List <NeighborsSegment> intermediateNeighborSegments = parcel.GetCommonNeighborSegmentsByType(neighbor, TypeNeighbor.Intermediate); List <NeighborsSegment> endingNeighborSegments = parcel.GetCommonNeighborSegmentsByType(neighbor, TypeNeighbor.Ending); AcGe.Point2d backPoint = AcGe.Point2d.Origin; List <NeighborsSegment> nextSegments; NeighborsSegment nextSegment = startingSegment; LandPolygon neighborLine = new LandPolygon(neighbor.Info, false); int index = intermediateNeighborSegments.Count + endingNeighborSegments.Count; while (index != -1) { if ( nextSegment.TypeNeighbor == TypeNeighbor.Starting && nextSegment.TypeNeighbor != TypeNeighbor.OnlyOnePoint_Outside ) { neighborLine.Points.Add(nextSegment.FrontPoint); neighborLine.Points.Add(nextSegment.MediumPoint); } neighborLine.Points.Add(nextSegment.BackPoint); backPoint = nextSegment.BackPoint; if ( nextSegment.TypeNeighbor == TypeNeighbor.Ending && nextSegment.TypeNeighbor != TypeNeighbor.OnlyOnePoint_Outside ) { break; } nextSegments = FindNeighborSegments(intermediateNeighborSegments, backPoint); if (nextSegments.Count == 0) { nextSegments = FindNeighborSegments(endingNeighborSegments, backPoint); if (nextSegments.Count == 0 && startingSegment.MediumPoint.Equals(backPoint)) { neighborLine.Points.Add(startingSegment.FrontPoint); } } if (nextSegments.Count == 1) { nextSegment = nextSegments[0]; } index--; } return(neighborLine); }
private static NeighborsAlongContour GetNeighborsAlongContour(List <LandPolygon> allNeighbors, LandPolygon contourParcel) { NeighborsAlongContour contour = new NeighborsAlongContour(); foreach (LandPolygon curNeighbor in allNeighbors) { LandInfo curNeighbor_SC = curNeighbor.FindInfo("SC"); LandInfo curNeighbor_NM = curNeighbor.FindInfo("NM"); if (contourParcel.IsCoincidesDirectionBorder(curNeighbor)) { curNeighbor.ReverseBorder(); } if (contourParcel.IsCommonPoints(curNeighbor)) { //if ( ! contourParcel.FindInfo("SC").Value.Equals( curNeighbor_SC.Value ) ) if (curNeighbor_SC != null) { if (contourParcel.FindInfo("SC").Value != curNeighbor_SC.Value) { contour.Neighbors.AddRange(contourParcel.GetNeighborLines(curNeighbor)); } } else { contour.Neighbors.AddRange(contourParcel.GetNeighborLines(curNeighbor)); } } } contour.Neighbors = ServiceIn4.SortingNeighbors(contourParcel, contour.Neighbors); return(contour); }
public void сreate(LandPolygon landPolygon, double scaleTable) { throw new NotImplementedException(); }