0

I want to calculate distance between two geo coordinates but because of hardware usage (cpu, ram, database usage) I don't want to be specific instead I want to divide map to squires of my choice for example 1 Km * 1 km squires is there any library out there to do this pereferly for java-scrip language I couldn't find any ps library to calculating distance between this two squires

thank you very much for your time

  • 1
    calculating distance between two points is a fairly trivial algorithm – Jaromanda X Nov 02 '16 at 00:24
  • How do you save anything if you have to determine the two squires your locations are in then determine the distance between the centroids of the squires vs just determining the distance between your two locations? – JonSG Nov 02 '16 at 00:34
  • the users gonna send their locations but I don't want to save their exact locations to my database I want to send their squire's that they are in it and then I want to calculate the distance between these squires and find out witch user is closer to witch one – Start Engine Nov 02 '16 at 00:41
  • 1
    Do you mean squares? Squires are like guys in training to be knights. – Paul Nov 02 '16 at 00:46
  • I am assuming they mean *shire* or some synonym denoting a small area of land. In this case like about 250ac – JonSG Nov 02 '16 at 00:54

1 Answers1

0

If you want to slightly obfuscate the user's location, then rather than assigning them to a grid, you might effectively do the same thing by rounding off their latitudes and longitudes to however many decimal places you like then computing the distance using a more traditional Haversine Formula.

This post Calculate distance between... has many such implementations, but the one you want (javascript wise) is from @Salvador Dali.

If you are still looking to move forward with the "squire" concept, then check out http://what3words.com/ as they seem to be doing something similar to what you are looking to do though perhaps at a higher level of precision and they have an API.

Community
  • 1
  • 1
JonSG
  • 10,542
  • 2
  • 25
  • 36
  • I'm so sorry for my english i meant squares and it's not for obfuscation it's for using less computing power and also it's nature of app to not be exact. your idea to round the decimal is make sense to me thank you so much – Start Engine Nov 02 '16 at 02:05