0

I have an array which implements new coordinates every second into my location array. I am trying to add up the distances between each location point and carry this process on as new coordinates are implemented into the array.

I want to use the CLLocationDistance function

as an example:

var Array = [Double](-1.0, 1.0, -2.0, 2.0, -3.0, 3.0)

now I know I can use:

let Distance = (Latitude:-1.0, Longitude:1.0.distance(from: (Latitude:-2.0,  Longitude:2.0))

print(Distance)

for each point, but I want to use a 'for' statement and indices to calculate all the distances between points of the growing array.

Eric Aya
  • 69,473
  • 35
  • 181
  • 253
Dan.code
  • 431
  • 2
  • 14

1 Answers1

0

Calculate distance from two locations

By using

let distance = fromLocation.distanceFromLocation(toLocation

After Append new distance to total distance

Kathiresan Murugan
  • 2,783
  • 3
  • 23
  • 44