1

My Erlang module loads a GPX file and performs a certain function for every set of lat/long coordinates in the file. I want to increase the resolution, so to speak, of the GPX file by filling in more GPS points between the existing points. For example, the GPX file may have points every 100 feet, or even points at random intervals, and I may want to have points consistently every 10 feet. I don't want to actually modify the GPX file; I only want my script to calculate these midpoints at runtime.

I do not care about interpolating speed or anything else; only regular GPS coordinates.

As you can see in my function below, I am using the egpx module to extract lat/long points from a GPX file. I also have discovered modules such as geolib that can perform geographical calculations, but my limited knowledge in this area precludes me from solving this issue on my own.

In Erlang, how can I interpolate more GPS coordinates between two coordinates based on a predetermined interval, such as 10 feet?

EDIT: I found this question on Stack Overflow which may be pertinent, but I still need help understanding and applying the solution: How to generate coordinates in between two known points

get_gpx_points([], _) -> ok;
get_gpx_points([H|T], Acc) ->
    Lat = egpx:get_lat(H), % Egpx converts GPX trackpoints to lat/long
    Long = egpx:get_lon(H),

    % I want to interpolate more lat/long points here based on a set interval, like 10 feet

    LatList = io_lib:format("~.6f",[Lat]), % Converts to list of no. with six decimal points
    LongList = io_lib:format("~.6f",[Long]),

    do_something(LatList, LongList), % Run a certain function for every coordinate

    get_gpx_points(T, Acc + 1). % Recurse until no more trackpoints found
grgoelyk
  • 397
  • 1
  • 3
  • 12

0 Answers0