Adding Query Fields to DVO

It is easy to add new query-able fields to DVO. This page discusses extending the queries. If you would like to extend the schema, see the following page: DVO_Adding_to_the_Schema?.

Note that fields which can be queried do not need to be restricted to fields that exist in the schema. It is possible to define a query-able field which is a function of an element of the schema (or a combination of multiple elements). For example, galactic latitude and longitude are available to be queried, but do not appear in the schema: they are calculated on-the-fly from RA & DEC.

Note: all paths below are relative to ipp/Ohana/src/opihi except where noted.

The three main types of queries (imextract, mextract, avextract) are all very similar in how they are implemented. The fields which can be queried are defined by enum entries in the file include/dvoshell.h. Fields query-able by mextract have names like MEAS_RA; by avextract, AVE_RA; by imextract, IMAGE_RA.

To add a new field, you need to first add it to the appropriate enum above.

Next, you need to add the field to the appropriate Parse*Field function in dvo/dbFields.c. There is one for each of the queries above: ParseMeasureField?(), ParseAverageField?(), ParseImageField?(). You need to add an entry to the list of tests for each field. Eg:

  if (!strcasecmp (fieldName, "PSF_QF"))     	 ESCAPE (MEAS_PSF_QF,         MAG_NONE, OPIHI_FLT);

The name in quotes is the name visible to the user. The ESCAPE macro sets the elements of a 'field' structure and returns, making it known that this is a valid field. The arguments of the ESCAPE macro are: the enum name of the field, the type of magnitude measurement being defined (NONE if not a magnitude), and the type of the output data generated by this field (OPIHI_INT or OPIHI_FLT).

Finally, you have to add the field to one of three .c files: dbExtractMeasures.c, dbExtractAverages.c, dbExtractImages.c.

In these files, you need to define the meaning of the field. You need to add a 'case' entry for your field, and assign the Flt or Int element of 'value' to the value of your field:

    case MEAS_PSF_QF: /* OK */
      value.Flt = measure[0].psfQual;
      break;