logoalt Hacker News

lifistoday at 3:12 PM0 repliesview on HN

I think the issue in the article can further be mitigated with a better algorithm for determining road elevation profiles that accounts for the fact that roads are usually placed to minimize vertical displacement.

One can start assuming that the world is square tiled with square corners on the elevation measurement grid, and assuming that elevation in the square lies between the minimum and maximum value.

Now a road can be split into curve segments such that each segment lies in exactly one square. Then the profile of the road can be determined by guessing the altitude for the midpoint of each curve segment and interpolating.

The altitudes should be guessed to approximately minimize the road length and I think good and fast algorithms are easy to find.

For example, the altitudes of the midpoints can be assigned with a greedy/lazy approach: once one is determined, for each neighbor pick the closest valid altitude until all are assigned. To start, pick the maximum n such that the first n segments have non-empty altitude interval intersection and pick for all of them the endpoint of the intersection interval that is closest to the next interval (or the middle of the intersection interval if there is no next one).

Alternatively it can be formulated as a constraint problem with linear constraints and an objective function that depends on the interpolation. If weighted sum of absolute values is chosen, it's a linear program, otherwise the objective function will have higher degree