@@ -11,8 +11,12 @@ package index
1111/*****************************************************************************************************************/
1212
1313import (
14+ "github.com/observerly/skysolve/pkg/astrometry"
1415 "github.com/observerly/skysolve/pkg/catalog"
1516 "github.com/observerly/skysolve/pkg/healpix"
17+ "github.com/observerly/skysolve/pkg/quad"
18+ "github.com/observerly/skysolve/pkg/solve"
19+ "github.com/observerly/skysolve/pkg/star"
1620)
1721
1822/*****************************************************************************************************************/
@@ -35,3 +39,63 @@ func NewIndexer(
3539}
3640
3741/*****************************************************************************************************************/
42+
43+ func (i * Indexer ) GenerateQuadsForPixel (pixel int ) ([]quad.Quad , error ) {
44+ // Convert the pixel index to the pixel's equatorial coordinate:
45+ eq := i .HealPIX .ConvertPixelIndexToEquatorial (pixel )
46+
47+ // Get the radial extent of the pixel:
48+ radius := i .HealPIX .GetPixelRadialExtent (pixel )
49+
50+ // Get the sources within the pixel's radial extent:
51+ sources , err := i .Catalog .PerformRadialSearch (eq , radius )
52+
53+ // If we encounter an error, return it:
54+ if err != nil {
55+ return nil , err
56+ }
57+
58+ // Convert the sources to stars:
59+ stars := make ([]star.Star , len (sources ))
60+
61+ for _ , source := range sources {
62+ // For each source, we just need to sense check that the source is within the pixel:
63+ eq := astrometry.ICRSEquatorialCoordinate {
64+ RA : source .RA ,
65+ Dec : source .Dec ,
66+ }
67+
68+ pixelIndex := i .HealPIX .ConvertEquatorialToPixelIndex (eq )
69+
70+ // If the source is not within the pixel, skip it:
71+ if pixelIndex != pixel {
72+ continue
73+ }
74+
75+ stars = append (stars , star.Star {
76+ Designation : source .Designation ,
77+ X : source .RA ,
78+ Y : source .Dec ,
79+ RA : source .RA ,
80+ Dec : source .Dec ,
81+ Intensity : source .PhotometricGMeanFlux ,
82+ })
83+ }
84+
85+ // We should have at least 5 sources to generate a quad:
86+ if len (stars ) < 5 {
87+ return nil , nil
88+ }
89+
90+ // Indexing the sources here involves storing the sources locally for future reference:
91+ quads , err := solve .GenerateEuclidianStarQuads (stars , 5 )
92+
93+ // If we encounter an error, return it:
94+ if err != nil {
95+ return nil , err
96+ }
97+
98+ return quads , nil
99+ }
100+
101+ /*****************************************************************************************************************/
0 commit comments