Spatial Filter giving data out of range(filtering)

73 views
Skip to first unread message

Jitesh Mogre

unread,
May 12, 2017, 5:35:02 AM5/12/17
to Druid User
Hi All,

I am querying for 0.01-mile radius with latitude and longitude, But in return, it's giving me data which are not in radius of lat-long.

"filter": {
    "type": "and",
    "fields": [
      {
        "type": "spatial",
        "dimension": "coordinates",
        "bound": {
          "type": "radius",
          "coords": [
            53.342429,
            -6.259931
          ],
          "radius": 0.01
        }
      }
    ]
  },

Its giving me 1.2 miles data also.

What is the unit for radius? Am I doing something wrong?
Can we trust Geo-Spatial Query in Druid?

Please help me to understand this


Thanks,
Jitesh

Jitesh Mogre

unread,
May 12, 2017, 6:37:55 AM5/12/17
to Druid User
When I am converting radius with lat-long to min max lat-long. I am getting the result as I expect.

"filter": {
    "type": "and",
    "fields": [
      {
        "type": "spatial",
        "dimension": "coordinates",
        "bound": {
          "type": "rectangular",
          "minCoords": [
            53.339531898289835,
            -6.2647739227516315
          ],
          "maxCoords": [
            53.34532610171017,
            -6.255088077248368
          ]
        }
      }
    ]
  },


I thing something I am doing different in radius, may be the radius unit is different.

calculating min-max lat-long by radius----------

                double radiusInMiles = 0.2;
double radiusInKm = radiusInMiles * 1.60934;

double lat = 53.342429;
double lon = -6.259931;

double kmInLongitudeDegree = 111.320 * Math.cos( lat / 180.0 * Math.PI);

double deltaLat = radiusInKm / 111.1;
double deltaLong = radiusInKm / kmInLongitudeDegree;

double minLat = lat - deltaLat;  
double maxLat = lat + deltaLat;
double minLong = lon - deltaLong; 
double maxLong = lon + deltaLong;

53.34532610171017     -6.255088077248368   53.339531898289835       -6.2647739227516315



Hope It will help our other friends too.

Please let me know if we can do same with radius.

Thanks,
Jitesh


Jitesh Mogre

unread,
May 13, 2017, 7:43:36 AM5/13/17
to Druid User
Anyone knows the unit of radius in spatial query ?

Nishant Bangarwa

unread,
May 14, 2017, 10:29:55 PM5/14/17
to Druid User
Hi Jitesh, the radis is in terms of difference in degrees terms of latitude and longitude. 
A PR to improve this to add support for units in terms of km or miles would be awesome. 


On Sat, 13 May 2017 at 17:13 Jitesh Mogre <jitu...@gmail.com> wrote:
Anyone knows the unit of radius in spatial query ?

--
You received this message because you are subscribed to the Google Groups "Druid User" group.
To unsubscribe from this group and stop receiving emails from it, send an email to druid-user+...@googlegroups.com.
To post to this group, send email to druid...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/druid-user/bdad841e-b0b0-45b4-bb2b-9078514443c6%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages