将网站分为城市/国家的最佳方式?

发布于 2024-10-24 22:34:43 字数 370 浏览 2 评论 0原文

我正在经营一个约会网站,或者更好地说,尝试一下。我想变得通用
尽可能覆盖国家。

由于它是一个本地约会网站,我必须跟踪城市
等等,所以我遇到了一些问题:

  1. 我需要有关城市的信息,人们可以从
    加入 (一个我一无所知的国家,我真的无法决定一个城市
    或任何东西)

  2. 当人们从不同的国家加入时,他们希望见到人
    附近。您将如何解决此类问题?

这似乎是两个简单的点,但它们确实给我带来了一些麻烦
天。 ** 尝试将它们视为与数据库相关的问题 **

我围绕 SE 转了一圈,发现这是最好的问题点,而不是其他问题
SE 网站。

非常感谢

i am running a dating website, or better say, try to. I want to be as generic
as possible in terms of, coverage for countries.

Since it's a local dating oriented website, i have to keep track of cities
and so on so i am running into a few problems:

  1. I need to have information about cities, people could join from
    (a country i don't know anything about, i really can't decide about a city
    or anything)

  2. When people join from different countries, they would like to see people
    near by. How would you approach this sort or problem?

This may seem like 2 easy points but they really make me some trouble these
days.
** Try to approach them as Database related issues **

I circled around SE and find this to be the best point to ask, not any other
SE website.

Thank you very much

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

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

发布评论

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

评论(2

落花随流水 2024-10-31 22:34:43

美国城市的全名是{country_name, state_name, city_name}。我说的是假设,在全球范围内,我所说的 state_name 不是唯一的。我可以很容易地想象拉丁美洲国家的某个地区被命名为“内华达”或“科罗拉多”。

你也有拼写问题。居住在德国的美国人可能会说她住在德国北莱茵-威斯特法伦州科隆。居住在那里的德国人会称其为“Köln”。

“附近”是一个更难解决的难题。我以前住在大城市。在州际高速公路上开车一个小时去接我的约会对象并不罕见。我认为那是“附近”。现在我住在一个小城市。现在,30 分钟似乎是一个很长的车程,但可能只有 15 或 20 英里,而不是 65 或 70 英里。

如果您住在边境城镇,15 英里可能是在另一个国家。也许是两个不同的国家。

我认为最好的选择是使用地理定位 API 或服务来获取插入新城市时的纬度和经度。给定两点的距离计算很简单,但除非使用边界框,否则会导致查询性能不佳。 (您不想计算到德克萨斯州每个城市的距离来查找“靠近”韦科的人。)

The full name of a city in the USA is {country_name, state_name, city_name}. I say that assuming that, on a global scale, what I call state_name is not unique. I can easily imagine some region of a Latin American country being named "Nevada" or "Colorado".

You also have the problem of spelling. An American living in Germany might say she lived in Cologne, North Rhine-Westphalia, Germany. A German living there would call it "Köln".

"Nearby" is an even tougher nut to crack. I used to live in a big city. It wasn't unusual to drive an hour on an Interstate highway to pick up my date. I thought of that as "nearby". Now I live in a small city. Now 30 minutes seems like a long drive, but it's probably only 15 or 20 miles instead of 65 or 70.

If you live in a border town, 15 miles might be in a different country. Maybe two different countries.

I think your best bet is to use a geolocation API or service to get the latitude and longitude of new cities when they're inserted. The calculation of distance given two points is straightforward, but it leads to badly performing queries unless you use a bounding box. (You don't want to calculate the distance to every city in Texas to find people "near" Waco.)

半暖夏伤 2024-10-31 22:34:43

获取所有城市的纬度/经度。不用担心确切的距离。

使用 Excel 查找给定距离(10 英里、25 英里、50 英里)的纬度和/或经度(Δlat 或 Δlong)的最大变化,然后当您搜索其他内容时,只需在数据库中搜索(Firstuser'sLongitude) +/- Δlong)并在(第一用户的纬度 +/-Δlong)内。

我认为人们不会介意 10 英里和 10*2^0.5 英里之间的差异。

Get the latitude/longitude for all of the cities. Don't worry about exact distances.

Play with excel and find the maximum change for latitude and/or longitude (Δlat or Δlong) for given distances (10miles, 25 miles, 50 miles), and then when you search for others, just search the database for within (Firstuser'sLongitude +/- Δlong) and within (Firstuser'sLatitude +/-Δlong).

I don't think people will mind the difference between 10miles and 10*2^0.5 miles.

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