windrobin / winforms-geplugin-control-library

Automatically exported from code.google.com/p/winforms-geplugin-control-library
GNU General Public License v3.0
0 stars 1 forks source link

Linestring Elevation Profile #72

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Hi,

One the features that I use the most in the normal google Earth application is 
the 'Elevation Profile'. So fare I've not been able to find a way to enable 
this feature when using the Plugin ?? Until then I've therefore yesterday got 
the following together which can be used as a starting point.

The method below, creates a PointPairList of elevation measurements between two 
points. The two points could for instance be obtained from click events on 
earth or right cliking on a linestring in the kmltreeView.

        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);

            double distanceToEnd = 100000;
            //loop until the endpoint almost is reached
            while (distanceToEnd > 0.2)
            {
                //calculate the new distance
                distanceToEnd = Maths.DistanceHaversine(start, end);
                //get elevation of point
                double elevation = ge.getGlobe().getGroundAltitude(start.Latitude, start.Longitude);
                //add to list
                PointPair pp = new PointPair(totalDistance - distanceToEnd, elevation);
                elevationList.Add(pp);
                //KmlHelpers.CreatePlacemark(ge, start, name: "" + (totalDistance - distanceToEnd).ToString("0.00") + ", " + elevation.ToString("0") + ", " + distanceToEnd.ToString("0.00"));
                //Move coordinate, currentset to move 100m
                start = Destination(start, 0.1, bearing);
            }

            //show the results in a form
            ElevationProfile elevationProfile = new ElevationProfile(elevationList);
            elevationProfile.Show();
        }

This works for distances < 50km or so....

Regards,
TKM

Original issue reported on code.google.com by tho...@gmail.com on 14 Feb 2012 at 9:50

Attachments:

GoogleCodeExporter commented 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:

GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
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

GoogleCodeExporter commented 9 years ago
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

GoogleCodeExporter commented 9 years ago

Original comment by fraser.c...@gmail.com on 17 May 2013 at 10:54

GoogleCodeExporter commented 9 years ago
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

GoogleCodeExporter commented 9 years ago
No further development now that the Earth API is depreciated. 

Original comment by fraser.c...@gmail.com on 17 Dec 2014 at 3:20