Commit f750cd4f21699e8457fa15d0b1fcaae14f10482a
1 parent
2719c3a2
Exists in
master
and in
72 other branches
Add size & display_time in user defined paramters list from WS (#9649)
Showing
1 changed file
with
35 additions
and
0 deletions
Show diff stats
php/WebServices/WebServer.php
... | ... | @@ -382,6 +382,41 @@ class WebServer |
382 | 382 | return array('success' => true,'ParameterList' => |
383 | 383 | array("LocalDataBaseParameters" => WSConfigClass::getUrl().$locParamDst)); |
384 | 384 | |
385 | + // Inject size & display_type | |
386 | + // => In derived parameters | |
387 | + $dom = new DOMDocument( "1.0"); | |
388 | + $dom->formatOutput = TRUE; | |
389 | + $dom->preserveWhiteSpace = FALSE; | |
390 | + $dom->load(WSConfigClass::getWsResultDir().$wsParamDst); | |
391 | + $paramNodes = $dom->getElementsByTagName("param"); | |
392 | + foreach ($paramNodes as $paramNode) { | |
393 | + $dim_1 = $paramNode->getAttribute('dim_1'); | |
394 | + $dim_1 = empty($dim_1) ? 1 : intval($dim_1); | |
395 | + $dim_2 = $paramNode->getAttribute('dim_2'); | |
396 | + $dim_2 = empty($dim_2) ? 1 : intval($dim_2); | |
397 | + $paramNode->setAttribute('size', $dim_1 * $dim_2); | |
398 | + | |
399 | + $display_type = 'timeseries'; | |
400 | + if ($dim_1 > 1 && $dim_2 > 1) { | |
401 | + $display_type = 'spectrogram'; | |
402 | + } | |
403 | + else if ($dim_1 > 3 || $dim_2 > 3) { | |
404 | + $display_type = 'spectrogram'; | |
405 | + } | |
406 | + $paramNode->setAttribute('display_type', $display_type); | |
407 | + } | |
408 | + // => In parameters from an uploaded file | |
409 | + $paramNodes = $dom->getElementsByTagName("mydata"); | |
410 | + foreach ($paramNodes as $paramNode) { | |
411 | + // size already exists | |
412 | + $display_type = 'timeseries'; | |
413 | + if ($paramNode->getAttribute('plottype') == 'Spectra') { | |
414 | + $display_type = 'spectrogram'; | |
415 | + } | |
416 | + $paramNode->setAttribute('display_type', $display_type); | |
417 | + } | |
418 | + $dom->save(WSConfigClass::getWsResultDir().$wsParamDst); | |
419 | + | |
385 | 420 | return array('success' => true,'ParameterList' => |
386 | 421 | array("UserDefinedParameters" => WSConfigClass::getUrl().$wsParamDst, |
387 | 422 | "LocalDataBaseParameters" => WSConfigClass::getUrl().$locParamDst)); |
... | ... |