邮政编码 [英] Zip code

查看:75
本文介绍了邮政编码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个纬度和经度的zipcodes数据库。我还有

计算两个zipcodes之间距离的方法。我想知道的是,b $ b知道是否有一种有效的算法来获取第一个邮政编码指定距离内的邮政编码

而无需检索

并计算数据库中的每条记录。


Shelly

I have a database of zipcodes with latitude and longitude. I also have the
method of calculating the distance between two zipcodes. What I want to
know is if there is an efficient algorithm for obtaining the zip codes
within a specified distance of the first zipcode without having to retrieve
and calculate for every record in the database.

Shelly

推荐答案

" News"写道:
"News" wrote:
我有一个纬度和经度的zipcodes数据库。我也有计算两个zipcodes之间距离的方法。我想知道的是,是否有一种有效的算法可以在第一个邮政编码的指定距离内获取邮政编码,而无需检索数据并计算数据库中的每个记录。

Shelly
I have a database of zipcodes with latitude and longitude. I also have the
method of calculating the distance between two zipcodes. What I want to
know is if there is an efficient algorithm for obtaining the zip codes
within a specified distance of the first zipcode without having to retrieve
and calculate for every record in the database.

Shelly




不是真正的PHP问题,但我会尝试这样的事情:


1.想象一下以目标邮政编码为中心的指定范围的圆圈。


2.现在想象两个(square-ish)框位于同一个点的中心,其边缘

对应于纬度和经度线。一个盒子恰好放在这个

圈内(也就是说,所有四个角都恰好位于圆圈上),而另一个盒子恰好适合圆圈(即圈子是圆圈)与所有四个方面相切(b $ b b)。您可以通过简单的

三角函数计算这些框的角坐标。


3.构建数据库查询以提取位于较小的内部的所有邮政编码

框。这些都在指定范围内。


4.构建另一个数据库查询以提取位于

较大框内但不在内部的所有邮政编码较小的一个。这些可能或可能不在指定范围内,并且必须单独测试。


5.如果还有大量的拉链在步骤4中测试的代码,将这个区域划分为基于纬度和经度值的网格,并且

预先计算每个单元格的标记以指示它是否为在区域内外完全是

,或者如果它部分相交(在这种情况下,你需要单独测试邮政编码)。

-

phil [dot] ronan @ virgin [dot] net
http://vzone.virgin.net/phil.ronan/


新闻写道:
我有一个纬度和经度的拉链码数据库。我也有计算两个zipcodes之间距离的方法。我想知道的是,是否有一种有效的算法可以在第一个邮政编码的指定距离内获取邮政编码,而无需检索数据并计算数据库中的每个记录。
I have a database of zipcodes with latitude and longitude. I also have the
method of calculating the distance between two zipcodes. What I want to
know is if there is an efficient algorithm for obtaining the zip codes
within a specified distance of the first zipcode without having to retrieve
and calculate for every record in the database.




您可以在查询本身中执行此操作;但数据库肯定会扫描所有记录

。看看之前的讨论

< news:CW ****************** @newssvr25.news.prodigy。 COM> (
http:// groups -beta.google.com/group/...418b46576b2cd3




索引纬度和经度可能有所帮助。


-

<?php echo''只是另一个PHP圣徒''; ?>

电子邮件:rrjanbiah-at-Y!com博客: http: //rajeshanbiah.blogspot.com



You may do that in the query itself; but the DB will definitely scan
all the records. Look at the previous discussions
<news:CW******************@newssvr25.news.prodigy. com> (
http://groups-beta.google.com/group/...418b46576b2cd3
)

Indexing latitude and longitude might help.

--
<?php echo ''Just another PHP saint''; ?>
Email: rrjanbiah-at-Y!com Blog: http://rajeshanbiah.blogspot.com




" Philip Ronan" <在***** @ invalid.invalid>在消息中写道

news:*****0中的BF0E9D15.3572E%@ invalid.invalid ...

"Philip Ronan" <in*****@invalid.invalid> wrote in message
news:BF0E9D15.3572E%in*****@invalid.invalid...
" News"写道:
"News" wrote:
我有一个纬度和经度的zipcodes数据库。我还有
计算两个zipcodes之间距离的方法。我想知道的是,如果在第一个邮政编码的指定距离内有一个有效的算法来获取邮政编码,而不必检索
并计算每个记录在数据库中。

Shelly
I have a database of zipcodes with latitude and longitude. I also have
the
method of calculating the distance between two zipcodes. What I want to
know is if there is an efficient algorithm for obtaining the zip codes
within a specified distance of the first zipcode without having to
retrieve
and calculate for every record in the database.

Shelly



不是真正的PHP问题,但我会尝试这样的事情:

1想象一下以目标邮政编码为中心的指定范围的圆圈。

2.现在想象两个(square-ish)框位于同一个点的中心,其两侧是
对应于纬度和经度线。一个盒子恰好适合里面这个
圈子(即,所有四个角落都恰好位于圆圈上),而另一个盒子恰好围绕圆圈(即圆圈与四个圆圈相切)
双方)。您可以通过简单的三角函数计算这些方框的角坐标。

3.构建数据库查询以提取位于
内的所有邮政编码
框。这些都在指定的范围内。



Not really a PHP issue, but I''d try something like this:

1. Imagine a circle of the specified range centred on the target zip code.

2. Now imagine two (square-ish) boxes centred on the same point, whose
sides
correspond to lines of latitude and longitude. One box just fits inside
this
circle (i.e., all four corners lie exactly on the circle), and the other
just fits around the circle (i.e., the circle is tangential to all four
sides). You can calculate the corner coordinates of these boxes by simple
trigonometry.

3. Build a DB query to extract all the zip codes that lie inside the
smaller
box. These all lie inside the specified range.




谢谢。在等待答案的同时,我做了类似的事情,而我自己也是这样做的。我所做的只是计算三角洲纬度和经度

(半径* 360/24902)并从中心点加上和减去。那个

给了周围的盒子。从那里我将没有那么多的zipcodes。我

可以测试每一个距离,看它是否在指定的

半径范围内。这是最简单的方法。


雪莉



Thanks. While waiting for an answer I did a similar thing to the above on
my own. All I did was calculate the delta latitude and longitude
(radius*360/24902) and added and subtracted from the center point. That
gave the surrounding box. From there I will have not that many zipcodes. I
can test each one for distance and see if it lies within the specified
radius. That is the simplest method.

Shelly


这篇关于邮政编码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆