Skip to content

Distance calculator - add altitude in formulas #37

Closed
@Warxcell

Description

@Warxcell

Hello, right now distance calculator does not add altitude difference between points to distance, and when it's calculating route with elevation gain or loss the results are slightly not correct.

I used pythagorean to include altitude to distance. I don't know if this is correct, but results looks more or less correct. :)

  public function distanceLatLngAlt(float $lat1, float $lng1, float $alt1, float $lat2, float $lng2, float $alt2)
    {
        $distance = $this->distanceLatLng($lat1, $lng1, $lat2, $lng2);

        $elevDiff = abs($alt1 - $alt2);

        return sqrt(pow($distance, 2) + pow($elevDiff, 2));
    }

This formula is tested against 141 km path. The difference between distance with 2 formulas is almost 1km.

What do you think if we integrate this or some other formulas to include altitude in distance calculations?

Metadata

Metadata

Assignees

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions