SWH12 commented on issue #9847: URL: https://github.com/apache/druid/issues/9847#issuecomment-704118657
> I made one workaround like this: > > ```sql > SELECT > MyDataRows, > FROM "Datasource" > WHERE > (POWER(DataLatitude-52.1, 2) + POWER( (DataLongitude-5.1)*COS(RADIANS(52.1)),2)) < POWER(5/68, 2) > ``` > > I am searching around Lat =52.1 and Lon = 5.1 with a radius of 5(km) and I assume that 1 degree is 68 km length at my latititude. > > The result will be all rows that have a DataLatitude and DataLongitude within that radius. > > This is based on > https://jonisalonen.com/2014/computing-distance-between-coordinates-can-be-simple-and-fast/ (the SQL part) > and the table at the following page to get the 1 degree is 68 km (the contstant at the end of the formula): > https://en.wikipedia.org/wiki/Longitude#Length_of_a_degree_of_longitude I agree with your workaround , and this is probably the simplest solution. The only problem is that 68 should be replaced with 110.25 in the formula, because this value does not change with the Latitude(https://jonisalonen.com/2014/computing-distance-between-coordinates-can-be-simple-and-fast/ (the SQL part)). Such as: ``` SELECT MyDataRows, FROM "Datasource" WHERE (POWER(DataLatitude-52.1, 2) + POWER( (DataLongitude-5.1)*COS(RADIANS(52.1)),2)) < POWER(5/110.25, 2) ``` I have a question, why doesn’t Druid use this calculation method? In the class named RadiusBound: ``` public boolean contains(float[] otherCoords) { double total = 0.0; for (int i = 0; i < coords.length; i++) { total += Math.pow(otherCoords[i] - coords[i], 2); } return (total <= Math.pow(radius, 2)); } ``` ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
