I'm currently taking a class of Algorithms and have to do a project related to Graphs, more specifically finding the shortest path in a set of locations. The problem is we not only have to take distance between points into account, we also need to know their altitude. Now, I've searched openstreetmaps, google elevation api, etc, and I've yet to find a way to get the elevation. From what I understand, osm only has elevation for a short amount of nodes.
Here is an example using curl from open-elevation's API. Is there a way to make a simple program (preferably C/C++) to do what I want? I've tried already but couldn't get it to work.
My first thought was using system(). If it worked, then I could read locations and create a string to pass to the function. However, I'm gettint a lot of compiler errors related to the quotes. Didn't I already escape everything? Here is the code:
#include <stdlib.h>
int main()
{
system("curl -X POST \\
https://api.open-elevation.com/api/v1/lookup \\
-H \'Accept: application/json\' \\
-H \'Content-Type: application/json\' \\
-d \'{
\"locations\":
[
{
\"latitude\": 41.1488064,
\"longitude\": -8.6094618
},
{
\"latitude\":20,
\"longitude\": 20
},
{
\"latitude\":41.161758,
\"longitude\":-8.583933
}
]
}\'");
return 0;
}
EDIT: Apparently removing the spaces worked. Even then, is there a better way to do this?