public function prepareXMLValue($xml_data, $db_features)
 {
     if ($this->aws_format->isOldawsFormat()) {
         $period = str_pad($xml_data['period'], 3, "0", STR_PAD_LEFT);
         if ($xml_data['solar_radiation_in_period'][0] == 'M') {
             $ac_period_tmp_str = 'MMMMMM';
         } else {
             $ac_period = It::convertMetric($xml_data['solar_radiation_in_period'], 'joule_per_sq_meter', $db_features['solar_radiation_in_period']);
             $ac_period_tmp = $this->getPow($ac_period);
             $ac_period_tmp_str = str_pad(round($ac_period_tmp[0], 3) * 1000, 4, '0', STR_PAD_LEFT) . str_pad($ac_period_tmp[1], 2, "0", STR_PAD_LEFT);
         }
         $ac_total_tmp_str = 'MMMMMM';
         return $period . $ac_period_tmp_str . $ac_total_tmp_str;
     } else {
         $period = str_pad($xml_data['period'], 3, "0", STR_PAD_LEFT);
         if ($xml_data['solar_radiation_in_period'][0] == 'M') {
             $ac_period_tmp_str = 'MMMMMM';
         } else {
             $ac_period = It::convertMetric($xml_data['solar_radiation_in_period'], 'joule_per_sq_meter', $db_features['solar_radiation_in_period']);
             $ac_period_tmp = $this->getPow($ac_period);
             $ac_period_tmp_str = str_pad(round($ac_period_tmp[0], 3) * 1000, 4, '0', STR_PAD_LEFT) . str_pad($ac_period_tmp[1], 2, "0", STR_PAD_LEFT);
         }
         $ac_total_tmp_str = 'MMMMMM';
         return $ac_period_tmp_str . $ac_total_tmp_str;
     }
 }
Пример #2
0
 public function prepareXMLValue($xml_data, $db_features)
 {
     if ($this->aws_format->isOldawsFormat()) {
         $data_1 = str_pad($xml_data['period'], 3, "0", STR_PAD_LEFT);
         if (isset($xml_data['rain_in_period']) && $xml_data['rain_in_period'] != 'M') {
             $tmp = It::convertMetric($xml_data['rain_in_period'], 'millimeter', $db_features['rain_in_period']);
             $data_2 = str_pad(round($tmp * 1000), 6, "0", STR_PAD_LEFT);
         } else {
             $data_2 = str_repeat('M', 6);
         }
         if (isset($xml_data['rain_in_day']) && $xml_data['rain_in_day'] != 'M') {
             $tmp = It::convertMetric($xml_data['rain_in_day'], 'inch', $db_features['rain_in_day']);
             $data_3 = str_pad(round($tmp * 1000), 6, "0");
         } else {
             $data_3 = str_repeat('M', 6);
         }
         return $data_1 . $data_2 . $data_3;
     } else {
         $data_1 = str_pad($xml_data['period'], 3, "0", STR_PAD_LEFT);
         if (isset($xml_data['rain_in_period']) && $xml_data['rain_in_period'] != 'M') {
             $tmp = It::convertMetric($xml_data['rain_in_period'], 'millimeter', $db_features['rain_in_period']);
             $data_2 = str_pad(round($tmp * 1000), 6, "0", STR_PAD_LEFT);
         } else {
             $data_2 = str_repeat('M', 6);
         }
         if (isset($xml_data['rain_in_day']) && $xml_data['rain_in_day'] != 'M') {
             $tmp = It::convertMetric($xml_data['rain_in_day'], 'inch', $db_features['rain_in_day']);
             $data_3 = str_pad(round($tmp * 1000), 6, "0");
         } else {
             $data_3 = str_repeat('M', 6);
         }
         return $data_2 . $data_3;
     }
 }