Hi,
I have an application that identifies the "general region" based on a post code / zip code list.
I am looking to identify the ten closest regions to the phone's current position. To do this,
As a one-off, the distance from 'current position' to all post offices is determined.
I am searching this distance list ten times. Each time this search is done, the minimum is set from the previous search.
This works, but I don't think it is the best way by far.
Can anyone suggest an alternative way? I am happy with a suggestion of a function or sort method that would be more efficient. The list size at the moment is 16000 roughly.
Thanks & Best wishes,
refsmmat
I have an application that identifies the "general region" based on a post code / zip code list.
I am looking to identify the ten closest regions to the phone's current position. To do this,
As a one-off, the distance from 'current position' to all post offices is determined.
I am searching this distance list ten times. Each time this search is done, the minimum is set from the previous search.
This works, but I don't think it is the best way by far.
Can anyone suggest an alternative way? I am happy with a suggestion of a function or sort method that would be more efficient. The list size at the moment is 16000 roughly.
Thanks & Best wishes,
refsmmat
B4X:
For k =0 To rows-1
distarray(k) = Sqrt(Power((MyArray(k, 1) - Latitude),2) + Power((MyArray(k, 2) - Longitude),2) ) * 111120
Next
For i=0 To (lstsize - 2)
dist2 = 10000000
For k =0 To rows-1
If (distarray(k) < dist2) AND (distarray(k) > minima(i)) Then
dist2 = distarray(k)
goodindex(i) = k
End If
Next
minima(i+1) = dist2
distance(i) = dist2
ListView1.AddSingleLine(MyArray(goodindex(i), 0) & " " & distance(i) & "m")
Next