Skip to content
Snippets Groups Projects
Commit b2db84b1 authored by Robert Butora's avatar Robert Butora
Browse files

fixes overlap code

parent 300126d5
No related branches found
No related tags found
No related merge requests found
...@@ -60,7 +60,6 @@ public class DbObstap ...@@ -60,7 +60,6 @@ public class DbObstap
Double em_min, em_max, em_res_power; Double em_min, em_max, em_res_power;
Long em_xel; Long em_xel;
boolean em_valid;
String o_ucd; String o_ucd;
...@@ -208,7 +207,8 @@ public class DbObstap ...@@ -208,7 +207,8 @@ public class DbObstap
String dbRegion = toRegionColumnName(pos.system); String dbRegion = toRegionColumnName(pos.system);
String theQuery ="SELECT *," String theQuery ="SELECT *,"
+ inputRegion + " <@ " + dbRegion + " AS inputInsideDb, " + inputRegion + " && " + dbRegion + " AS inputOverlapsDb, "
+ inputRegion + " <@ " + dbRegion + " AS inputInsideDb, "
+ inputRegion + " @> " + dbRegion + " AS dbInsideInput FROM obscore WHERE (obs_publisher_did IN (\'" + inputRegion + " @> " + dbRegion + " AS dbInsideInput FROM obscore WHERE (obs_publisher_did IN (\'"
+commaSepPubdids+"\'))"; +commaSepPubdids+"\'))";
...@@ -257,9 +257,8 @@ public class DbObstap ...@@ -257,9 +257,8 @@ public class DbObstap
obstap.t_resolution = this.getDouble(res,"t_resolution"); obstap.t_resolution = this.getDouble(res,"t_resolution");
obstap.t_xel = this.getLong(res,"t_xel"); obstap.t_xel = this.getLong(res,"t_xel");
obstap.em_min = this.getDouble(res,"em_min"); boolean em_min_valid = !res.wasNull(); obstap.em_min = this.getDouble(res,"em_min");
obstap.em_max = this.getDouble(res,"em_max"); boolean em_max_valid = !res.wasNull(); obstap.em_max = this.getDouble(res,"em_max");
obstap.em_valid = em_min_valid && em_max_valid;;
obstap.em_res_power = this.getDouble(res,"em_res_power"); obstap.em_res_power = this.getDouble(res,"em_res_power");
obstap.em_xel = this.getLong(res,"em_xel"); obstap.em_xel = this.getLong(res,"em_xel");
...@@ -274,16 +273,22 @@ public class DbObstap ...@@ -274,16 +273,22 @@ public class DbObstap
// VLKB extension // VLKB extension
obstap.s_region_galactic = this.getString(res,"s_region_galactic"); obstap.s_region_galactic = this.getString(res,"s_region_galactic");
obstap.vel_min = this.getDouble(res,"vel_min"); //boolean em_min_valid = !res.wasNull(); obstap.vel_min = this.getDouble(res,"vel_min");
obstap.vel_max = this.getDouble(res,"vel_max"); //boolean em_max_valid = !res.wasNull(); obstap.vel_max = this.getDouble(res,"vel_max");
boolean inputOverlapsDb = res.getBoolean("inputOverlapsDb");
boolean inputInsideDb = res.getBoolean("inputInsideDb"); boolean inputInsideDb = res.getBoolean("inputInsideDb");
boolean dbInsideInput = res.getBoolean("dbInsideInput"); boolean dbInsideInput = res.getBoolean("dbInsideInput");
obstap.overlapCodeSky = convertToOverlapCodeSky(inputInsideDb, dbInsideInput); LOGGER.finest("inpOverlapsDb, inpInsideDb, dbInsideInp : "
+ inputOverlapsDb + " " + inputInsideDb + " " + dbInsideInput);
obstap.overlapCodeVel = convertToOverlapCodeVel(band,obstap.em_valid,obstap.em_min,obstap.em_max); obstap.overlapCodeSky = convertToOverlapCodeSky(inputOverlapsDb, inputInsideDb, dbInsideInput);
obstap.overlapCode = convertToOverlapCode(obstap.overlapCodeSky, obstap.overlapCodeVel); obstap.overlapCodeVel = convertToOverlapCodeVel(band,
obstap.em_min,obstap.em_max,
obstap.vel_min,obstap.vel_max );
obstap.overlapCode = convertToOverlapCode(obstap.overlapCodeSky, obstap.overlapCodeVel);
obstapList.add(obstap); obstapList.add(obstap);
...@@ -303,24 +308,56 @@ public class DbObstap ...@@ -303,24 +308,56 @@ public class DbObstap
return cubes; return cubes;
} }
/* convert overlap codes */ /* convert overlap codes (AST definition):
"0 - The check could not be performed because the second Region could not be mapped into the coordinate system of the first Region.",
"1 - There is no overlap between the two Regions.",
"2 - The first Region is completely inside the second Region.",
"3 - The second Region is completely inside the first Region.",
"4 - There is partial overlap between the two Regions.",
"5 - The Regions are identical to within their uncertainties.",
"6 - The second Region is the exact negation of the first Region to within their uncertainties."
*/
private Integer convertToOverlapCodeSky(boolean inpOverlapsDb, boolean inpInDb, boolean dbInInp)
{
if(inpOverlapsDb)
{
if(!inpInDb && !dbInInp) return 4;
else if( inpInDb && !dbInInp) return 3;
else if(!inpInDb && dbInInp) return 2;
else return 5;
}
else
{
return 1;
}
}
private boolean intervalOverlap(double amin, double amax, double bmin, double bmax)
{
boolean AoverB
= (amin <= bmin) && (bmin <= amax)
|| (amin <= bmax) && (bmax <= amax);
private Integer convertToOverlapCodeSky(boolean inpInDb, boolean dbInInp) boolean BoverA
{ = (bmin <= amin) && (amin <= bmax)
if(!inpInDb && !dbInInp) return 4; // parial overlap || (bmin <= amax) && (amax <= bmax);
else if( inpInDb && !dbInInp) return 3; // input region completely inside fits-datacube
else if(!inpInDb && dbInInp) return 2; // datacube completely inside input-region return AoverB || BoverA;
else return 5; // exact match: both inpInDb dbInInp are true
} }
private Integer convertToOverlapCodeVel(Band band, boolean v_valid, double v_min, double v_max) private Integer convertToOverlapCodeVel(Band band,
Double w_min, Double w_max, // WAVE
Double v_min, Double v_max) // VELO
{ {
if((band != null) && v_valid) if(band != null)
{ {
if(band.system == Band.System.VELO_LSRK) boolean v_valid = (v_min != null) && (v_max != null);
boolean w_valid = (w_min != null) && (w_max != null);
if( v_valid && (band.system == Band.System.VELO_LSRK) )
{ {
// FIXME assert qArgs: vel_min <= vel_max boolean overlap = intervalOverlap(band.min, band.max, v_min, v_max);;
// FIXME assert cube: v_min <= v_max
boolean dbInInp = (band.min <= v_min) && (v_min <= band.max) boolean dbInInp = (band.min <= v_min) && (v_min <= band.max)
&& (band.min <= v_max) && (v_max <= band.max); && (band.min <= v_max) && (v_max <= band.max);
...@@ -328,20 +365,44 @@ public class DbObstap ...@@ -328,20 +365,44 @@ public class DbObstap
boolean inpInDb = (v_min <= band.min) && (band.min <= v_max) boolean inpInDb = (v_min <= band.min) && (band.min <= v_max)
&& (v_min <= band.max ) && (band.max <= v_max); && (v_min <= band.max ) && (band.max <= v_max);
return convertToOverlapCodeSky(inpInDb, dbInInp); // do as in Sky-overlap
return convertToOverlapCodeSky(overlap, inpInDb, dbInInp);
}
else if( w_valid && (band.system == Band.System.WAVE_Barycentric) )
{
boolean overlap = intervalOverlap(band.min, band.max, w_min, w_max);;
boolean dbInInp = (band.min <= w_min) && (w_min <= band.max)
&& (band.min <= w_max) && (w_max <= band.max);
boolean inpInDb = (w_min <= band.min) && (band.min <= w_max)
&& (w_min <= band.max ) && (band.max <= w_max);
// do as in Sky-overlap
return convertToOverlapCodeSky(overlap, inpInDb, dbInInp);
}
else
{
return null;
} }
else return null;// FIXME other v_type NotImplemented yet
} }
else
return null; {
return null;
}
} }
private Integer convertToOverlapCode(Integer ovcSky, Integer ovcVel) private Integer convertToOverlapCode(Integer ovcSky, Integer ovcVel)
{ {
if(ovcVel == null) return ovcSky; // 2D images if(ovcSky == null) return ovcVel; // spectral images or both null
else if(ovcSky == ovcVel) return ovcSky; else if(ovcVel == null) return ovcSky; // 2D sky images or both null
else return 4;// partial overlap else if((ovcSky != null) && (ovcVel != null))
{
if((ovcSky == 1) || (ovcVel == 1) ) return 1; // no overlap
else if(ovcSky == ovcVel) return ovcSky;
else return 4;
}
else return null; // both null
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment