GeoDjango,dwithin 和 distance_lt 之间的区别?
有什么区别
myObj.objects.filter(point__dwithin(...etc.))
使用geoDjango,和
myObj.objects.filter(point__distance_lt(...etc.))
?
它们是同一件事,还是做着细微不同的事情?
Using geoDjango, what is the difference between
myObj.objects.filter(point__dwithin(...etc.))
and
myObj.objects.filter(point__distance_lt(...etc.))
?
Are they the same thing, or are they doing subtly different things?
好吧,我做了一些研究,但我不知道结果是否有任何用处;)
我查看了 单元测试,他们用来测试数据库查询,但他们没有给出真正的提示(对我来说)。
我尝试比较生成的 SQL:
我已经有一个使用 PostgreSQL 数据库的地理应用程序。当我使用
__distance_lt
执行此查询时:我得到生成的 SQL:
当我尝试使用 do 与
__dwithin
< /strong>,我收到错误:因此我必须将查询更改为不使用
D
对象:这会导致
Summary:
<强>
__dwithin
- 将度数值作为距离参数。
- 使用
ST_DWithin
SQL 函数。__distance_lt
- 可以采用其他距离值;)。
- 使用
ST_distance_sphere
SQL 函数。顺便说一句,我对两个查询都得到了不同的结果,但我想这主要是因为我不知道要使用哪个“度”值。
Ok, I did some research but I don't know if the results are of any use ;)
I looked at the unit tests that they use to test the DB queries but they don't give real hints (to me).
I tried to compare the generated SQL:
I have already a geo application using a PostgreSQL databse. When I perform this query with
__distance_lt
:I get this generated SQL:
When I try to use do to the same with
__dwithin
, I get an error:So I had to change the query to no use a
D
object:which results in
Summary:
__dwithin
- takes degree values as distance parameter.
- uses
ST_DWithin
SQL function.__distance_lt
- can take other distance values ;).
- uses
ST_distance_sphere
SQL function.Btw, I get different results with both queries but I guess this is mostly due the fact that I don't know which "degree" value to use.