You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@druid.apache.org by GitBox <gi...@apache.org> on 2020/10/06 08:37:31 UTC

[GitHub] [druid] SWH12 opened a new issue #9847: When using Spatial filters, what is the unit of radius

SWH12 opened a new issue #9847:
URL: https://github.com/apache/druid/issues/9847


   When I use a spatial filter, I don't know what the unit of radius is, kilometers or degrees?
   
   By calculation I got the distance between coordinates [38,115] and [39.93883,116.51135] to be 152.7 kilometers.
   
   When I use the spatial filter and type as radius, set coords to [38, 115], radius to 2, the result is empty; but set tcoords to [38, 115], radius to 3, the result is [39.93883, 116.51135 ].


----------------------------------------------------------------
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:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For additional commands, e-mail: commits-help@druid.apache.org


[GitHub] [druid] emetselaar commented on issue #9847: When using Spatial filters, what is the unit of radius

Posted by GitBox <gi...@apache.org>.
emetselaar commented on issue #9847:
URL: https://github.com/apache/druid/issues/9847#issuecomment-703488933


   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
   


----------------------------------------------------------------
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:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For additional commands, e-mail: commits-help@druid.apache.org


[GitHub] [druid] SWH12 commented on issue #9847: When using Spatial filters, what is the unit of radius

Posted by GitBox <gi...@apache.org>.
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:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For additional commands, e-mail: commits-help@druid.apache.org


[GitHub] [druid] emetselaar commented on issue #9847: When using Spatial filters, what is the unit of radius

Posted by GitBox <gi...@apache.org>.
emetselaar commented on issue #9847:
URL: https://github.com/apache/druid/issues/9847#issuecomment-702033548


   Hi, great that you found that out. I am wondering now how to use it. Have you found an easy way for this?


----------------------------------------------------------------
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:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For additional commands, e-mail: commits-help@druid.apache.org


[GitHub] [druid] SWH12 removed a comment on issue #9847: When using Spatial filters, what is the unit of radius

Posted by GitBox <gi...@apache.org>.
SWH12 removed a comment on issue #9847:
URL: https://github.com/apache/druid/issues/9847#issuecomment-704094601


   > 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
   
   


----------------------------------------------------------------
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:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For additional commands, e-mail: commits-help@druid.apache.org


[GitHub] [druid] SWH12 commented on issue #9847: When using Spatial filters, what is the unit of radius

Posted by GitBox <gi...@apache.org>.
SWH12 commented on issue #9847:
URL: https://github.com/apache/druid/issues/9847#issuecomment-703473458


   > Hi, great that you found that out. I am wondering now how to use it. Have you found an easy way for this?
   
   Unfortunately, the spatial query statement of druid is not the same as what we want. I guess that the real spatial filtering function will seriously slow down the query speed.
   If you really need to use Druid for spatial query business, I suggest you modify the code that implements this function in Druid


----------------------------------------------------------------
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:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For additional commands, e-mail: commits-help@druid.apache.org


[GitHub] [druid] SWH12 closed issue #9847: When using Spatial filters, what is the unit of radius

Posted by GitBox <gi...@apache.org>.
SWH12 closed issue #9847:
URL: https://github.com/apache/druid/issues/9847


   


----------------------------------------------------------------
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:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For additional commands, e-mail: commits-help@druid.apache.org


[GitHub] [druid] SWH12 commented on issue #9847: When using Spatial filters, what is the unit of radius

Posted by GitBox <gi...@apache.org>.
SWH12 commented on issue #9847:
URL: https://github.com/apache/druid/issues/9847#issuecomment-630615302


   The unit of radius is Latitude or longitude.
   


----------------------------------------------------------------
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:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For additional commands, e-mail: commits-help@druid.apache.org


[GitHub] [druid] SWH12 closed issue #9847: When using Spatial filters, what is the unit of radius

Posted by GitBox <gi...@apache.org>.
SWH12 closed issue #9847:
URL: https://github.com/apache/druid/issues/9847


   


----------------------------------------------------------------
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:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For additional commands, e-mail: commits-help@druid.apache.org


[GitHub] [druid] SWH12 commented on issue #9847: When using Spatial filters, what is the unit of radius

Posted by GitBox <gi...@apache.org>.
SWH12 commented on issue #9847:
URL: https://github.com/apache/druid/issues/9847#issuecomment-704094601


   > 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
   
   


----------------------------------------------------------------
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:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For additional commands, e-mail: commits-help@druid.apache.org