Closed GoogleCodeExporter closed 9 years ago
Updated the method a bit, no indefinite loops now :D
Also note that the accuracy descreases over distance, maybe doo to projection
issues in the Destination method ? (see picture)
private void calcElevationProfile(Coordinate start, Coordinate end)
{
//Create List to hold results
PointPairList elevationList = new PointPairList();
//calculate the total distance between the 2 points
double totalDistance = Maths.DistanceHaversine(start, end);
//calculate the bearing between the 2 points for later use, when "moving" across the line
double bearing = Maths.BearingFinal(start, end);
//set the distance of "steps" in km
double stepSize = 0.1;
//calc max number of iterations
int iterations = Convert.ToInt32(totalDistance / stepSize);
double distanceToEnd = 100000;
double distanceCounter = 0;
int counter = 0;
//loop until the endpoint almost is reached
while (distanceToEnd > 0.2 && iterations >= counter)
{
Coordinate temp = Destination(start, distanceCounter, bearing);
//calculate the new distance
distanceToEnd = Maths.DistanceHaversine(temp, end);
//get elevation of point
double elevation = ge.getGlobe().getGroundAltitude(temp.Latitude, temp.Longitude);
//add to list
PointPair pp = new PointPair(totalDistance - distanceToEnd, elevation);
elevationList.Add(pp);
KmlHelpers.CreatePlacemark(ge, temp, name: ""+ (totalDistance - distanceToEnd).ToString("0.00") + " km from START, " + elevation.ToString("0") + " m above ground, " + distanceToEnd.ToString("0.00") + " km to END");
//Move coordinate, currentset to move 100m
distanceCounter += stepSize;
counter++;
}
/*StringBuilder b = new StringBuilder();
foreach (PointPair reading in elevationList)
{
b.Append(reading.X.ToString("0.00") + ", " + reading.Y.ToString("0.00") + Environment.NewLine);
}
MessageBox.Show(""+b);*/
//show the results in a form
ElevationProfile elevationProfile = new ElevationProfile(elevationList, stepSize);
elevationProfile.Show();
}
Original comment by tho...@gmail.com
on 14 Feb 2012 at 11:54
Attachments:
[deleted comment]
This looks really interesting, many thanks for sharing! I will take a good look
though and look to see how it might be implemented. It is certainly a useful
too.
Thanks again!
F
Original comment by fraser.c...@gmail.com
on 14 Feb 2012 at 7:58
No problem - And it should maybe be more like 'Thank you for sharing'. I've
used the dll for quite some time now and its working great.
Feel free to ask if I havn't been clear enough in my post.
Original comment by tho...@gmail.com
on 16 Feb 2012 at 2:54
Original comment by fraser.c...@gmail.com
on 17 May 2013 at 10:54
Something like this is going in using the Google Elevation API
https://developers.google.com/maps/documentation/elevation/
Original comment by fraser.c...@gmail.com
on 21 May 2013 at 12:21
No further development now that the Earth API is depreciated.
Original comment by fraser.c...@gmail.com
on 17 Dec 2014 at 3:20
Original issue reported on code.google.com by
tho...@gmail.com
on 14 Feb 2012 at 9:50Attachments: