简体   繁体   中英

(Foursquare) Calculating Check-in Distance

We are developing a live-stream, browser based racing game. Our contenders will start to race from a START point and first contender who check-in in STOP venue will won race.

For example this venue will be our STOP venue: https://foursquare.com/venue/2154697

But there is a problem. For example now i'm 1.3km far away from STOP venue but i can check-in and i can win race:) So i have to calculate distance and if distance is lower than 100meters, contender will win.

How can we do it?

In shortly, i have to verify, contender is really in this venue.

I would suggest that you not use the check in feature to determine a win for exactly the reasons you mention above. Rather, I would suggest that you pull the winning location from foursquare, and then use a native lookup of the device's lat/long to compare to.

If you are making a browser based game, you can pull GPS info directly in JS in most modern OS's browsers (iOs, Android, Palm, etc). Almost all app frameworks support this now as well. While GPS lookup in the browser is a legitimate spec, there are handy JS warpers that help with cross compatibility like this one [[ http://code.google.com/p/geo-location-javascript/ ]]

So now that you know the 'destination' lat/lon and the true position of the player, you can calculate the delta from the location with some trigonometry. Remember though that the lat and log deltas themselves are not as simple as subtraction, as you are playing on a curved surface. The good news is that this stackOverflow article covers how to do this [[ Calculate distance between 2 GPS coordinates ]]

The most reliable way to ensure that the user is at the right location is to place a secret code of some kind at the said location that the user would have to find and type.

Since you appear to be running some kind of game, why not arrange a cheap gift (like chocolate or cake) containing the code?

This of course is doable only if the locations you choose are locations which you control in some way. You could arrange a partnership with a café franchise and use the café locations as stop points.

Give a secret code at the start point, and once arrived at the café, the user can convert his secret code into a pastry, or something like that, and his code is used to generate the end code.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM