Adds an index over the separate long and lat columns. This is currently implemented using q3c; DaCHS will move to pgsphere entirely at some point. RDs using this will not need an update then. This will by default cluster according to the index. In the rare cases when you don't want this, add a cluster="False" in the FEED element. Since long and lat may be expressions, this will not automatically declare index/columns. You should therefore pass in a comma-separated list of column names in the columns attribute in order to inform clients of the index. Examples:: <FEED source="//scs#splitPosIndex" long="ra" lat="dec" columns="ra,dec"/> <FEED source="//scs#splitPosIndex" long="long(ssa_location)" lat="lat(ssa_location)" columns="ssa_location"/> \columns q3c_ang2ipix(\long,\lat) Definition of a q3c index over the main position of a table. \\nameForUCDs{pos.eq.ra;meta.main|POS_EQ_RA_MAIN}, \\nameForUCDs{pos.eq.dec;meta.main|POS_EQ_DEC_MAIN} q3c_ang2ipix(\\nameForUCDs{pos.eq.ra;meta.main|POS_EQ_RA_MAIN}, \\nameForUCDs{pos.eq.dec;meta.main|POS_EQ_DEC_MAIN}) A mixin adding an index to the main equatorial positions. In new RDs, use pgs-pos-index instead; we'd like to stop q3c support at some point. This is what you usually want if your input data already has "sane" (i.e., ICRS or at least J2000) positions or you convert the positions manually. You have to designate exactly one column with the ucds pos.eq.ra;meta.main pos.eq.dec;meta.main, respectively. These columns receive the positional index. This will fail without the q3c extension to postgres. Definition of an index over spoint(ra, dec); give this parameters long and lat naming the corresponding columns (in degrees). Or use the spoint-index mixin. This will by default cluster according to the index. In the rare cases when you don't want this, add a cluster="False" in the FEED element. This needs to be replayed within a table (or something that defines a tablename macro). \ra,\dec spoint(radians(\ra),radians(\dec)) A mixin adding a pgsphere index to the main spherical position for tables with separate RA and Dec columns. You have to designate exactly one column with the ucds pos.eq.ra;meta.main pos.eq.dec;meta.main, respectively. These columns receive the positional index. This should be used instead of q3cindex on new tables; it's a bit slower than q3c, but it's less funky, too. If you'd like an index on other sorts of long/lat pairs, see the //scs#spoint-index-def STREAM. None None from gavo.protocols import scs def getRADec(inPars, sqlPars): """tries to guess coordinates from inPars. (for human SCS condition). """ pos = inPars["hscs_pos"] try: return base.parseCooPair(pos) except ValueError: data = base.caches.getSesame("web").query(pos) if not data: raise base.ValidationError("%s is neither a RA,DEC" " pair nor a simbad resolvable object"% inPars["hscs_pos"], "hscs_pos") return float(data["RA"]), float(data["dec"]) def genQuery(td, inPars, outPars): """returns the query fragment for this cone search. """ return scs.getRadialCondition(td, "%%(%s)s"%base.getSQLKey("RA", inPars["RA"], outPars), "%%(%s)s"%base.getSQLKey("DEC", inPars["DEC"], outPars), "%%(%s)s"%base.getSQLKey("SR", inPars["SR"], outPars), raColName, decColName) scs.xml scs.xml scs.xml yield genQuery(core.queriedTable, inPars, outPars) scs.xml scs.xml if inPars["hscs_pos"] is None: return if inPars["hscs_sr"] is None: raise base.ValidationError("If you query for a position," " you must give a search radius", "hscs_sr") ra, dec = getRADec(inPars, outPars) try: sr = float(inPars["hscs_sr"])/60. except ValueError: # in case we're not running behind forms raise gavo.ValidationError("Not a valid float", "hscs_sr") inPars = {"RA": ra, "DEC": dec, "SR": sr} yield genQuery(core.queriedTable, inPars, outPars) This is also used in ```` ]]> from gavo.protocols import scs