gnuastro-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[gnuastro-commits] master e07e645: Query: value ranges are defined befor


From: Mohammad Akhlaghi
Subject: [gnuastro-commits] master e07e645: Query: value ranges are defined before positional
Date: Wed, 20 Jan 2021 11:25:01 -0500 (EST)

branch: master
commit e07e645f632640b85f9bee9bfd810ba2ed0f2988
Author: Mohammad Akhlaghi <mohammad@akhlaghi.org>
Commit: Mohammad Akhlaghi <mohammad@akhlaghi.org>

    Query: value ranges are defined before positional
    
    Until now while constructing the ADQL query, I first had the spatial range
    component (selecting rows within a certain distance of RA and Dec for
    example), then the value range component (like '--range' or
    '--noblank'). But it seems more logical to first limit the rows to those
    that are with a certain value (which is computationally much more easier),
    then do the spatial checks.
    
    With this commit, this has been done: we now first limit the rows by their
    indiviual values, then do the 2D searching.
    
    Also, I noticed that on VizieR, the Gaia DR2 catalog doesn't have RAJ2000
    and DEJ2000. So the default spatial columns are changed to 'ra_epoch2000'
    and 'dec_epoch2000'.
---
 bin/query/tap.c    | 13 ++++++-------
 bin/query/vizier.c |  2 ++
 2 files changed, 8 insertions(+), 7 deletions(-)

diff --git a/bin/query/tap.c b/bin/query/tap.c
index 8bdbf91..61fc57f 100644
--- a/bin/query/tap.c
+++ b/bin/query/tap.c
@@ -201,7 +201,7 @@ tap_query_construct_spatial(struct queryparams *p)
      other components of the query can assume that the single-quote
      environment is active.*/
   if( asprintf(&spatialstr,
-               "WHERE 1=CONTAINS( POINT('\"'ICRS', %s, %s), %s )\"'",
+               "1=CONTAINS( POINT('\"'ICRS', %s, %s), %s )\"'",
                p->ra_name, p->dec_name, regionstr)<0 )
     error(EXIT_FAILURE, 0, "%s: asprintf allocation ('querystr')",
           __func__);
@@ -324,15 +324,14 @@ tap_query_construct_data(struct queryparams *p)
   if(p->range) tap_query_construct_range(p, &valuelimitstr);
 
   /* Write the automatically generated query string.  */
-  if( asprintf(&querystr,  "'SELECT %s %s FROM %s %s %s %s'",
+  if( asprintf(&querystr,  "'SELECT %s %s FROM %s %s %s %s %s'",
                headstr ? headstr : "",
                columns,
                datasetstr,
-               spatialstr ? spatialstr : "",
-               ( valuelimitstr && spatialstr
-                 ? "AND"
-                 : valuelimitstr ? "WHERE" : "" ),
-               valuelimitstr ? valuelimitstr : "")<0 )
+               ( valuelimitstr || spatialstr ? "WHERE" : ""),
+               valuelimitstr ? valuelimitstr : "",
+               ( valuelimitstr && spatialstr ? "AND"   : "" ),
+               spatialstr ? spatialstr : "")<0 )
     error(EXIT_FAILURE, 0, "%s: asprintf allocation ('querystr')",
           __func__);
 
diff --git a/bin/query/vizier.c b/bin/query/vizier.c
index 7ed4e45..81bee59 100644
--- a/bin/query/vizier.c
+++ b/bin/query/vizier.c
@@ -91,6 +91,8 @@ vizier_sanity_checks(struct queryparams *p)
       else if( !strcmp(p->datasetstr, "gaiadr2") )
         {
           free(p->datasetstr);
+          if(p->ra_name==NULL) p->ra_name="ra_epoch2000";
+          if(p->dec_name==NULL) p->dec_name="dec_epoch2000";
           gal_checkset_allocate_copy("I/345/gaia2", &p->datasetstr);
         }
       else if( !strcmp(p->datasetstr, "gaiaedr3") )



reply via email to

[Prev in Thread] Current Thread [Next in Thread]