• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

calculate the distance between two points?

 
Ranch Hand
Posts: 59
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have many requests at the same time on the server side with longitude and latitude coordinates how can I figure out which points are located in the circumcircle of 5 meter with Java?
 
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
How to do it with Java is trivial once you have the formula. So that's where you need to start.

How accurate do you want it? Assuming rectangular coordinates is easiest, but obviously pretty inaccurate. Even assuming a sphere has inaccuracies since the world isn't a perfect sphere.

You can google for the formula. Or, speaking of Google, can you just use their geo web service and have them do all the hard work?
 
Alex Ardoin
Ranch Hand
Posts: 59
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
accuracy of 90%. I will try it with Haversine formula.
 
Alex Ardoin
Ranch Hand
Posts: 59
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am trying to use the haversin formula to prevent updating the mysql table. I am implementing an app based on crowdsorucing where the data mac, route, lat, long is being recorded by the devices of the passangers im bus and send to the server.

My database table has mac address as UNIQUE KEY. So to avoid that other passanger in the same bus to store their data in the table I would filter these requests out by using the Haversin formula but I tried it with tow point which are roughly 20 meter close to eachother but I am gettig number of 4803.800129810092



does someone know any idea how can I reach that? the most buses are without WIFI access point.
 
Marshal
Posts: 28193
95
Eclipse IDE Firefox Browser MySQL Database
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
 
Alex Ardoin
Ranch Hand
Posts: 59
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
ok
 
Paul Clapham
Marshal
Posts: 28193
95
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Copy and paste and forget-to-edit error? I hate it when that happens.
 
Alex Ardoin
Ranch Hand
Posts: 59
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I understand your point thanks. Is this formula sufficient for my issue since I am trying to calculate distace between two point with distance of 5 meter?
 
Paul Clapham
Marshal
Posts: 28193
95
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
It looks pretty much identical to code that I have used in the past for calculating the length of a GPS track based on points measured once a minute by a person on foot. Probably we got it from the same source. Anyway, testing should clarify whether it works for you, no?
 
Alex Ardoin
Ranch Hand
Posts: 59
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Maybe : I have multiplied R with 1000 to get the result in meter and I am getting value between 8-15 meter. I have picked some geocoordinates from my vicinity I have to test it real but I am realy surprised ;)
 
Catch Ernie! Catch the egg! And catch this tiny ad too:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic