This is what I came up with. The angle appears to be off from the field when loaded in Google earth. This is individual lines for each field. Here is it in Google earth:
Here is the code for the reader. Someone may be able to tweak the angles or the calculations for the coordinates.
public void FileLoadABLines2()
{
ABLine.moveDistance = 0;
//make sure at least a global blank AB Line file exists
string dirField = fieldsDirectory + currentFieldDirectory + "\\";
string directoryName = Path.GetDirectoryName(dirField).ToString(CultureInfo.InvariantCulture);
if ((directoryName.Length > 0) && (!Directory.Exists(directoryName)))
{ Directory.CreateDirectory(directoryName); }
string filename = directoryName + "\\ablines2.txt";
if (!File.Exists(filename))
{
using (StreamWriter writer = new StreamWriter(filename))
{
}
}
if (!File.Exists(filename))
{
TimedMessageBox(2000, gStr.gsFileError, gStr.gsMissingABLinesFile);
}
else
{
using (StreamReader reader = new StreamReader(filename))
{
try
{
string line;
ABLine.numABLines = 0;
ABLine.numABLineSelected = 0;
ABLine.lineArr?.Clear();
//read all the lines
for (int i = 0; !reader.EndOfStream; i++)
{
double Lat1 = 0;
double Long1 = 0;
double Lat2 = 0;
double Long2 = 0;
line = reader.ReadLine();
string[] words = line.Split(',');
if (words.Length != 5) break;
ABLine.lineArr.Add(new CABLines());
ABLine.lineArr[i].Name = words[0];
Lat1 = double.Parse(words[1], CultureInfo.InvariantCulture);
Long1 = double.Parse(words[2], CultureInfo.InvariantCulture);
Lat2 = double.Parse(words[3], CultureInfo.InvariantCulture);
Long2 = double.Parse(words[4], CultureInfo.InvariantCulture);
pn.DecDeg2UTM(Lat1, Long1);
double est1 = pn.DecDeg2UTM(Lat1, Long1)[0] - pn.utmEast;
double nrt1 = pn.DecDeg2UTM(Lat1, Long1)[1] - pn.utmNorth;
pn.DecDeg2UTM(Lat2, Long2);
double est2 = pn.DecDeg2UTM(Lat2, Long2)[0] - pn.utmEast;
double nrt2 = pn.DecDeg2UTM(Lat2, Long2)[1] - pn.utmNorth;
double abHead = Math.Atan2(est2 - est1,nrt2 -nrt1);
if (abHead < 0) abHead += glm.twoPI;
double headingCalc = abHead + glm.PIBy2;
ABLine.lineArr[i].heading = abHead;
ABLine.lineArr[i].origin.easting = est1;
ABLine.lineArr[i].origin.northing = nrt1;
ABLine.lineArr[i].ref1.easting = est1;
ABLine.lineArr[i].ref1.northing = nrt1;
ABLine.lineArr[i].ref2.easting = est2;
ABLine.lineArr[i].ref2.northing = nrt2;
ABLine.numABLines++;
}
}
catch (Exception er)
{
var form = new FormTimedMessage(2000, gStr.gsABLineFileIsCorrupt, "Please delete it!!!");
form.Show();
WriteErrorLog("FieldOpen, Loading ABLine, Corrupt ABLine File" + er);
}
}
FileSaveABLines();
}
if (ABLine.numABLines == 0) ABLine.numABLineSelected = 0;
if (ABLine.numABLineSelected > ABLine.numABLines) ABLine.numABLineSelected = ABLine.numABLines;
}
Here is the field folder, Just save the file and drop the .txt on the end of it. Remember that the field saves the offsets.
heaky test 2020.Oct.01 16_02.zip.txt (4.6 KB)
Edit: In reviewing the code above, I’m calling the DecDeg2Utm routine too many times. Should have built a vec2 for both points and only call it twice. Will that make a difference in the outcome? I don’t know, but I don’t know why it would. Also, failed to mention that I edited the ablines2.txt to eliminate the number of lines. The reader above simply reads the name, lat1,long1,lat2,long2. Five items per line separated by commas. The reader then splits the lines, and sends the lat and long into the position designer routine to get back the easting and northing. In AOG, ABLines are stored as an origin and heading. Using the dy/dx, get the heading, set the origin and ref1 to point1, set ref2 to point2. Upon saving the ab file and reloading it into the normal ab reader (next time you open the field) AOG takes care of the rest. This includes making the line longer. Probably a thousand better ways to do it, but??? Since these lines now have easting and northing values should be able to adjust them to the current field offsets. I set the simulator coordinates to the first coordinate of the ABLine file. That will effect the value of the easting and northing.