这不是一个编码问题,如果您愿意的话,这只是我试图实现的概念(算法)。
基本上我想做的是检查用户是否在某个特定的地方,即大英博物馆!然后给他们发一条消息说欢迎来到大英博物馆。
我的数据库中只有三个位置
- :英国博物馆、
- 杜莎夫人蜡像馆、
- 威斯敏斯特修道院
、我知道我需要使用实时检查!所以我想我获取用户位置,检查它是否匹配任何三个值,然后发送消息。你能提出更好的建议吗?谢谢
this is not a coding question, its just the concept im trying to achieve(alogirthm) if you like.
basically what i want to do is check if a user is in a particular place i.e the british meseum!! and then sending them a message saying welcome to the british meseum.
i only have three location in my DB
- the british meuseum
- the madamme tussaud
- westminster abbey
i know that i need to use real time checking! so i was thinking that i get the users location, check to see if it matches any three values, and then send message. can you suggest anything better? thanks
发布评论
评论(2)
是的,这听起来像是可行的。请务必检查半径内的位置匹配(位置永远不会完全相同),即
if ( dist ( userCooperative - MuseumCooperative)
(使用
distanceFromLocation:
方法来计算这个)此外,为了获得实时检查,您可能需要使用
CLLocationManager
用于在用户位置发生变化时接收更新。Yea, that sounds like it would work. Just be sure to check the location matches within radius (the location will never be exactly the same) i.e.
if ( dist ( userCoordinate - museumCoordinate) < THRESHOLD ) ...
(use the
distanceFromLocation:
method To calculate this)Also, to get the real time checking, you might want to use the delegate callback of the
CLLocationManager
to receive updates when the users location changes.您想要的称为地理编码。通常是通过向实际为您执行转换的服务发送请求来完成的。 Google 和其他一些公司提供此服务。
下面可以作为代码参考
What you want to is called geocoding. Typically is done by sending a request to a service which actually does the conversion for you. Google and some other companies offer this service.
Below can be used as code reference