Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
V
vlkb-siav2
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
ViaLactea
vlkb-siav2
Commits
5a4ae663
Commit
5a4ae663
authored
1 year ago
by
Robert Butora
Browse files
Options
Downloads
Patches
Plain Diff
cleans up Corrd (and removes last remaining & escapes)
parent
480ae8c8
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
data-discovery/src/main/java/vlkb/common/Coord.java
+91
-143
91 additions, 143 deletions
data-discovery/src/main/java/vlkb/common/Coord.java
with
91 additions
and
143 deletions
data-discovery/src/main/java/vlkb/common/Coord.java
+
91
−
143
View file @
5a4ae663
...
...
@@ -146,87 +146,10 @@ 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
;
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."
);
}
/*
Coord(String lon, String lat, String radius, String velLow, String velUp)
{
try
{
this.skySystem = "GALACTIC";
this.lon = Double.parseDouble(lon);
this.lat = Double.parseDouble(lat);
this.radius = Double.parseDouble(radius);
}
catch(Exception e)
{
throw new IllegalArgumentException("lon and lat are mandatory: " + e.getMessage());
}
if(this.radius <= 0.0) throw new IllegalArgumentException("radius must be positive and not zero");
this.shape = "CIRCLE";
if((velLow != null) && (velUp != null))
{
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;
}
else
{
this.vel_valid = false;
}
}
Coord(double lon, double lat, double radius)
{
if(radius < 0.0)
throw new IllegalArgumentException("radius must be bigger than zero: " + radius);
this.skySystem = "GALACTIC";
this.lon = lon;
this.lat = lat;
this.radius = radius;
this.shape = "CIRCLE";
this.vel_valid = false;
}
Coord(double lon, double lat, double dlon, double dlat)
{
if((dlon < 0.0) || (dlat < 0.0))
throw new IllegalArgumentException("both dlon and dlat must be bigger than zero: " + dlon + " " + dlat);
this.skySystem = "GALACTIC";
this.lon = lon;
this.lat = lat;
this.dlon = dlon;
this.dlat = dlat;
this.shape = "RECT";
this.vel_valid = false;
}
*/
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
;
...
...
@@ -235,51 +158,11 @@ class Coord
this
.
vel_valid
=
true
;
}
// utils
public
String
toString
()
{
String
area
=
null
;
switch
(
shape
)
{
case
"CIRCLE"
:
area
=
String
.
valueOf
(
radius
);
break
;
case
"RECT"
:
area
=
dlon
+
", "
+
dlat
;
break
;
default
:
// FIXME leave with exception
area
=
"err: "
+
shape
;
}
String
resourceSearchArea
=
"(P; area) = ("
+
lon
+
", "
+
lat
+
"; "
+
area
+
") [deg]"
;
return
resourceSearchArea
;
}
void
toXML
(
PrintWriter
writer
)
{
// center is mandatory -> create no Coord if center not valid
writer
.
println
(
"<SkySystem>"
+
skySystem
+
"</SkySystem>"
);
writer
.
println
(
"<l>"
+
lon
+
"</l>"
);
writer
.
println
(
"<b>"
+
lat
+
"</b>"
);
switch
(
shape
)
{
case
"CIRCLE"
:
writer
.
println
(
"<r>"
+
String
.
valueOf
(
radius
)+
"</r>"
);
break
;
case
"RECT"
:
writer
.
println
(
"<dl>"
+
String
.
valueOf
(
dlon
)+
"</dl>"
);
writer
.
println
(
"<db>"
+
String
.
valueOf
(
dlat
)+
"</db>"
);
break
;
default
:
writer
.
println
(
"<shape> unknown shape: "
+
shape
+
" </shape>"
);
}
if
(
vel_valid
)
{
writer
.
println
(
"<vl>"
+
String
.
valueOf
(
vel_low
)
+
"</vl>"
);
writer
.
println
(
"<vu>"
+
String
.
valueOf
(
vel_up
)
+
"</vu>"
);
writer
.
println
(
"<vtype>"
+
vel_type
+
"</vtype>"
);
}
}
// generate cutout/merge queryStrings
String
toQueryString
()
{
...
...
@@ -289,38 +172,34 @@ class Coord
return
toVoQueryString
();
}
// FIXME separate keywords into dictionary key-string (LON->"l" LAT->"b" SKYSYSTEM->"skysystem")
// to be part of api/QueryStringParams.java
String
toVlkbLegacyQueryString
()
{
LOGGER
.
info
(
"trace"
);
StringBuilder
sb
=
new
StringBuilder
();
sb
.
append
(
"skysystem="
+
skySystem
);
sb
.
append
(
"&
amp;
l="
+
lon
);
sb
.
append
(
"&
amp;
b="
+
lat
);
sb
.
append
(
"&l="
+
lon
);
sb
.
append
(
"&b="
+
lat
);
switch
(
shape
)
{
case
"CIRCLE"
:
sb
.
append
(
"&
amp;
r="
+
radius
);
break
;
// writer.println("<r>"+String.valueOf(radius)+"</r>"); break;
case
"CIRCLE"
:
sb
.
append
(
"&r="
+
radius
);
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>");
sb
.
append
(
"&dl="
+
dlon
);
sb
.
append
(
"&db="
+
dlat
);
break
;
default
:
// ERROR internal err FIXME writer.println("<shape>
unknown shape: "+
shape +" </
shape
>"
);
LOGGER
.
info
(
"Coord::toVlkbLegacyQueryString:
unknown 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>");
sb
.
append
(
"&vl="
+
vel_low
);
sb
.
append
(
"&vu="
+
vel_up
);
sb
.
append
(
"&specsystem="
+
vel_type
);
}
return
sb
.
toString
();
...
...
@@ -329,6 +208,8 @@ class Coord
String
toVoQueryString
()
{
LOGGER
.
info
(
"trace"
);
StringBuilder
sb
=
new
StringBuilder
();
sb
.
append
(
"skysystem="
+
skySystem
);
...
...
@@ -353,12 +234,86 @@ class Coord
break
;
default
:
;
// ERROR internal err FIXME writer.println("<shape> unknown shape: "+ shape +" </shape>");
LOGGER
.
info
(
"Coord::toVoQueryString: unknown shape: "
+
shape
);
}
if
(
vel_valid
)
{
sb
.
append
(
"&BAND= "
+
vel_low
+
" "
+
vel_up
);
sb
.
append
(
"&specsystem="
+
vel_type
);
}
return
sb
.
toString
();
}
// utils
public
String
toString
()
{
String
area
=
null
;
switch
(
shape
)
{
case
"CIRCLE"
:
area
=
String
.
valueOf
(
radius
);
break
;
case
"RECT"
:
area
=
dlon
+
", "
+
dlat
;
break
;
default
:
// FIXME leave with exception
area
=
"err: "
+
shape
;
}
String
resourceSearchArea
=
"(P; area) = ("
+
lon
+
", "
+
lat
+
"; "
+
area
+
") [deg]"
;
return
resourceSearchArea
;
}
void
toXML
(
PrintWriter
writer
)
{
// center is mandatory -> create no Coord if center not valid
writer
.
println
(
"<SkySystem>"
+
skySystem
+
"</SkySystem>"
);
writer
.
println
(
"<l>"
+
lon
+
"</l>"
);
writer
.
println
(
"<b>"
+
lat
+
"</b>"
);
switch
(
shape
)
{
case
"CIRCLE"
:
writer
.
println
(
"<r>"
+
String
.
valueOf
(
radius
)+
"</r>"
);
break
;
case
"RECT"
:
writer
.
println
(
"<dl>"
+
String
.
valueOf
(
dlon
)+
"</dl>"
);
writer
.
println
(
"<db>"
+
String
.
valueOf
(
dlat
)+
"</db>"
);
break
;
default
:
writer
.
println
(
"<shape> unknown shape: "
+
shape
+
" </shape>"
);
}
if
(
vel_valid
)
{
writer
.
println
(
"<vl>"
+
String
.
valueOf
(
vel_low
)
+
"</vl>"
);
writer
.
println
(
"<vu>"
+
String
.
valueOf
(
vel_up
)
+
"</vu>"
);
writer
.
println
(
"<vtype>"
+
vel_type
+
"</vtype>"
);
}
}
// used in constructor and parseVlkb
// 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
;
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."
);
}
// used in parseSoda
String
getFirstString
(
Map
<
String
,
String
[]>
params
,
String
key
)
{
String
[]
values
=
params
.
get
(
key
);
...
...
@@ -386,11 +341,4 @@ class Coord
return
stringArray
;
}
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment