红宝石宝石地质套件和:在最大或公差范围内?
刚刚开始使用 geokit 并尝试一些东西......
事情几乎按预期工作,给定一个点,它会发现附近的东西。
但是,如果我将 :within 设置为一个大值,例如 100,000,使用 :miles,我希望获得返回的数据库中的大多数(如果不是全部)对象 - 但它似乎在某个点停止 - 作为如果 :within 存在内置最大值。
我尝试过公式:平面和:球体。
提前致谢, 克里斯
Just started playing with geokit and trying some things out...
Things are pretty much working as expected, given a point, its finding things nearby.
However, if I set :within to be a large value, say 100,000, using :miles, I would expect to get most (if not all) of the objects in the db returned - but it seems to stop at a certain point - as if there is a built in maximum for :within.
I have tried the formulas :flat and :sphere.
Thanks in advance,
Chris
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您的问题似乎不是
:within
的内置最大值,而是缺乏限制(以及 geokit 内的健全性检查)。看起来
:within
查询最终会通过Geokit::Bounds.from_point_and_radius
来生成边界框。from_point_and_radius
将执行一些三角函数(请参阅mappable.rb
中的endpoint
),结果将是Geokit::Bounds< /代码> 实例。
我怀疑你在三角学方面出了问题;三角函数是周期性的,因此您的 100 000 半径最终将环绕到 0 到约 40 000 公里(地球周长,约 25 000 英里)之间,并且边界框不会限制 100 000 英里。如果你稍微玩一下你的 100 000,你可能会让 geokit 生成一个每边只有几厘米的边界框(如果你能解决常见的浮点问题,则半径为零)。
执行摘要:如果您想要全部,请根本不要使用
:within
;如果你想使用:within
,那么给它一个合理的距离(即足够小以适合行星表面而不环绕)。Your problem doesn't appear to be a built in maximum for
:within
but the lack of a limit (and sanity checking inside geokit).It looks like a
:within
query ends up going throughGeokit::Bounds.from_point_and_radius
to produce a bounding box.from_point_and_radius
will do a bit of trigonometry (seeendpoint
inmappable.rb
) and the result will be anGeokit::Bounds
instance.I suspect that things are going wrong for you in the trigonometry; trig functions are periodic so your 100 000 radius will end up wrapping around to something between 0 and ~40 000 km (the Earth's circumference, ~25 000 miles) and the bounding box will not bound 100 000 miles. If you play with your 100 000 a bit you could probably get geokit to produce a bounding box that is only a couple centimeters per side (or a zero radius if you can sort out the usual floating point issues).
Executive summary: if you want them all, don't use
:within
at all; if you want to use:within
, then give it a sensible distance (i.e. small enough to fit on the planet's surface without wrap around).