动态处理地理位置

发布于 2024-10-09 15:22:30 字数 787 浏览 0 评论 0原文

我建立了一个度假租赁和住房租赁网站。我创建了一个页面,用户可以在其中自行添加位置(最多 6 层),但我遇到了一个问题。用户可以添加位置,即:

北美->北美。美国->加利福尼亚州->旧金山

另一个用户可能到达并在 SF 下添加一个他认为位于 SF 下的区域(例如 Silver Terrace)。 另一个用户可以添加相同的区域,但他不会在 SF 下查找,而是会添加为 SF

北美的兄弟节点 ->美国->加利福尼亚州-> Silver Terrace

现在我们将拥有:

北美 -> 北美美国->加利福尼亚州->旧金山 ->银台
北美 ->美国->加利福尼亚州-> Silver Terrace

当然是重复的 =/ 我可以告诉第二次添加 Silver Terrace 的用户它已经存在,但第一个用户可能错误地放置了它,从而导致了问题。

即使我不允许用户添加位置并且我自己添加位置或将其限制为少数用户,正确添加所有位置仍然非常困难。

在其他国家/地区,还存在包含或不包含州/地区/地区等作为位置路径的一部分的问题......

我已经阅读了很多关于此的文章,但我无法总结我的内容寻找一个好的解决方案。

很难完全消除位置,因为我将它们用于子域,即。 san-francisco.example.com 或 california.example.com 。如果用户不想(或不能)使用地图,位置还允许用户按国家/州/城市/地区/社区/等进行浏览。

我认为对此没有完美的答案,但如果您有一些建议,请告诉我。太感谢了。

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 by 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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

绮筵 2024-10-16 15:22:30

您可以使用的另一种方法是统计方法,无需用户输入即可自动添加子域。 (此方法假设您最初没有有关位置的信息)

作为一个激励示例,假设您的系统上有 20,000 个用户,其中 10,000 个用户位于一个位置(形式为 x -> (y -> )* z) 以“United States -> California”开头

因为“United States -> California”是在如此多的位置中找到的元素,所以您可以确信“United States -> California” " 事实上,这是一个有效的位置。在添加子域时,此方法很有意义,因为您可能不想添加子域,直到您的人口中的很大一部分成为该子域的成员。

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.

抠脚大汉 2024-10-16 15:22:30

将隐藏值附加到 X->Y->Z 路径,表示 Z 的邮政编码。这可能是确定哪些路径重复的最简单方法。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文