简体   繁体   English

如何将地图的边界框传递给SetFilterFloatRange()?

[英]How to pass bounding box of map to SetFilterFloatRange()?

I get bounding_box of map SW, NE which gives me array of 4 coordinates or lt/ln. 我得到地图SW,NE的bounding_box ,它为我提供了4个坐标或lt / ln的数组。 I want to pass this to SetFilterFloatRange() . 我想将此传递给SetFilterFloatRange()

Purpose of doing this is, I want to get filtered results only which fall in this bounding box area or from visible portion of map. 这样做的目的是,我只想获得过滤结果,这些结果落在此边界框区域内或来自地图的可见部分。

I have below questions 我有以下问题

  1. How to pass it to SetFilterFloatRange() because it accepts only 2 params of lt/ln 如何将其传递给SetFilterFloatRange()因为它仅接受lt / ln的2个参数

    Ref : http://php.net/manual/en/sphinxclient.setfilterfloatrange.php 参考: http : //php.net/manual/zh/sphinxclient.setfilterfloatrange.php

  2. I think I need to convert these coordinates to radians before passing to above method. 我认为在传递给上述方法之前,需要将这些坐标转换为弧度。 Correct me, if wrong. 纠正我,如果有错。

How to pass it to SetFilterFloatRange() because it accepts only 2 params of lt/ln 如何将其传递给SetFilterFloatRange(),因为它仅接受lt / ln的2个参数

I assume you have 2 attributes: 我假设您有2个属性:

  • latitude 纬度
  • longitude 经度

in your index and you have an array of 4 lt/ln corner coordinates of the area you want to filter by. 在索引中,您有一个要过滤的区域的4 lt / ln角坐标数组。 And you want to find only those documents that are inside you box area. 而且,您只想查找框区域内的那些文档。 Then you first need to convert the array to 4 values: 然后,您首先需要将数组转换为4个值:

  • min latitude 最小纬度
  • max latitude 最大纬度
  • min longitude 最小经度
  • max longitude 最大经度

and then set 2 filters: 然后设置2个过滤器:

  • SetFilterFloatRange('latitude', $min_lt, $max_lt); SetFilterFloatRange('latitude',$ min_lt,$ max_lt);
  • SetFilterFloatRange('longitude', $min_ln, $max_ln); SetFilterFloatRange('经度',$ min_ln,$ max_ln);

I need to convert these coordinates to radians before passing to above method 在传递给上述方法之前,我需要将这些坐标转换为弧度

If you have the indexed coordinates in radians - yes, the function itself doesn't care about radians/degrees, it's just that the indexed values and values you pass to the fuction should be compatible. 如果您以弧度为单位的索引坐标-是的,函数本身并不关心弧度/度,只是索引值和传递给函数的值应该兼容。

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

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