Loading data-discovery/src/main/java/vlkb/common/Coord.java +91 −143 Original line number Diff line number Diff line Loading @@ -146,94 +146,109 @@ class Coord } // if param present -> must have at least one value static private String getFirstValue(Map<String, String[]> map, String key) { String[] value = map.get(key); if(value == null) return null; void setSkySystem(String skySystem) { this.skySystem = skySystem; } void setSpecSystem(String velType) { this.vel_type = velType; } if(value.length > 0) // key-value present at least once: return first occurance return value[0].toString(); else // length=0: no values present (array exists but is empty) throw new IllegalArgumentException("parameter " + key + " has no value."); void setVelocity(double vel_low, double vel_up, String vel_type) { this.vel_type = vel_type; this.vel_low = vel_low; this.vel_up = vel_up; this.vel_valid = true; } /* Coord(String lon, String lat, String radius, String velLow, String velUp) { try // generate cutout/merge queryStrings String toQueryString() { this.skySystem = "GALACTIC"; this.lon = Double.parseDouble(lon); this.lat = Double.parseDouble(lat); this.radius = Double.parseDouble(radius); if(API_VLKB_legacy) return toVlkbLegacyQueryString(); else return toVoQueryString(); } catch(Exception e) String toVlkbLegacyQueryString() { throw new IllegalArgumentException("lon and lat are mandatory: " + e.getMessage()); } LOGGER.info("trace"); if(this.radius <= 0.0) throw new IllegalArgumentException("radius must be positive and not zero"); StringBuilder sb = new StringBuilder(); this.shape = "CIRCLE"; sb.append("skysystem=" + skySystem); sb.append("&l=" + lon ); sb.append("&b=" + lat ); if((velLow != null) && (velUp != null)) switch(shape) { this.vel_low = Double.parseDouble(velLow); this.vel_up = Double.parseDouble(velUp); this.vel_type = "1"; // VELO + LSRK //this.vel_type = "2"; // WAVE + Barycentric this.vel_valid = true; case "CIRCLE" : sb.append("&r=" + radius ); break; case "RECT" : sb.append("&dl=" + dlon ); sb.append("&db=" + dlat ); break; default: LOGGER.info("Coord::toVlkbLegacyQueryString: unknown shape: " + shape); } else if(vel_valid) { this.vel_valid = false; sb.append("&vl=" + vel_low); sb.append("&vu=" + vel_up ); sb.append("&specsystem=" + vel_type ); } return sb.toString(); } String toVoQueryString() { LOGGER.info("trace"); StringBuilder sb = new StringBuilder(); sb.append("skysystem=" + skySystem); Coord(double lon, double lat, double radius) switch(shape) { if(radius < 0.0) throw new IllegalArgumentException("radius must be bigger than zero: " + radius); case "CIRCLE" : sb.append("&POS=CIRCLE " + lon + " " + lat + " " + + radius ); break; this.skySystem = "GALACTIC"; this.lon = lon; this.lat = lat; this.radius = radius; this.shape = "CIRCLE"; this.vel_valid = false; case "RECT" : if(vel_valid) sb.append("&POS=RANGE=" + " " + (lon - dlon) + " " + (lon + dlon) + " " + (lat - dlat) + " " + (lat + dlat) + " " + vel_low + " " + vel_up ); else sb.append("&POS=RANGE=" + " " + (lon - dlon) + " " + (lon + dlon) + " " + (lat - dlat) + " " + (lat + dlat) ); break; default: LOGGER.info("Coord::toVoQueryString: unknown shape: " + shape); } Coord(double lon, double lat, double dlon, double dlat) if(vel_valid) { if((dlon < 0.0) || (dlat < 0.0)) throw new IllegalArgumentException("both dlon and dlat must be bigger than zero: " + dlon + " " + dlat); sb.append("&BAND= " + vel_low + " " + vel_up); sb.append("&specsystem=" + vel_type ); } this.skySystem = "GALACTIC"; this.lon = lon; this.lat = lat; this.dlon = dlon; this.dlat = dlat; this.shape = "RECT"; this.vel_valid = false; return sb.toString(); } */ void setSkySystem(String skySystem) { this.skySystem = skySystem; } void setSpecSystem(String velType) { this.vel_type = velType; } // spectral axis void setVelocity(double vel_low, double vel_up, String vel_type) { this.vel_type = vel_type; this.vel_low = vel_low; this.vel_up = vel_up; this.vel_valid = true; } // utils Loading Loading @@ -281,84 +296,24 @@ class Coord } String toQueryString() { if(API_VLKB_legacy) return toVlkbLegacyQueryString(); else return toVoQueryString(); } // FIXME separate keywords into dictionary key-string (LON->"l" LAT->"b" SKYSYSTEM->"skysystem") // to be part of api/QueryStringParams.java String toVlkbLegacyQueryString() { StringBuilder sb = new StringBuilder(); sb.append("skysystem=" + skySystem); sb.append("&l=" + lon ); sb.append("&b=" + lat ); switch(shape) { case "CIRCLE" : sb.append("&r=" + radius ); break;// writer.println("<r>"+String.valueOf(radius)+"</r>"); break; case "RECT" : sb.append("&dl=" + dlon ); sb.append("&db=" + dlat ); //writer.println("<dl>"+String.valueOf(dlon)+"</dl>"); //writer.println("<db>"+String.valueOf(dlat)+"</db>"); break; default: // ERROR internal err FIXME writer.println("<shape> unknown shape: "+ shape +" </shape>"); } if(vel_valid) { sb.append("&vl=" + vel_low); sb.append("&vu=" + vel_up ); sb.append("&vt=" + vel_type ); // writer.println("<vl>" + String.valueOf(vel_low) +"</vl>"); // writer.println("<vu>" + String.valueOf(vel_up) +"</vu>"); // writer.println("<vtype>"+ vel_type +"</vtype>"); } return sb.toString(); } String toVoQueryString() { StringBuilder sb = new StringBuilder(); sb.append("skysystem=" + skySystem); switch(shape) // used in constructor and parseVlkb // if param present -> must have at least one value static private String getFirstValue(Map<String, String[]> map, String key) { case "CIRCLE" : sb.append("&POS=CIRCLE " + lon + " " + lat + " " + + radius ); break; case "RECT" : if(vel_valid) sb.append("&POS=RANGE=" + " " + (lon - dlon) + " " + (lon + dlon) + " " + (lat - dlat) + " " + (lat + dlat) + " " + vel_low + " " + vel_up ); String[] value = map.get(key); else sb.append("&POS=RANGE=" + " " + (lon - dlon) + " " + (lon + dlon) + " " + (lat - dlat) + " " + (lat + dlat) ); break; if(value == null) return null; default: ;// ERROR internal err FIXME writer.println("<shape> unknown shape: "+ shape +" </shape>"); if(value.length > 0) // key-value present at least once: return first occurance return value[0].toString(); else // length=0: no values present (array exists but is empty) throw new IllegalArgumentException("parameter " + key + " has no value."); } return sb.toString(); } // used in parseSoda String getFirstString(Map<String, String[]> params, String key) { String[] values = params.get(key); Loading Loading @@ -386,11 +341,4 @@ class Coord return stringArray; } } Loading
data-discovery/src/main/java/vlkb/common/Coord.java +91 −143 Original line number Diff line number Diff line Loading @@ -146,94 +146,109 @@ class Coord } // if param present -> must have at least one value static private String getFirstValue(Map<String, String[]> map, String key) { String[] value = map.get(key); if(value == null) return null; void setSkySystem(String skySystem) { this.skySystem = skySystem; } void setSpecSystem(String velType) { this.vel_type = velType; } if(value.length > 0) // key-value present at least once: return first occurance return value[0].toString(); else // length=0: no values present (array exists but is empty) throw new IllegalArgumentException("parameter " + key + " has no value."); void setVelocity(double vel_low, double vel_up, String vel_type) { this.vel_type = vel_type; this.vel_low = vel_low; this.vel_up = vel_up; this.vel_valid = true; } /* Coord(String lon, String lat, String radius, String velLow, String velUp) { try // generate cutout/merge queryStrings String toQueryString() { this.skySystem = "GALACTIC"; this.lon = Double.parseDouble(lon); this.lat = Double.parseDouble(lat); this.radius = Double.parseDouble(radius); if(API_VLKB_legacy) return toVlkbLegacyQueryString(); else return toVoQueryString(); } catch(Exception e) String toVlkbLegacyQueryString() { throw new IllegalArgumentException("lon and lat are mandatory: " + e.getMessage()); } LOGGER.info("trace"); if(this.radius <= 0.0) throw new IllegalArgumentException("radius must be positive and not zero"); StringBuilder sb = new StringBuilder(); this.shape = "CIRCLE"; sb.append("skysystem=" + skySystem); sb.append("&l=" + lon ); sb.append("&b=" + lat ); if((velLow != null) && (velUp != null)) switch(shape) { this.vel_low = Double.parseDouble(velLow); this.vel_up = Double.parseDouble(velUp); this.vel_type = "1"; // VELO + LSRK //this.vel_type = "2"; // WAVE + Barycentric this.vel_valid = true; case "CIRCLE" : sb.append("&r=" + radius ); break; case "RECT" : sb.append("&dl=" + dlon ); sb.append("&db=" + dlat ); break; default: LOGGER.info("Coord::toVlkbLegacyQueryString: unknown shape: " + shape); } else if(vel_valid) { this.vel_valid = false; sb.append("&vl=" + vel_low); sb.append("&vu=" + vel_up ); sb.append("&specsystem=" + vel_type ); } return sb.toString(); } String toVoQueryString() { LOGGER.info("trace"); StringBuilder sb = new StringBuilder(); sb.append("skysystem=" + skySystem); Coord(double lon, double lat, double radius) switch(shape) { if(radius < 0.0) throw new IllegalArgumentException("radius must be bigger than zero: " + radius); case "CIRCLE" : sb.append("&POS=CIRCLE " + lon + " " + lat + " " + + radius ); break; this.skySystem = "GALACTIC"; this.lon = lon; this.lat = lat; this.radius = radius; this.shape = "CIRCLE"; this.vel_valid = false; case "RECT" : if(vel_valid) sb.append("&POS=RANGE=" + " " + (lon - dlon) + " " + (lon + dlon) + " " + (lat - dlat) + " " + (lat + dlat) + " " + vel_low + " " + vel_up ); else sb.append("&POS=RANGE=" + " " + (lon - dlon) + " " + (lon + dlon) + " " + (lat - dlat) + " " + (lat + dlat) ); break; default: LOGGER.info("Coord::toVoQueryString: unknown shape: " + shape); } Coord(double lon, double lat, double dlon, double dlat) if(vel_valid) { if((dlon < 0.0) || (dlat < 0.0)) throw new IllegalArgumentException("both dlon and dlat must be bigger than zero: " + dlon + " " + dlat); sb.append("&BAND= " + vel_low + " " + vel_up); sb.append("&specsystem=" + vel_type ); } this.skySystem = "GALACTIC"; this.lon = lon; this.lat = lat; this.dlon = dlon; this.dlat = dlat; this.shape = "RECT"; this.vel_valid = false; return sb.toString(); } */ void setSkySystem(String skySystem) { this.skySystem = skySystem; } void setSpecSystem(String velType) { this.vel_type = velType; } // spectral axis void setVelocity(double vel_low, double vel_up, String vel_type) { this.vel_type = vel_type; this.vel_low = vel_low; this.vel_up = vel_up; this.vel_valid = true; } // utils Loading Loading @@ -281,84 +296,24 @@ class Coord } String toQueryString() { if(API_VLKB_legacy) return toVlkbLegacyQueryString(); else return toVoQueryString(); } // FIXME separate keywords into dictionary key-string (LON->"l" LAT->"b" SKYSYSTEM->"skysystem") // to be part of api/QueryStringParams.java String toVlkbLegacyQueryString() { StringBuilder sb = new StringBuilder(); sb.append("skysystem=" + skySystem); sb.append("&l=" + lon ); sb.append("&b=" + lat ); switch(shape) { case "CIRCLE" : sb.append("&r=" + radius ); break;// writer.println("<r>"+String.valueOf(radius)+"</r>"); break; case "RECT" : sb.append("&dl=" + dlon ); sb.append("&db=" + dlat ); //writer.println("<dl>"+String.valueOf(dlon)+"</dl>"); //writer.println("<db>"+String.valueOf(dlat)+"</db>"); break; default: // ERROR internal err FIXME writer.println("<shape> unknown shape: "+ shape +" </shape>"); } if(vel_valid) { sb.append("&vl=" + vel_low); sb.append("&vu=" + vel_up ); sb.append("&vt=" + vel_type ); // writer.println("<vl>" + String.valueOf(vel_low) +"</vl>"); // writer.println("<vu>" + String.valueOf(vel_up) +"</vu>"); // writer.println("<vtype>"+ vel_type +"</vtype>"); } return sb.toString(); } String toVoQueryString() { StringBuilder sb = new StringBuilder(); sb.append("skysystem=" + skySystem); switch(shape) // used in constructor and parseVlkb // if param present -> must have at least one value static private String getFirstValue(Map<String, String[]> map, String key) { case "CIRCLE" : sb.append("&POS=CIRCLE " + lon + " " + lat + " " + + radius ); break; case "RECT" : if(vel_valid) sb.append("&POS=RANGE=" + " " + (lon - dlon) + " " + (lon + dlon) + " " + (lat - dlat) + " " + (lat + dlat) + " " + vel_low + " " + vel_up ); String[] value = map.get(key); else sb.append("&POS=RANGE=" + " " + (lon - dlon) + " " + (lon + dlon) + " " + (lat - dlat) + " " + (lat + dlat) ); break; if(value == null) return null; default: ;// ERROR internal err FIXME writer.println("<shape> unknown shape: "+ shape +" </shape>"); if(value.length > 0) // key-value present at least once: return first occurance return value[0].toString(); else // length=0: no values present (array exists but is empty) throw new IllegalArgumentException("parameter " + key + " has no value."); } return sb.toString(); } // used in parseSoda String getFirstString(Map<String, String[]> params, String key) { String[] values = params.get(key); Loading Loading @@ -386,11 +341,4 @@ class Coord return stringArray; } }