开发者

handling geographic locations dynamically

I've built a website for vacation rentals and housing for rent. I've created a page where users can add locations themselves (up to 6 levels deep) but I have come across a problem. A user may add a location ie:

North America -> United States -> California -> San Francisco

Another user may arrive and add an area under SF which he assumes to be under SF ( say Silver Terrace ). Yet another user could add that same area but he would not look under SF and would add to be a brother node of SF

North America -> United States -> California -> Silver Terrace

So now we would have:

North America -> United States -> California -> San Francisco -> Silver Terrace

North America -> United States -> California -> Silver Terrace

which is of course a duplicate =/ I could tell the user adding Silver Terrace the second time that it already exists but the first user may have placed it incorrectly which causes a problem.

Even if I were to not allow users to add locations and I would do it myself or limit it to a few users, it would still be very difficult to correctly add all locations.

In other countries there also comes the question of including or not including the state/district/region and so on to be part of the path for locations...

I've read quite a few posts about this but I can't wrap my head around a good solution.

It is difficult to eliminate locations altogether because I use them for subdomains ie. san-francisco.example.com or california.example.com . Locations also allow users to browse 开发者_如何学Cby country/state/city/area/neighborhood/etc if a user doesn't want to (or can't) do so using a map.

I don't think there is a perfect answer for this but if you've got some suggestions, please let me know. Thank you so much.


Another approach you could use, to automatically add sub domains with little user input, is a statistical approach. (This approach assumes you have no information about locations initially)

As a motivating example, let's say that you have 20,000 users on your system and 10,000 of these users put in a location (in the form of x -> (y ->)* z) that starts with "United States -> California"

Because "United States -> California" is an element which is found in such a large number of locations, you could be confident that "United States -> California" is, in fact, a valid location. This approach makes sense when adding subdomains because you may not want to add a sub domain until a significant portion of your population would become members of that sub domain.


Have a hidden value attatched to the X->Y->Z path which denotes Z's ZIP code. That might be the easiest way to determine which paths are duplicates.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜