Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
N
nshmp-ws-static
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
Service Desk
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
ghsc
National Seismic Hazard Model Project
nshmp-ws-static
Commits
fee2f13f
Commit
fee2f13f
authored
2 years ago
by
Clayton, Brandon Scott
Browse files
Options
Downloads
Patches
Plain Diff
Move metadta to own class
parent
11f87dce
No related branches found
Branches containing commit
No related tags found
Tags containing commit
2 merge requests
!124
Production Release | nshmp-ws-static
,
!123
Resolves - Remove GITLAB_TOKEN Requirement and AASHTO-2023 web service -- add CSV response
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/lib/src/main/java/gov/usgs/earthquake/nshmp/netcdf/www/Metadata.java
+111
-0
111 additions, 0 deletions
...n/java/gov/usgs/earthquake/nshmp/netcdf/www/Metadata.java
with
111 additions
and
0 deletions
src/lib/src/main/java/gov/usgs/earthquake/nshmp/netcdf/www/Metadata.java
0 → 100644
+
111
−
0
View file @
fee2f13f
package
gov.usgs.earthquake.nshmp.netcdf.www
;
import
gov.usgs.earthquake.nshmp.gmm.Imt
;
import
gov.usgs.earthquake.nshmp.gmm.NehrpSiteClass
;
import
gov.usgs.earthquake.nshmp.netcdf.Netcdf
;
import
gov.usgs.earthquake.nshmp.netcdf.data.ScienceBaseMetadata
;
import
gov.usgs.earthquake.nshmp.netcdf.www.NetcdfService.SourceModel
;
import
gov.usgs.earthquake.nshmp.netcdf.www.Request.RequestData
;
import
gov.usgs.earthquake.nshmp.netcdf.www.Request.RequestDataImt
;
import
gov.usgs.earthquake.nshmp.netcdf.www.Request.RequestDataSiteClass
;
import
gov.usgs.earthquake.nshmp.netcdf.www.meta.DoubleParameter
;
import
io.micronaut.http.HttpRequest
;
/**
* Web service metadata.
*
* @author U.S. Geological Survey
*/
public
class
Metadata
<
T
extends
Query
>
{
public
final
String
description
;
public
final
String
[]
syntax
;
public
final
SourceModel
model
;
public
final
DoubleParameter
longitude
;
public
final
DoubleParameter
latitude
;
public
final
DoubleParameter
vs30
;
public
final
NetcdfMetadata
netcdfMetadata
;
Metadata
(
HttpRequest
<?>
request
,
NetcdfService
<
T
>
netcdfService
,
String
description
)
{
var
netcdf
=
netcdfService
.
netcdf
();
var
url
=
request
.
getUri
().
toString
();
url
=
url
.
endsWith
(
"/"
)
?
url
.
substring
(
0
,
url
.
length
()
-
1
)
:
url
;
this
.
description
=
description
;
syntax
=
new
String
[]
{
url
+
"/{longitude:number}/{latitude:number}"
,
url
+
"?longitude={number}&latitude={number}"
,
url
+
"/{longitude:number}/{latitude:number}/{siteClass:NehrpSiteClass}"
,
url
+
"?longitude={number}&latitude={number}&siteClass={NehrpSiteClass}"
,
};
var
min
=
netcdf
.
netcdfData
().
minimumBounds
();
var
max
=
netcdf
.
netcdfData
().
maximumBounds
();
longitude
=
new
DoubleParameter
(
"Longitude"
,
"°"
,
min
.
longitude
,
max
.
longitude
);
latitude
=
new
DoubleParameter
(
"Latitude"
,
"°"
,
min
.
latitude
,
max
.
latitude
);
model
=
netcdfService
.
getSourceModel
();
vs30
=
new
DoubleParameter
(
"Vs30"
,
"m/s"
,
150
,
1500
);
netcdfMetadata
=
new
NetcdfMetadata
(
netcdf
);
}
class
NetcdfMetadata
{
public
final
String
netcdfFile
;
public
final
ScienceBaseMetadata
scienceBaseMetadata
;
NetcdfMetadata
(
Netcdf
<?>
netcdf
)
{
var
fileName
=
netcdf
.
netcdfPath
().
getFileName
();
netcdfFile
=
fileName
==
null
?
netcdf
.
netcdfPath
().
toString
()
:
fileName
.
toString
();
scienceBaseMetadata
=
netcdf
.
netcdfData
().
scienceBaseMetadata
();
}
}
interface
ServiceMetadata
{
RequestData
toRequestMetadata
(
RequestData
requestData
);
}
static
class
ServiceResponseMetadata
implements
ServiceMetadata
{
public
NehrpSiteClass
siteClass
;
public
String
xLabel
;
public
String
yLabel
;
ServiceResponseMetadata
(
NehrpSiteClass
siteClass
,
String
xLabel
,
String
yLabel
)
{
this
.
siteClass
=
siteClass
;
this
.
xLabel
=
xLabel
;
this
.
yLabel
=
yLabel
;
}
@Override
public
RequestDataSiteClass
toRequestMetadata
(
RequestData
requestData
)
{
return
new
RequestDataSiteClass
(
requestData
.
site
,
siteClass
,
requestData
.
format
);
}
}
static
class
HazardResponseMetadata
extends
ServiceResponseMetadata
{
public
final
Imt
imt
;
HazardResponseMetadata
(
NehrpSiteClass
siteClass
,
Imt
imt
,
String
xLabel
,
String
yLabel
)
{
super
(
siteClass
,
xLabel
,
yLabel
);
this
.
imt
=
imt
;
}
@Override
public
RequestDataImt
toRequestMetadata
(
RequestData
requestData
)
{
return
new
RequestDataImt
(
requestData
.
site
,
siteClass
,
imt
,
requestData
.
format
);
}
}
}
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