-
Notifications
You must be signed in to change notification settings - Fork 1
demo client API
The OpenQuake django server application exposes the following set of api endpoints for use by the GeoExt client.
^mtapi/ ^input_upload/$
^mtapi/ ^input_upload_result/$
^mtapi/ ^hazard_risk_calc/$
^mtapi/ ^hazard_risk_result/$
Allows the user to upload a NRML file with seismic input model data. Makes use of a multipart/form-data
Form parameters:
- input_files: as described here
The content type of the returned data needs to be text/html.
http://openquake.gemsun02.ethz.ch/mtapi/input_upload/
{ "status": "success", "msg": "Upload processing started", "id": 22 }
Allows clients to obtain the results of the given seismic input upload/
http://openquake.gemsun02.ethz.ch/mtapi/input_upload_result/123/
{"status": "success", "msg": "All uploaded files processed", "id": 123,
"files": [{"id": 1, "name": "src-a.xml"}, {"id": 2, "name": "src-b.xml"}]}
or
{"status": "failure", "msg": "Processing of uploaded files failed",
"id": 123,
Response codes:
- 404: when result not available yet
- 200: when the result is available
- 500: in case of failure
Allows the user to start a combined hazard/risk OpenQuake engine calculation given the chosen geometry and a small selection of calculation parameters.
Once the OpenQuake engine completes the calculation, a shapefile
will be produced for each hazard/loss map and registered with the geonode
server as described under the ("Adding a directory of existing Shapefiles" section on this page)[http://docs.geoserver.org/latest/en/user/restconfig/rest-config-examples/rest-config-examples-curl.html#adding-a-directory-of-existing-shapefiles].
TODO:
- what hazard/risk calculation parameters should be supported by the GUI?
http://openquake.gemsun02.ethz.ch/mtapi/hazard_risk_calc/
{
"model": "mtapi.calculationparams",
"upload": 22,
"fields": {
"job_type": "classical",
"region_grid_spacing": 0.1,
"min_magnitude": 6.1,
"investigation_time": 50.0,
"component": "average",
"imt": "pga",
"period": 12.0,
"truncation_type": "none",
"truncation_level": 1.0,
"reference_vs30_value": 10.0,
"imls": [1.0, 2.0, 3.0],
"poes": [1.0, 2.0, 3.0],
"realizations": 2,
"histories": 5,
"gm_correlated": false,
"region": "POLYGON((-180 -90,180 -90,180 90,-180 90,-180 -90))"
}
}
Please note:
- job_type may be one of the following: 'classical', 'probabilistic', 'deterministic'
- min_magnitude and investigation_time are only set for classical and probabilistic job types
- component may be one of the following: 'average', 'gmroti50'
- imt (intensity measure type) may be one of the following: 'pga', 'sa', 'pgv', 'pgd'
- period is only set if the intensity measure type is 'sa'
- truncation_type may be one of the following: 'none', '1-sided', '2-sided'
- imls (intensity measure levels) and poes (probabilities of exceedence) are only set for classical job types
- realizations (number of logic tree samples) is only set for classical and probabilistic job types
- histories (number of seismicity histories) is only set for probabilistic job types
- gm_correlated (ground motion correlation flag) is only set for probabilistic and deterministic job types
- float values listed above must always be positive
Response data:
{ "status": "success", "msg": "Calculation started", "id": 123 }
TODO:
Allows clients to obtain the results of the given OpenQuake calculation.
http://openquake.gemsun02.ethz.ch/mtapi/hazard_risk_result/123/
Response data (TODO: add min/max for stretched classifications):
{ "status": "success", "msg": "Calculation succeeded", "id": 123,
"files": [{
"id": 77, "name": "loss-map-0fcfdbc7.xml", "type": "loss map",
"path": "/usr/openquake/spool/tmpuJnrZA/123/loss-map-0fcfdbc7.xml",
"shapefile": "/usr/openquake/spool/tmpuJnrZA/123/77/loss-map-0fcfdbc7.shp" }, {
"id": 78, "name": "hazardmap-0.01-mean.xml", "type": "hazard map",
"path": "/usr/openquake/spool/tmpuJnrZA/123/hazardmap-0.01-mean.xml",
"shapefile": "/usr/openquake/spool/tmpuJnrZA/123/78/hazardmap-0.01-mean.shp" }]}
Please note that in case of success the generated shapefiles will be registered with the geonode
server before passing back the results above.
In case of failure the returned json data will look as follows:
{ "status": "failure", "msg": "Calculation failed", "id": 123 }
Response codes:
- 404: when result not available yet
- 200: when the result is available
- 500: in case of failure