大容量地理编码和距离检查
我正在尝试为一家维护每天更新的注册表的公司编写一个应用程序。该应用程序必须获取用户的位置并显示该注册表中所有最近的位置。到目前为止,我已经让应用程序调用谷歌并获取我想出的一个小 Plist 的地理编码信息。然而,从放大的角度考虑它......我现在使用一个地理编码密钥,这个应用程序无法在现实世界中正确快速地工作,因为谷歌每天每个密钥只提供 15000 个请求......以及列表位于公司的服务器上。这是一个很大的清单。超过 25000 个数据点。
这些人如何喜欢“Yowza”应用程序或任何其他基于位置的应用程序搜索这些经常更新的数据库,同时获取所有用户所需的地理编码信息。他们是否存储给定位置的纬度和经度,还是我需要 Google 提供一些特殊的信息?他们是如何如此快速地获取信息的? SQLite 数据库的实现对此有帮助吗?先感谢您。
I am trying to write an app for a company that maintains a registry that is updated everyday. The app will have to take the user's location and display all the nearest locations that are in that registry. Thus far I have gotten the app to call out to google and get geocoding information for a small Plist that I came up with. However, considering it from a scaled up point of view....I am using one geocoding key right now and this app cannot work correctly and quickly in the real world because google only give 15000 request per day per key.. and the list is located on the company's server. This is a big list. upwards of 25000 data points.
How do these guys like the "Yowza" app or any other location based app search through these data bases that get updated often while getting the geocoding information they need for all users. Do they store the lats and longs for given locations or do I need something special from Google? And how do they get the information so fast. Does the implementation of the SQLite data base help with this? Thank You in advance.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
如果您的位置是静态的,并且您只需要知道用户距其中一个位置有多远,您可以使用此代码片段(抱歉,它太草率了):
此外,您可以创建两个 CLLocation 对象并使用 distanceToLocation: 方法。
If your locations are static and you just need to know how far the user is from one of the locations you can use this snippet(sorry it's so sloppy):
Also, you could create two CLLocation objects and use the distanceToLocation: method.
谷歌有我不知道有多少服务器。他们可以非常快地做到这一点。
如果您的应用程序需要大量对时间敏感的用户数据,并且可以在整个网络上使用,那么除了将更新从任何地方发送到数据库服务器之外,我真的不知道还有其他方法可以做到这一点。如果它需要快速,那么你需要大量的力量,一些非常聪明的编码,或者两者兼而有之。
然后,如果您需要查找附近的用户,那么我想您可以返回特定纬度/经度窗口内的所有用户。
Google has I don't know how many servers. They can be really fast with that.
If your application needs a lot of time-sensitive user data, available across the entire network, I really don't know of another way to do it except to send updates from everywhere to your DB server. And if it needs to be zippy, then you need a lot of muscle, some really clever coding, or both.
Then, if you need to find users that are nearby, then you can, I suppose, return all users that are within a certain latitude/longitude window.
如果现在选择数据库引擎还不算太晚,SQL Server 2008 现在具有允许您处理空间数据的功能。您可以在 T-SQL 中执行诸如距离计算之类的操作。有一篇关于通过 SQL Server 2008 处理空间数据的非常好的文章 此处。
If it isn't too late to select your database engine, SQL Server 2008 now has features to allow you to work with spatial data. You can do things like distance calculations in T-SQL. There is a pretty nice article about working with spatial data through SQL Server 2008 here.
您能澄清一下您在哪里进行地理编码吗?您的 25k 数据点是否每天都在变化,或者您是否认为每天会有足够的 iPhone 用户达到 15k 限制?另外,您是否想从地址获取纬度和经度,或者从纬度和经度获取地址?
如果您所做的只是显示前 XX 个最近的位置,那么您无需从 iPhone 进行任何地理编码。您可以从 Core Location 获取当前的纬度和经度。然后您可以将该位置与数据库进行比较,找出最接近的位置。如果您的数据库支持 GIS/空间函数(大多数都支持),那么就使用它们。如果没有,那就自己动手(三角学是你的朋友)。
如果您确实知道自己将达到限制,请考虑缓存地理编码数据。这样,您可以首先检查它(iPhone 或“注册表”位置)您距离缓存位置有多远。如果您距离缓存位置足够近(可能 1/4 英里,取决于这些东西是什么),则使用缓存结果。仅当距离太远时才进行地理编码。
Can you clarify where you're doing the geocoding? Are your 25k data points changing every day, or are you thinking that you are going to have enough iPhone users to hit the 15k limit every day? Also, are you trying to get latitude and longitude from an address, or an address from latitude an longitude?
If all you're doing is displaying the top XX nearest locations, then you won't have to do any geocoding from the iPhone. You can get the current latitude and longitude from Core Location. Then you can compare that location with your database to figure out what's closest. If your database supports GIS/spatial functions (most do), then use them. If not, roll your own (trigonometry is your friend).
If you really know that you're going to hit the limit, then consider caching the geocoding data. That way you can first check if it (the iPhone or the 'registry' location) how far away you are from a cached location. If you're close enough to the cached location (maybe 1/4 mile, depends on what these things are), then use the cached results. Only do the geocoding if you're too far away.
该服务器端列表应该已经提供所有数据点的纬度/经度坐标。如果现在没有,请立即开始使用每天 1500 次 Google 转化进行转化。然后,您只需在服务器端进行空间查询即可找到用户本地的点并将它们放置在地图上。
老实说,25k 数据点并不算多,您可以将它们本地存储在应用程序中,并让应用程序查询新数据点。还有一个 sqllite 的空间变体,您可以使用它来尝试执行设备本地空间查询。
This server side list should already provide lat/long coordinates for all data points. If it doesn't have them now, start converting today using your 1500 Google conversions per day. Then you are simply doing spatial queries on the server side to find points local to the user and laying them out on the map.
25k data points is honestly not that much though, you could store them locally in the app and have the app query for new data points. There's also a spatial variant of sqllite you could use to try and do device local spatial queries.