segasai / q3c

PostgreSQL extension for spatial indexing on a sphere
GNU General Public License v2.0
76 stars 27 forks source link

Objects near polygon boundary not selected by q3c_poly_query() #6

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?

1. Create a simple two column table with two double precision fields: ra and 
dec. Populate the table with uniformly spaced values of ra and dec, centered at 
(ra = 45.0, dec = 90.0), and a total width of 2 degrees on a side. Create a q3c 
index on the table with q3c_ang2ipix.

2. Define a four-sided polygon whose vertices lie just a few arcseconds outside 
the range of ra and dec values in the table, e.g. 
{88.999,43.999,88.999,46.001,91.001,46.001,91.001,43.999}.  

3. Select objects from the table using q3c_poly_query and the polygon defined 
in step 2.

What is the expected output? What do you see instead?

I expect the query to return all the rows in the table. However, a few rows 
near one boundary are not selected, as shown in Fig_1.png. The blue dots show 
the coordinates of selected objects; the white dots show ones that should have 
been selected, but were not. 

What version of the product are you using? On what operating system?

I'm using:

* q3c-1.4.17
* Postgresql v9.2.1
* Linux (2.6.18-308.4.1.el5)

Please provide any additional information below.

It appears that this problem is independent of RA, but strongly dependent on 
the absolute value of declination.  The number of objects 'missed' by 
poly_query increases as you move away from 0.0, but starts to decrease again as 
you move to the poles (above ~80 degrees).  The 'missing' objects always appear 
only on the boundary closest to dec = 0.0. 

Original issue reported on code.google.com by greg.j.m...@gmail.com on 18 Dec 2012 at 3:18

Attachments:

GoogleCodeExporter commented 9 years ago
This is not the bug. The queries are done using spherical polygons. E.g. the 
edges  of polygons are great circles, therefore  they almost never follow 
constant declination lines   (except dec=0).

Original comment by koposov on 18 Dec 2012 at 3:23

GoogleCodeExporter commented 9 years ago
Oops, sorry about that, I should have realised!

Original comment by greg.j.m...@gmail.com on 18 Dec 2012 at 3:40