'', 'type' => '', 'mission' => '', 'units' => '','time_resolution' => '', 'fillval' => '', 'coordinate_system' => '', 'label' => ''); function __construct() { $this->myParamsInfoMgr = new ParamsInfoMgr(); $this->xmlName = orbitesXml; if (file_exists($this->xmlName)) unlink($this->xmlName); $this->contentDom = new DomDocument("1.0"); $this->contentDom->preserveWhiteSpace = false; $this->contentDom->formatOutput = true; $this->createDom(); $this->xp = new domxpath($this->contentDom); } protected function createDom() { $rootElement = $this->contentDom->createElement('orbitesList'); $this->contentDom->appendChild($rootElement); $this->contentDom->save($this->xmlName); } /* * Add Orbites in Orbites.xml */ protected function addOrbites($obj) { $objList = $this->contentDom->documentElement; $newObj = $this->contentDom->createElement($this->objTagName); $newObj->setAttribute('xml:id',$this->id); $obj_arr = (array)$obj; foreach ($obj_arr as $key => $value) { if ($key != 'xml:id') $newObj->setAttribute($key, $value); } $objList -> appendChild($newObj); $this->contentDom->save($this->xmlName); } /***************************************************************** * PUBLIC FUNCTIONS *****************************************************************/ public function createOrbites() { $parametresXml = new DomDocument(); if (file_exists(paramXml)) { $parametresXml -> load(paramXml); $xpath = new DOMXpath($parametresXml); $parametres = $xpath->query("//PARAM[@type='orbit']"); if (!is_null($parametres)) { foreach ($parametres as $parametre) { $paramInfo = $this->myParamsInfoMgr->GetDDInfoFromParameterID($parametre->getAttribute('xml:id')); $mission = $paramInfo['submission']['id']; if ($mission == '') $mission = $paramInfo['mission_id']; echo $parametre->getAttribute('xml:id')." was generated....".$mission.PHP_EOL; if ($mission != '') { $obj = (object)array( "param" => $parametre->getAttribute('xml:id'), "name" => $parametre->getAttribute('name'), "type" => $parametre->getAttribute('type'), "mission" => strtoupper($mission), "units" => $parametre->getElementsByTagName('UNITS')->item(0)->nodeValue, "time_resolution" => $parametre->getElementsByTagName('TIME_RESOLUTION')->item(0)->nodeValue, "fillval" => $parametre->getElementsByTagName('FILLVAL')->item(0)->nodeValue, "coordinate_system" => $parametre->getElementsByTagName('COORDINATE_SYSTEM')->item(0)->nodeValue, "label" => $parametre->getElementsByTagName('LABEL_I')->item(0)->nodeValue ); $this->id = $obj->param; $this -> addOrbites($obj); } } } else { return array('success' => false, 'message' => "Local param file is empty"); } } else { echo "Local param file doesn't exist ".paramXml.PHP_EOL; return array('success' => false, 'message' => "Local param file doesn't exist"); } } public function createOrbitesInfoFiles($locBases){ $domTargets = new DomDocument(); if (!$domTargets->load(targetsSimu)) { $msg = "Cannot load file ".targetsSimu.PHP_EOL; if (!$this->updateOnly) error_log($msg,1,email); continue; } $targets = $domTargets->getElementsByTagName('target'); foreach ($targets as $target) { $help = "
$sat:
";
$dom = new DomDocument();
if (!$dom->load($domName)) {
$msg = "Cannot load file ".$domName.PHP_EOL;
print_r($msg);
if (!$this->updateOnly) error_log($msg,1,email);
continue;
}
$domParam = new DomDocument();
if (!$domParam->load($domParamName)) {
$msg = "Cannot load file ".$domParamName.PHP_EOL;
print_r($msg);
if (!$this->updateOnly) error_log($msg,1,email);
continue;
}
$domOrbites = new DomDocument();
if (!$domOrbites->load(orbitesXml)) {
$msg = "Cannot load file ".orbitesXml.PHP_EOL;
print_r($msg);
if (!$this->updateOnly) error_log($msg,1,email);
continue;
}
$xp = new domxpath($dom);
$xpParam = new domxpath($domParam);
$xpOrb = new domxpath($domOrbites);
$body = explode('.',$target->nodeValue);
$query = "//dataset";
$datasets = $xp->query($query);
if ($datasets->length > 0){
foreach ($datasets as $dataset){
$vi = $dataset->getAttribute('xml:id');
$query = "//PARAM[@vi='$vi']";
$param = $xpParam->query($query);
if($param->length > 0){
$paramID = $param->item(0)->getAttribute('xml:id');
$query = "//orbites[@xml:id='$paramID']";
$orbites = $xpOrb->query($query);
if ($orbites->length > 0) { // && $dataset->getElementsByTagName('target')->item(0)->nodeValue == $body[0]){
if ($dataset->getElementsByTagName('target')->item(0)->nodeValue == $body[0] ){
// $help = $help."
$sat: "; $title = $dataset->getElementsByTagName('title')->item(0)->nodeValue; $start = $dataset->getElementsByTagName('dataStart')->item(0)->nodeValue; $stop = $dataset->getElementsByTagName('dataStop')->item(0)->nodeValue; $help = $help."$title: $start - $stop
"; if ($target->nodeValue == 'Ganymede') $help = $help."You can find the Ganymede flyby TimeTable in the Shared Time Tables/OTHER/ganymede_flyby
$sat: "; $start = $dataset->getElementsByTagName('dataStart')->item(0)->nodeValue; $stop = $dataset->getElementsByTagName('dataStop')->item(0)->nodeValue; $help = $help.$orbites->item(0)->getAttribute('mission')." $start - $stop
"; } elseif ($dataset->getElementsByTagName('title')->item(0)->nodeValue == 'CLUSTER1' || $dataset->getElementsByTagName('title')->item(0)->nodeValue == 'CLUSTER2' || $dataset->getElementsByTagName('title')->item(0)->nodeValue == 'CLUSTER3' || $dataset->getElementsByTagName('title')->item(0)->nodeValue == 'CLUSTER4'){ // $help = $help."$sat: "; $start = $dataset->getElementsByTagName('dataStart')->item(0)->nodeValue; $stop = $dataset->getElementsByTagName('dataStop')->item(0)->nodeValue; $help = $help.$orbites->item(0)->getAttribute('param')." $start - $stop
"; } } } } } } } $help = $help."