/// <summary> /// Return the point within the section based off of footage information /// </summary> /// <param name="Foot"></param> /// <returns></returns> public PointClass LocateFootage(FootageClass Foot) { PointClass LocateFootageOut = new PointClass(); LineClass right = new LineClass(); LineClass bottom = new LineClass(); LineClass left = new LineClass(); LineClass top = new LineClass(); LineClass second = new LineClass(); LineClass first = new LineClass(); PointClass temp = new PointClass(); if (IsValid()) { // *** SE Corner Based of south and east borders if (Foot.CombindDir() == "NW") { bottom.CreateFromPoints(Corners[2], Corners[3]); right.CreateFromPoints(Corners[0], Corners[3]); first.CreateSlopePoint(right.M, bottom.CPoint((Corners[3].X - bottom.Adjustment(Foot.EastWestValueMeters)))); second.CreateSlopePoint(bottom.M, right.CPoint((Corners[3].X + (Math.Sign(right.M) * right.Adjustment(Foot.NorthSouthValueMeters))))); // *** SW corner based of south and west borders } else if ((Foot.CombindDir() == "NE")) { bottom.CreateFromPoints(Corners[2], Corners[3]); left.CreateFromPoints(Corners[1], Corners[2]); first.CreateSlopePoint(left.M, bottom.CPoint((Corners[2].X + bottom.Adjustment(Foot.EastWestValueMeters)))); second.CreateSlopePoint(bottom.M, left.CPoint(Corners[2].X + (Math.Sign(left.M) * left.Adjustment(Foot.NorthSouthValueMeters)))); // *** NW corner based off west and north borders } else if ((Foot.CombindDir() == "SE")) { top.CreateFromPoints(Corners[0], Corners[1]); left.CreateFromPoints(Corners[1], Corners[2]); first.CreateSlopePoint(left.M, top.CPoint((Corners[1].X + top.Adjustment(Foot.EastWestValueMeters)))); second.CreateSlopePoint(top.M, left.CPoint((Corners[1].X - (Math.Sign(left.M) * left.Adjustment(Foot.NorthSouthValueMeters))))); // *** NE corner based off east and north border } else if ((Foot.CombindDir() == "SW")) { top.CreateFromPoints(Corners[0], Corners[1]); right.CreateFromPoints(Corners[0], Corners[3]); first.CreateSlopePoint(right.M, top.CPoint((Corners[0].X - bottom.Adjustment(Foot.EastWestValueMeters)))); second.CreateSlopePoint(top.M, right.CPoint((Corners[0].X - (Math.Sign(right.M) * right.Adjustment(Foot.NorthSouthValueMeters))))); } temp = MeasureFunctions.LineIntercection(first, second); LocateFootageOut = temp; } else { temp.X = -1; temp.Y = -1; LocateFootageOut = temp; } return(LocateFootageOut); }
/// <summary> /// Return the footage for the point within the section /// </summary> /// <param name="P"></param> /// <returns></returns> public FootageClass Point2Footage(PointClass P) { FootageClass Ans = new FootageClass(); LineClass left = new LineClass(); LineClass right = new LineClass(); LineClass bottom = new LineClass(); LineClass top = new LineClass(); LineClass hori = new LineClass(); LineClass vert = new LineClass(); double temp1; double temp2; double temp3; double temp4; int temp = 0; FootageClass tFootage = new FootageClass(); temp1 = MeasureFunctions.DistanceBetween(Corners[0], P); temp2 = MeasureFunctions.DistanceBetween(Corners[1], P); temp3 = MeasureFunctions.DistanceBetween(Corners[2], P); temp4 = MeasureFunctions.DistanceBetween(Corners[3], P); if (temp1 < temp2 && temp1 < temp3 && temp1 < temp4) { temp = 1; } else if (temp2 < temp1 && temp2 < temp3 && temp2 < temp4) { temp = 2; } else if (temp3 < temp1 && temp3 < temp2 && temp3 < temp4) { temp = 3; } else if (temp4 < temp1 && temp4 < temp2 && temp4 < temp3) { temp = 4; } if (temp == 1) { top.CreateFromPoints(Corners[0], Corners[1]); right.CreateFromPoints(Corners[0], Corners[3]); hori.CreateSlopePoint(top.M, P); vert.CreateSlopePoint(right.M, P); int northing = Convert.ToInt32(MeasureFunctions.DistanceBetween(MeasureFunctions.LineIntercection(top, vert), P)); int easting = Convert.ToInt32(MeasureFunctions.DistanceBetween(MeasureFunctions.LineIntercection(right, hori), P)); tFootage.SetFootageMeters(northing, "S", easting, "W"); } else if (temp == 2) { top.CreateFromPoints(Corners[0], Corners[1]); left.CreateFromPoints(Corners[1], Corners[2]); hori.CreateSlopePoint(top.M, P); vert.CreateSlopePoint(left.M, P); int northing = Convert.ToInt32(MeasureFunctions.DistanceBetween(MeasureFunctions.LineIntercection(top, vert), P)); int easting = Convert.ToInt32(MeasureFunctions.DistanceBetween(MeasureFunctions.LineIntercection(left, hori), P)); tFootage.SetFootageMeters(northing, "S", easting, "E"); } else if (temp == 3) { bottom.CreateFromPoints(Corners[2], Corners[3]); left.CreateFromPoints(Corners[1], Corners[2]); hori.CreateSlopePoint(bottom.M, P); vert.CreateSlopePoint(left.M, P); int northing = Convert.ToInt32(MeasureFunctions.DistanceBetween(MeasureFunctions.LineIntercection(bottom, vert), P)); int easting = Convert.ToInt32(MeasureFunctions.DistanceBetween(MeasureFunctions.LineIntercection(left, hori), P)); tFootage.SetFootageMeters(northing, "N", easting, "E"); } else if (temp == 4) { bottom.CreateFromPoints(Corners[2], Corners[3]); right.CreateFromPoints(Corners[0], Corners[3]); hori.CreateSlopePoint(bottom.M, P); vert.CreateSlopePoint(right.M, P); int northing = Convert.ToInt32(MeasureFunctions.DistanceBetween(MeasureFunctions.LineIntercection(bottom, vert), P)); int easting = Convert.ToInt32(MeasureFunctions.DistanceBetween(MeasureFunctions.LineIntercection(right, hori), P)); tFootage.SetFootageMeters(northing, "N", easting, "W"); } return(tFootage); }