0

I am in a situation where I need to find the maximum LatLng in a pool of LatLngs.

For example: Imagine I have the following

LatLng(3.9,3.4);
LatLng(1.2,3.3);
LatLng(0.4,2.4);

Clearly from the above, I think the first LatLng pair is the farthest and biggest, but how can I determine this algorithmically is the problem I have.

For example, in a regular array of integers say let a = [1,3,5,6];

let max = Math.max(a); //This would be 6. 

But how can this be determined when working with pairs instead.

Any insight would be really appreciated.

ololo
  • 1,326
  • 2
  • 14
  • 47
  • where is your input and expected output? – DecPK Jun 05 '21 at 01:04
  • would it not just be the max average between the lat/long pairs? – m_callens Jun 05 '21 at 01:05
  • @m_callens I'm not sure I get that. I doubt that will work. – ololo Jun 05 '21 at 01:08
  • 2
    how do you define "maximum LatLng in the pool" – m_callens Jun 05 '21 at 01:09
  • I've updated my question so you understand it better. – ololo Jun 05 '21 at 01:11
  • 2
    You need to define what you mean by 'max' – 'farthest and biggest' is a little vague. – pilchard Jun 05 '21 at 01:13
  • @pilchard By farthest I meant the LatLng in the List that is farthest from a reference LatLng. Thank you. – ololo Jun 05 '21 at 01:15
  • 1
    Then you need to add that to the question. Sounds like you are looking to determine distance from one point to another on a sphere then. see: [Calculate distance between two latitude-longitude points?](https://stackoverflow.com/questions/27928/calculate-distance-between-two-latitude-longitude-points-haversine-formula) – pilchard Jun 05 '21 at 01:16

0 Answers0