protected function readTrack($filepath) { $xml = new cls_xml_parser(); try { $array = $xml->loadFile($filepath, false, "ROOT"); if (!isset($array['ROOT']['tracks']['track'])) { return; } $tracks = $array['ROOT']['tracks']['track']; if (isset($tracks['meas'])) { $tracks = $array['ROOT']['tracks']; } if (!is_array($tracks)) { //throw new Exception("track not array:".realpath($filepath).""); return; } foreach ($tracks as $track) { $trackId = $track['trackid']; $astlenpx = $track['astlenpx']; $fake = $track['fake']; $starfactor = $track['starfactor']; $rafactor = $track['rafactor']; $trackparams = array(); foreach ($track as $keyparam => $vparam) { if ($keyparam != "meas") { $trackparams[$keyparam] = $vparam; } } if (!is_array($track['meas'][0])) { return; } //////////////// /*$s = realpath($filepath); $d=dirname($s); $te = fopen($d."/resmeas.txt","a+"); ob_start(); print_r($track); $r1 = ob_get_clean(); fputs($te, $r1); fclose($te);*/ //////////////////////// if (array_key_exists("{$trackId}", $this->arrayTrack) && count($track['meas']) < count($this->arrayTrack["{$trackId}"])) { break; } else { $this->trackCount[$trackId] = 0; $this->arrayTrack["{$trackId}"] = array(); $this->arrayfits["{$trackId}"] = array(); foreach ($track['meas'] as $meas) { //$this->arrayTrack["$trackId"][] = array('x' => $meas['x'], 'y' => $meas['y'], 'fitpath' => $meas['filename']); if (!in_array($meas['filename'], $this->arrayfits["{$trackId}"])) { $this->arrayTrack["{$trackId}"][] = new Point($trackId, array('x' => $meas['x'], 'y' => $meas['y'], 'fitpath' => $meas['filename'], 'mag' => $meas['mag'], 'fake' => $fake, 'astlenpx' => $astlenpx, 'starfactor' => $starfactor, 'rafactor' => $rafactor), 'Apex', $trackparams); $this->arrayfits["{$trackId}"][] = $meas['filename']; $this->trackCount[$trackId] += 1; } } } } return; } catch (Exception $e) { echo "ERROR\n"; echo realpath($filepath); $f = fopen("resterr.txt", "a+"); fputs($f, $e->getMessage()); fclose($f); throw new Exception("no simpledat"); } }
//chdir("./$dateofsquares"); $xmlfile = glob("{$dateofsquares}/*.xml")[0]; //находим общий xml-файл с результатами обработки апекса echo $xmlfile . "\n"; $xml = new cls_xml_parser(); $array = $xml->loadFile($xmlfile, false, 'root'); $arrayTrack = $array['root']['track']; $squareTrack = array(); foreach ($arrayTrack as $track) { $square = $track['meas'][0]['filename']; $s = explode(".", $square); $square = $s[0]; $squareTrack["{$square}"][] = $track; } foreach ($squareTrack as $dirl => $tracks) { $Rxml = new cls_xml_parser(); $Rstr = $Rxml->CreateFromArray('tracks', array('track' => $tracks)); $Rstr = '<?xml version="1.0"?>' . "<ROOT>" . $Rstr; $Rstr .= "</ROOT>"; file_put_contents("{$dateofsquares}/{$dirl}/R00001.xml", $Rstr); } //chdir(".."); } } /* $filepath =('./10323_R/20150703_10323.xml');// $xml = new cls_xml_parser(); $array = $xml->loadFile($filepath, false, 'root'); $arrayTrack = $array['root']['track']; //print_r($array['root']['track']); $squareTrack = array();