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
81255dc2
Commit
81255dc2
authored
2 years ago
by
Clayton, Brandon Scott
Browse files
Options
Downloads
Patches
Plain Diff
get service name from netcdf file
parent
bd568499
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/aashto/src/main/java/gov/usgs/earthquake/nshmp/netcdf/www/NetcdfServiceGroundMotions.java
+21
-18
21 additions, 18 deletions
...rthquake/nshmp/netcdf/www/NetcdfServiceGroundMotions.java
with
21 additions
and
18 deletions
src/aashto/src/main/java/gov/usgs/earthquake/nshmp/netcdf/www/NetcdfServiceGroundMotions.java
+
21
−
18
View file @
81255dc2
...
@@ -8,8 +8,11 @@ import gov.usgs.earthquake.nshmp.geo.Location;
...
@@ -8,8 +8,11 @@ import gov.usgs.earthquake.nshmp.geo.Location;
import
gov.usgs.earthquake.nshmp.netcdf.NetcdfGroundMotions
;
import
gov.usgs.earthquake.nshmp.netcdf.NetcdfGroundMotions
;
import
gov.usgs.earthquake.nshmp.netcdf.NetcdfVersion
;
import
gov.usgs.earthquake.nshmp.netcdf.NetcdfVersion
;
import
gov.usgs.earthquake.nshmp.netcdf.data.StaticData
;
import
gov.usgs.earthquake.nshmp.netcdf.data.StaticData
;
import
gov.usgs.earthquake.nshmp.netcdf.www.Metadata.ServiceResponseMetadata
;
import
gov.usgs.earthquake.nshmp.netcdf.www.NetcdfWsUtils.Key
;
import
gov.usgs.earthquake.nshmp.netcdf.www.NetcdfWsUtils.Key
;
import
gov.usgs.earthquake.nshmp.netcdf.www.Query.Service
;
import
gov.usgs.earthquake.nshmp.netcdf.www.Query.Service
;
import
gov.usgs.earthquake.nshmp.netcdf.www.Request.RequestData
;
import
gov.usgs.earthquake.nshmp.netcdf.www.Request.RequestDataSiteClass
;
import
gov.usgs.earthquake.nshmp.www.ResponseBody
;
import
gov.usgs.earthquake.nshmp.www.ResponseBody
;
import
gov.usgs.earthquake.nshmp.www.ResponseMetadata
;
import
gov.usgs.earthquake.nshmp.www.ResponseMetadata
;
import
gov.usgs.earthquake.nshmp.www.WsUtils
;
import
gov.usgs.earthquake.nshmp.www.WsUtils
;
...
@@ -26,7 +29,6 @@ import io.micronaut.http.HttpRequest;
...
@@ -26,7 +29,6 @@ import io.micronaut.http.HttpRequest;
public
class
NetcdfServiceGroundMotions
extends
NetcdfService
<
Query
>
{
public
class
NetcdfServiceGroundMotions
extends
NetcdfService
<
Query
>
{
static
final
String
SERVICE_DESCRIPTION
=
"Get static ground motions from a NetCDF file"
;
static
final
String
SERVICE_DESCRIPTION
=
"Get static ground motions from a NetCDF file"
;
static
final
String
SERVICE_NAME
=
"AASHTO-2023 Web Service"
;
static
final
String
X_LABEL
=
"Period (s)"
;
static
final
String
X_LABEL
=
"Period (s)"
;
static
final
String
Y_LABEL
=
"Spectral Acceleration (g)"
;
static
final
String
Y_LABEL
=
"Spectral Acceleration (g)"
;
...
@@ -35,12 +37,12 @@ public class NetcdfServiceGroundMotions extends NetcdfService<Query> {
...
@@ -35,12 +37,12 @@ public class NetcdfServiceGroundMotions extends NetcdfService<Query> {
}
}
@Override
@Override
ResponseBody
<
String
,
Metadata
>
getMetadataResponse
(
HttpRequest
<?>
request
)
{
ResponseBody
<
String
,
Metadata
<
Query
>
>
getMetadataResponse
(
HttpRequest
<?>
request
)
{
var
metadata
=
new
Metadata
(
request
,
SERVICE_DESCRIPTION
);
var
metadata
=
new
Metadata
<
Query
>
(
request
,
this
,
SERVICE_DESCRIPTION
);
return
ResponseBody
.<
String
,
Metadata
>
usage
()
return
ResponseBody
.<
String
,
Metadata
<
Query
>
>
usage
()
.
metadata
(
new
ResponseMetadata
(
NetcdfVersion
.
appVersions
()))
.
metadata
(
new
ResponseMetadata
(
NetcdfVersion
.
appVersions
()))
.
name
(
SERVICE_NAME
)
.
name
(
getServiceName
()
)
.
request
(
NetcdfWsUtils
.
getRequestUrl
(
request
))
.
request
(
NetcdfWsUtils
.
getRequestUrl
(
request
))
.
response
(
metadata
)
.
response
(
metadata
)
.
url
(
NetcdfWsUtils
.
getRequestUrl
(
request
))
.
url
(
NetcdfWsUtils
.
getRequestUrl
(
request
))
...
@@ -49,12 +51,12 @@ public class NetcdfServiceGroundMotions extends NetcdfService<Query> {
...
@@ -49,12 +51,12 @@ public class NetcdfServiceGroundMotions extends NetcdfService<Query> {
@Override
@Override
String
getServiceName
()
{
String
getServiceName
()
{
return
SERVICE_NAME
;
return
getSourceModel
().
name
;
}
}
@Override
@Override
SourceModel
getSourceModel
()
{
SourceModel
getSourceModel
()
{
return
new
SourceModel
();
return
new
SourceModel
(
netcdf
()
);
}
}
@Override
@Override
...
@@ -63,18 +65,18 @@ public class NetcdfServiceGroundMotions extends NetcdfService<Query> {
...
@@ -63,18 +65,18 @@ public class NetcdfServiceGroundMotions extends NetcdfService<Query> {
}
}
@Override
@Override
ResponseBody
<?,
?>
processRequest
(
HttpRequest
<?>
httpRequest
,
Query
query
,
Service
service
)
{
String
processRequest
(
HttpRequest
<?>
httpRequest
,
Query
query
,
Service
service
)
{
var
site
=
Location
.
create
(
query
.
longitude
,
query
.
latitude
);
var
site
=
Location
.
create
(
query
.
longitude
,
query
.
latitude
);
var
requestData
=
new
RequestData
(
site
);
var
requestData
=
new
RequestData
(
site
,
query
.
format
);
var
url
=
NetcdfWsUtils
.
getRequestUrl
(
httpRequest
);
var
url
=
NetcdfWsUtils
.
getRequestUrl
(
httpRequest
);
switch
(
service
)
{
switch
(
service
)
{
case
CURVES:
case
CURVES:
return
processCurves
(
requestData
,
url
);
return
toResponseFromList
(
processCurves
(
requestData
,
url
)
)
;
case
CURVES_BY_SITE_CLASS:
case
CURVES_BY_SITE_CLASS:
requestData
=
new
RequestDataSiteClass
(
site
,
query
.
siteClass
);
requestData
=
new
RequestDataSiteClass
(
site
,
query
.
siteClass
,
query
.
format
);
return
processCurvesSiteClass
(
return
toResponse
(
processCurvesSiteClass
(
(
RequestDataSiteClass
)
requestData
,
url
);
(
RequestDataSiteClass
)
requestData
,
url
)
)
;
default
:
default
:
throw
new
RuntimeException
(
"Netcdf service ["
+
service
+
"] not found"
);
throw
new
RuntimeException
(
"Netcdf service ["
+
service
+
"] not found"
);
}
}
...
@@ -92,7 +94,7 @@ public class NetcdfServiceGroundMotions extends NetcdfService<Query> {
...
@@ -92,7 +94,7 @@ public class NetcdfServiceGroundMotions extends NetcdfService<Query> {
return
ResponseBody
.<
RequestDataSiteClass
,
ResponseData
<
ServiceResponseMetadata
>>
success
()
return
ResponseBody
.<
RequestDataSiteClass
,
ResponseData
<
ServiceResponseMetadata
>>
success
()
.
metadata
(
new
ResponseMetadata
(
NetcdfVersion
.
appVersions
()))
.
metadata
(
new
ResponseMetadata
(
NetcdfVersion
.
appVersions
()))
.
name
(
SERVICE_NAME
)
.
name
(
getServiceName
()
)
.
request
(
request
)
.
request
(
request
)
.
response
(
responseData
)
.
response
(
responseData
)
.
url
(
url
)
.
url
(
url
)
...
@@ -106,11 +108,11 @@ public class NetcdfServiceGroundMotions extends NetcdfService<Query> {
...
@@ -106,11 +108,11 @@ public class NetcdfServiceGroundMotions extends NetcdfService<Query> {
WsUtils
.
checkValue
(
Key
.
LATITUDE
,
request
.
latitude
);
WsUtils
.
checkValue
(
Key
.
LATITUDE
,
request
.
latitude
);
WsUtils
.
checkValue
(
Key
.
LONGITUDE
,
request
.
longitude
);
WsUtils
.
checkValue
(
Key
.
LONGITUDE
,
request
.
longitude
);
var
curves
=
netcdf
().
staticData
(
request
.
site
);
var
curves
=
netcdf
().
staticData
(
request
.
site
);
var
responseData
=
toList
(
request
.
site
,
curves
);
var
responseData
=
toList
(
request
,
curves
);
return
ResponseBody
.<
RequestData
,
List
<
ResponseData
<
ServiceResponseMetadata
>>>
success
()
return
ResponseBody
.<
RequestData
,
List
<
ResponseData
<
ServiceResponseMetadata
>>>
success
()
.
metadata
(
new
ResponseMetadata
(
NetcdfVersion
.
appVersions
()))
.
metadata
(
new
ResponseMetadata
(
NetcdfVersion
.
appVersions
()))
.
name
(
SERVICE_NAME
)
.
name
(
getServiceName
()
)
.
request
(
request
)
.
request
(
request
)
.
response
(
responseData
)
.
response
(
responseData
)
.
url
(
url
)
.
url
(
url
)
...
@@ -118,11 +120,12 @@ public class NetcdfServiceGroundMotions extends NetcdfService<Query> {
...
@@ -118,11 +120,12 @@ public class NetcdfServiceGroundMotions extends NetcdfService<Query> {
}
}
List
<
ResponseData
<
ServiceResponseMetadata
>>
toList
(
List
<
ResponseData
<
ServiceResponseMetadata
>>
toList
(
Location
site
,
RequestData
requestData
,
StaticData
<
XySequence
>
curves
)
{
StaticData
<
XySequence
>
curves
)
{
return
curves
.
entrySet
().
stream
()
return
curves
.
entrySet
().
stream
()
.
map
(
entry
->
{
.
map
(
entry
->
{
var
request
=
new
RequestDataSiteClass
(
site
,
entry
.
getKey
());
var
request
=
new
RequestDataSiteClass
(
requestData
.
site
,
entry
.
getKey
(),
requestData
.
format
);
return
toResponseData
(
request
,
entry
.
getValue
());
return
toResponseData
(
request
,
entry
.
getValue
());
})
})
.
collect
(
Collectors
.
toList
());
.
collect
(
Collectors
.
toList
());
...
...
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