django-daiquiri / daiquiri

A framework for the publication of scientific databases
https://escience.aip.de/daiquiri
Apache License 2.0
26 stars 8 forks source link

BUG: the default query for the cone search is wrong #203

Open kimakan opened 1 year ago

kimakan commented 1 year ago

https://github.com/django-daiquiri/daiquiri/blob/33094c5389e0acb0b30fcc1db54b7bb6bafaf0c5/daiquiri/conesearch/adapter.py#L102-L109

Possible solution would be using the function for the angular distance between two points on a sphere cos(d) = sin(dec1)sin(dec2) + cos(dec1)cos(dec2)cos(ra1-ra2).

SELECT %(id_field)s, %(ra_field)s, %(dec_field)s
FROM %(schema)s.%(table)s
WHERE ACOS(SIN(RADIANS(%(dec_field)))*SIN(RADIANS(%%(DEC)s)) 
                      + COS(RADIANS(%(dec_field)))*COS(RADIANS(%%(DEC)s))*COS(RADIANS(%(ra_field) - %%(RA)s))) 
              < RADIANS(%%(SR)s)
LIMIT %(limit)s