简体   繁体   English

Perl MongoDB地理空间查询

[英]Perl MongoDB geospatial query

I am trying to perform a geospatial query with the MongoDB::Collection package for Perl, but it's not working. 我正在尝试使用Perl的MongoDB :: Collection包执行地理空间查询,但是它不起作用。 Does anyone have an example use? 有人使用示例吗? Does it even work? 还能用吗? There is no specific example in the package documentation and the example documentation on the site isn't working. 软件包文档中没有特定的示例,并且该站点上的示例文档不起作用。

Thanks 谢谢

its only array query so you can convert this code to perl: 它唯一的数组查询,因此您可以将此代码转换为perl:

$earthRadius = 6378; // km
$range = 35; // max search km
$max = $range / $earthRadius;

array(
'lat' =>
    array('$within' =>
       array('$centerSphere' =>
          array(array(floatval(  52.417 ), floatval( 16.883 )),
              $range/$earthRadius)
        )
    )
);


$collection->ensureIndex(array('loc.lat' => "2d"), array('background' => true) );

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM