如何将映射的边界框传递给SetFilterFloatRange()?

I get bounding_box of map SW, NE which gives me array of 4 coordinates or lt/ln. I want to pass this to 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

    Ref : http://php.net/manual/en/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

I assume you have 2 attributes:

  • latitude
  • longitude

in your index and you have an array of 4 lt/ln corner coordinates of the area you want to filter by. 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:

  • min latitude
  • max latitude
  • min longitude
  • max longitude

and then set 2 filters:

  • SetFilterFloatRange('latitude', $min_lt, $max_lt);
  • SetFilterFloatRange('longitude', $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.