English 中文(简体)
YQL Geo Distance between 2 WOEID s
原标题:

I store the YQL WOEID (Where on earth id) for all the users of my application locations. I now need a way to search for all users within x miles of a given WOEID, is this possible using YQL?

Alternativly I guess I could change the app to store lat and longitudes, but I need the calculation of distances as quick as possible as there potentialy could be thousends of users.

Edit : I guess what I m really looking for is something like the employee search on Stackoverflow Careers, where you can enter a place then tell it a distance around that space that you want to include in your search results

问题回答

As far as I can tell, this isn t something supported by YQL. The closest you might find is the method to return the neighbors of a given WOEID.

The problem with finding users within x miles of a given WOEID is that WOEIDs can be of arbitrary sizes with different centers and bounding boxes. Even though it is more complex, storing latitude and longitude are going to let you get the results you re looking for. There are at least two ways of going about this.

The first is to query directly on latitude and longitude by calculating the Haversine distance to the starting point. This can be extremely slow, especially when dealing with thousands of rows. In any event, you should see if your database support geospatial data. MySQL and PostgreSQL both have geospatial extensions.

A second popular method is to use a geohash. This produces a set of strings that you can use to query for nearby points. For example, take the coordinates Lat: 40.7571397, Lon: -73.9891705 for Rockefeller Center in NYC. One implementation of geohash (for Google AppEngine) for these coordinates produces the following:

  • 9
  • 9a
  • 9ac
  • 9ac7
  • 9ac7b
  • 9ac7be
  • 9ac7be2
  • 9ac7be2e
  • 9ac7be2e4
  • 9ac7be2e4e
  • 9ac7be2e4ed
  • 9ac7be2e4ed4
  • 9ac7be2e4ed4e

So if you want to find points that are really close, you can find other points that match 9ac7be2e4ed4e; if you want the general region you can try 9ac7be2e4e and so forth. Once you have a subset of your points, you could do the distance calculations on a much smaller dataset.





相关问题
Anyone feel like passing it forward?

I m the only developer in my company, and am getting along well as an autodidact, but I know I m missing out on the education one gets from working with and having code reviewed by more senior devs. ...

How to Add script codes before the </body> tag ASP.NET

Heres the problem, In Masterpage, the google analytics code were pasted before the end of body tag. In ASPX page, I need to generate a script (google addItem tracker) using codebehind ClientScript ...

Transaction handling with TransactionScope

I am implementing Transaction using TransactionScope with the help this MSDN article http://msdn.microsoft.com/en-us/library/system.transactions.transactionscope.aspx I just want to confirm that is ...

System.Web.Mvc.Controller Initialize

i have the following base controller... public class BaseController : Controller { protected override void Initialize(System.Web.Routing.RequestContext requestContext) { if (...

Microsoft.Contracts namespace

For what it is necessary Microsoft.Contracts namespace in asp.net? I mean, in what cases I could write using Microsoft.Contracts;?

Separator line in ASP.NET

I d like to add a simple separator line in an aspx web form. Does anyone know how? It sounds easy enough, but still I can t manage to find how to do it.. 10x!

热门标签