I'm using geocoder. I want to get near locations but it's returning a empty array.
Got this in database:
"id": 5,
"name": "sogra2",
"lat": "-22.833575",
"long": "-43.312882",
This is my action using the near coordenates
def near
@near = Test.near([-22.844279, -43.306174], 100, :units => :km)
render json: @near
end
This is my model:
class Test < ApplicationRecord
reverse_geocoded_by :lat, :long
end
Posting the Query
SELECT tests.*, (111.19492664455873 * ABS(tests.lat - -22.844279) *
0.7071067811865475) + (96.29763124613503 * ABS(tests.long - -43.306174) * 0.7071067811865475) AS distance, CASE WHEN (tests.lat >= -22.844279 AND tests.long >= -43.306174) THEN 45.0 WHEN (tests.lat < -22.844279 AND tests.long >= -43.306174) THEN 135.0 WHEN (tests.lat < -22.844279 AND tests.long < -43.306174) THEN 225.0 WHEN (tests.lat >= -22.844279 AND tests.long < -43.306174) THEN 315.0 END AS bearing FROM "tests" WHERE (tests.lat BETWEEN -23.74360060591873 AND
-21.94495739408127 AND tests.long BETWEEN -44.282039151718706 AND -42.33030884828129) ORDER BY distance ASC
It's returning []
Rails 5.1 API mode