function GetRange($point, $raidus) { //计算纬度 $degree = 111293.636111; $radiusLat = $raidus / $degree; $res['minlat'] = $point['lat'] - $radiusLat; //得到最小纬度 $res['maxlat'] = $point['lat'] + $radiusLat; //得到最大纬度 //计算经度 $mpdLng = $degree * cos($point['lat'] * (Pi() / 180)); $radiusLng = $raidus / $mpdLng; $res['minlng'] = $point['lng'] - $radiusLng; //得到最小经度 $res['maxlng'] = $point['lng'] + $radiusLng; //得到最大经度 return $res; }
public function prepareData() { parent::prepareData(); $this->initForm(); $this->createFormFields(); $this->setFieldValuesFromRequest(); $request = CoreServices::get('request'); $this->A = $this->form->getField('A')->getValue(); $this->H = $this->form->getField('H')->getValue(); $this->L1 = $this->form->getField('L1')->getValue(); $this->DLS = $this->form->getField('DLS')->getValue(); $this->DLS2 = $this->form->getField('DLS2')->getValue(); $this->alfa2 = $this->form->getField('alfa2')->getValue(); $this->L3 = $this->form->getField('L3')->getValue(); $this->Azimuth = $this->form->getField('Azimuth')->getValue(); $this->targetInclination = $this->form->getField('targetInclination')->getValue(); $this->targetAzimuth = $this->form->getField('targetAzimuth')->getValue(); $this->TR = $this->form->getField('TR')->getValue(); $this->TL = $this->form->getField('TL')->getValue(); $this->BR = $this->form->getField('BR')->getValue(); $this->BL = $this->form->getField('BL')->getValue(); $this->SR = $this->form->getField('SR')->getValue(); $this->ST = $this->form->getField('ST')->getValue(); $this->SM = $this->form->getField('SM')->getValue(); $this->NOS = $this->form->getField('NOS')->getValue(); $this->DeltaX = $this->form->getField('DeltaX')->getValue(); $this->DeltaY = $this->form->getField('DeltaY')->getValue(); $this->Variant = $this->form->getField('Variant')->getValue(); $this->Name = $this->form->getField('Name')->getValue(); $this->siteId = $this->form->getField('SiteId')->getValue(); if (empty($this->Name)) { $this->Name = "Pads"; } if (empty($this->Variant)) { throw new Exception("No Trajectory Variant"); } $wellDAO = new WellDAO(); $well3dpointDAO = new Well3DPointDAO(); $well = $wellDAO->getRecordTemplate(); $well['A'] = $this->A; $well['H'] = $this->H; $well['L1'] = $this->L1; $well['DLS'] = $this->DLS; $well['DLS2'] = $this->DLS2; $well['alfa2'] = $this->alfa2; $well['L3'] = $this->L3; $well['wellName'] = $this->Name . " W0"; $well['siteId'] = $this->siteId; $well['wellType'] = '2d'; $well['wellTrajectory'] = "J2"; $well['wellTrajectoryVariant'] = $this->Variant; $wellDAO->save($well); $this->trajectory = new TrajectoryVariant(); $algoritm = new TrajectoryAlgoritm(); $trajectoryMethod = $this->Variant; $methodParameters = array(); $parameters = explode("_", $this->Variant); array_shift($parameters); foreach ($parameters as $parameter) { $methodParameters[$parameter] = $well[$parameter]; } $this->trajectoryParams = call_user_func_array(array($this->trajectory, $trajectoryMethod), $methodParameters); if (!empty($this->trajectoryParams['error'])) { //$this->errorMessageContainer = new CoreFormValidationMessageContainer(); //$this->errorMessageContainer->addMessage('parametrError'); return 0; //!!!!! } //print_r($this->trajectoryParams); $sectionNumber = 3; $step = 10; $azimut = 0; $this->trajectoryTable = $algoritm->calculateCoordinates($sectionNumber, $this->trajectoryParams['A'], $this->trajectoryParams['H'], $this->trajectoryParams['L'], $this->trajectoryParams['alfa'], $this->trajectoryParams['delta'], $this->trajectoryParams['DLS'], $this->trajectoryParams['R'], $azimut, $step); //print_r($this->trajectoryTable); $firstElements = array_values($this->trajectoryTable); $firstElement = $firstElements[0]; $trayectoryTableLenght = count($this->trajectoryTable); $section = $firstElement['section']; $hpoints[] = $firstElement; $counter = 1; foreach ($this->trajectoryTable as $point) { if ($point['section'] == 'PP' || $section != $point['section'] && $section != 'PP' || $counter == $trayectoryTableLenght) { $section = $point['section']; $hpoints[] = $point; } $counter++; } //print_r($hpoints); if ($this->TR == 'true') { // In loop create // 1. well 3d with R3Konc // 2. calulate points W, HP, TP // 3. save well & points if ($this->NOS > 0) { for ($i = 1; $i <= $this->NOS; $i++) { $padWell = $wellDAO->getRecordTemplate(); $padWell['wellName'] = $this->Name . "_W" . $i . "R"; $padWell['wellType'] = '3d'; $padWell['well3DTrajectory'] = "KONC"; $padWell['siteId'] = $this->siteId; $wellDAO->save($padWell); $srSum = $i * $this->SR; $stSum = $i * $this->ST; $BOPX = $firstElement['X'] + $srSum * cos($this->Azimuth * Pi() / 180) + $this->DeltaX; $BOPY = $firstElement['Y'] - $srSum * sin($this->Azimuth * Pi() / 180) + $this->DeltaY; $HPX = $hpoints[2]['X'] + $stSum * cos($this->Azimuth * Pi() / 180) + $this->DeltaX; $HPY = $hpoints[2]['Y'] - $srSum * sin($this->Azimuth * Pi() / 180) + $this->DeltaY; $TPX = $hpoints[3]['X'] + $stSum * cos($this->Azimuth * Pi() / 180) + $this->DeltaX; $TPY = $hpoints[3]['Y'] - $srSum * sin($this->Azimuth * Pi() / 180) + $this->DeltaY; $well3dpoint = $well3dpointDAO->getRecordTemplate(); $well3dpoint['wellId'] = $padWell['id']; $well3dpoint['number'] = 1; $well3dpoint['X'] = $BOPX; $well3dpoint['Y'] = $BOPY; $well3dpoint['Z'] = 0; $well3dpoint['alfa'] = 0; $well3dpoint['beta'] = 0; $well3dpoint['LP'] = 0; $well3dpointDAO->save($well3dpoint); $well3dpoint = $well3dpointDAO->getRecordTemplate(); $well3dpoint['wellId'] = $padWell['id']; $well3dpoint['number'] = 2; $well3dpoint['X'] = $HPX; $well3dpoint['Y'] = $HPY; $well3dpoint['Z'] = $hpoints[2]['Z']; $well3dpoint['alfa'] = 0; $well3dpoint['beta'] = 0; $well3dpoint['LP'] = 0; $well3dpointDAO->save($well3dpoint); $well3dpoint = $well3dpointDAO->getRecordTemplate(); $well3dpoint['wellId'] = $padWell['id']; $well3dpoint['number'] = 3; $well3dpoint['X'] = $TPX; $well3dpoint['Y'] = $TPY; $well3dpoint['Z'] = $hpoints[3]['Z']; $well3dpoint['alfa'] = $this->targetInclination; $well3dpoint['beta'] = $this->targetAzimuth; $well3dpoint['LP'] = 0; $well3dpointDAO->save($well3dpoint); } } } if ($this->TL == 'true') { if ($this->NOS > 0) { for ($i = 1; $i <= $this->NOS; $i++) { $padWell = $wellDAO->getRecordTemplate(); $padWell['wellName'] = $this->Name . "_W" . $i . "L"; $padWell['wellType'] = '3d'; $padWell['well3DTrajectory'] = "KONC"; $padWell['siteId'] = $this->siteId; $wellDAO->save($padWell); $srSum = $i * $this->SR; $stSum = $i * $this->ST; $BOPX = $firstElement['X'] - $srSum * cos($this->Azimuth * Pi() / 180) + $this->DeltaX; $BOPY = $firstElement['Y'] + $srSum * sin($this->Azimuth * Pi() / 180) + $this->DeltaY; $HPX = $hpoints[2]['X'] - $stSum * cos($this->Azimuth * Pi() / 180) + $this->DeltaX; $HPY = $hpoints[2]['Y'] + $srSum * sin($this->Azimuth * Pi() / 180) + $this->DeltaY; $TPX = $hpoints[3]['X'] - $stSum * cos($this->Azimuth * Pi() / 180) + $this->DeltaX; $TPY = $hpoints[3]['Y'] + $srSum * sin($this->Azimuth * Pi() / 180) + $this->DeltaY; $well3dpoint = $well3dpointDAO->getRecordTemplate(); $well3dpoint['wellId'] = $padWell['id']; $well3dpoint['number'] = 1; $well3dpoint['X'] = $BOPX; $well3dpoint['Y'] = $BOPY; $well3dpoint['Z'] = 0; $well3dpoint['alfa'] = 0; $well3dpoint['beta'] = 0; $well3dpoint['LP'] = 0; $well3dpointDAO->save($well3dpoint); $well3dpoint = $well3dpointDAO->getRecordTemplate(); $well3dpoint['wellId'] = $padWell['id']; $well3dpoint['number'] = 2; $well3dpoint['X'] = $HPX; $well3dpoint['Y'] = $HPY; $well3dpoint['Z'] = $hpoints[2]['Z']; $well3dpoint['alfa'] = 0; $well3dpoint['beta'] = 0; $well3dpoint['LP'] = 0; $well3dpointDAO->save($well3dpoint); $well3dpoint = $well3dpointDAO->getRecordTemplate(); $well3dpoint['wellId'] = $padWell['id']; $well3dpoint['number'] = 3; $well3dpoint['X'] = $TPX; $well3dpoint['Y'] = $TPY; $well3dpoint['Z'] = $hpoints[3]['Z']; $well3dpoint['alfa'] = $this->targetInclination; $well3dpoint['beta'] = $this->targetAzimuth; $well3dpoint['LP'] = 0; $well3dpointDAO->save($well3dpoint); } } } if ($this->BR == 'true') { if ($this->NOS > 0) { for ($i = 1; $i <= $this->NOS; $i++) { $this->Azimuth = $this->Azimuth + 180; $padWell = $wellDAO->getRecordTemplate(); $padWell['wellName'] = $this->Name . "_W" . $i . "MR"; $padWell['wellType'] = '3d'; $padWell['well3DTrajectory'] = "KONC"; $padWell['siteId'] = $this->siteId; $wellDAO->save($padWell); $srSum = $i * $this->SR; $stSum = $i * $this->ST; $DeltaX = $this->DeltaX + $this->SM * sin($this->Azimuth * pi() / 180); $DeltaY = $this->DeltaY + $this->SM * sin($this->Azimuth * pi() / 180); $BOPX = $firstElement['X'] + $srSum * cos($this->Azimuth * Pi() / 180) + $DeltaX; $BOPY = $firstElement['Y'] - $srSum * sin($this->Azimuth * Pi() / 180) + $DeltaY; $HPX = $hpoints[2]['X'] + $stSum * cos($this->Azimuth * Pi() / 180) + $DeltaX; $HPY = $hpoints[2]['Y'] - $srSum * sin($this->Azimuth * Pi() / 180) + $DeltaY; $TPX = $hpoints[3]['X'] + $stSum * cos($this->Azimuth * Pi() / 180) + $DeltaX; $TPY = $hpoints[3]['Y'] - $srSum * sin($this->Azimuth * Pi() / 180) + $DeltaY; $well3dpoint = $well3dpointDAO->getRecordTemplate(); $well3dpoint['wellId'] = $padWell['id']; $well3dpoint['number'] = 1; $well3dpoint['X'] = $BOPX; $well3dpoint['Y'] = $BOPY; $well3dpoint['Z'] = 0; $well3dpoint['alfa'] = 0; $well3dpoint['beta'] = 0; $well3dpoint['LP'] = 0; $well3dpointDAO->save($well3dpoint); $well3dpoint = $well3dpointDAO->getRecordTemplate(); $well3dpoint['wellId'] = $padWell['id']; $well3dpoint['number'] = 2; $well3dpoint['X'] = $HPX; $well3dpoint['Y'] = $HPY; $well3dpoint['Z'] = $hpoints[2]['Z']; $well3dpoint['alfa'] = 0; $well3dpoint['beta'] = 0; $well3dpoint['LP'] = 0; $well3dpointDAO->save($well3dpoint); $well3dpoint = $well3dpointDAO->getRecordTemplate(); $well3dpoint['wellId'] = $padWell['id']; $well3dpoint['number'] = 3; $well3dpoint['X'] = $TPX; $well3dpoint['Y'] = $TPY; $well3dpoint['Z'] = $hpoints[3]['Z']; $well3dpoint['alfa'] = $this->targetInclination; $well3dpoint['beta'] = $this->targetAzimuth; $well3dpoint['LP'] = 0; $well3dpointDAO->save($well3dpoint); } } } if ($this->BL == 'true') { if ($this->NOS > 0) { for ($i = 1; $i <= $this->NOS; $i++) { $this->Azimuth = $this->Azimuth + 180; $padWell = $wellDAO->getRecordTemplate(); $padWell['wellName'] = $this->Name . "_W" . $i . "ML"; $padWell['wellType'] = '3d'; $padWell['well3DTrajectory'] = "KONC"; $padWell['siteId'] = $this->siteId; $wellDAO->save($padWell); $srSum = $i * $this->SR; $stSum = $i * $this->ST; $DeltaX = $this->DeltaX + $this->SM * sin($this->Azimuth * pi() / 180); $DeltaY = $this->DeltaY + $this->SM * sin($this->Azimuth * pi() / 180); $BOPX = $firstElement['X'] - $srSum * cos($this->Azimuth * Pi() / 180) + $DeltaX; $BOPY = $firstElement['Y'] + $srSum * sin($this->Azimuth * Pi() / 180) + $DeltaY; $HPX = $hpoints[2]['X'] - $stSum * cos($this->Azimuth * Pi() / 180) + $DeltaX; $HPY = $hpoints[2]['Y'] + $srSum * sin($this->Azimuth * Pi() / 180) + $DeltaY; $TPX = $hpoints[3]['X'] - $stSum * cos($this->Azimuth * Pi() / 180) + $DeltaX; $TPY = $hpoints[3]['Y'] + $srSum * sin($this->Azimuth * Pi() / 180) + $DeltaY; $well3dpoint = $well3dpointDAO->getRecordTemplate(); $well3dpoint['wellId'] = $padWell['id']; $well3dpoint['number'] = 1; $well3dpoint['X'] = $BOPX; $well3dpoint['Y'] = $BOPY; $well3dpoint['Z'] = 0; $well3dpoint['alfa'] = 0; $well3dpoint['beta'] = 0; $well3dpoint['LP'] = 0; $well3dpointDAO->save($well3dpoint); $well3dpoint = $well3dpointDAO->getRecordTemplate(); $well3dpoint['wellId'] = $padWell['id']; $well3dpoint['number'] = 2; $well3dpoint['X'] = $HPX; $well3dpoint['Y'] = $HPY; $well3dpoint['Z'] = $hpoints[2]['Z']; $well3dpoint['alfa'] = 0; $well3dpoint['beta'] = 0; $well3dpoint['LP'] = 0; $well3dpointDAO->save($well3dpoint); $well3dpoint = $well3dpointDAO->getRecordTemplate(); $well3dpoint['wellId'] = $padWell['id']; $well3dpoint['number'] = 3; $well3dpoint['X'] = $TPX; $well3dpoint['Y'] = $TPY; $well3dpoint['Z'] = $hpoints[3]['Z']; $well3dpoint['alfa'] = $this->targetInclination; $well3dpoint['beta'] = $this->targetAzimuth; $well3dpoint['LP'] = 0; $well3dpointDAO->save($well3dpoint); } } } // +add slot to DB // +calculate trajectory // +get points 0, HP, TP // calculate additional trajectories points // create }
function printPie($graph) { $series_names = array_keys($graph->series); $column_names = array_keys($graph->series[$series_names[0]]); $num = count($column_names); $values = $graph->series[$series_names[0]]; $sum = array_sum($values); $image = Graph::create_canvas($graph); $color_legend = imagecolorallocate($image, $graph->text_color[r], $graph->text_color[g], $graph->text_color[b]); $angle1 = 0; $x_center = 150; $y_center = 150; $x_radius = 150; $y_radius = 150; //draw pie for ($i = 0; $i < $num; $i++) { $r = hexdec(substr($graph->plot_colors[$i], 1, 2)); $g = hexdec(substr($graph->plot_colors[$i], 3, 2)); $b = hexdec(substr($graph->plot_colors[$i], 5, 2)); $color[$i] = imagecolorallocate($image, $r, $g, $b); $value = $graph->series[$series_names[0]][$column_names[$i]] / $sum; $angle2 = $angle1 + 340 * $value; imagefilledarc($image, $x_center, $y_center, $x_radius, $y_radius, $angle1, $angle2, $color[$i], 4); $x_values_pos[$i] = $x_center + 0.7 * $x_radius * cos(Pi() * (($angle1 + $angle2) / 360)) - 20; $y_values_pos[$i] = $y_center + 0.7 * $y_radius * sin(Pi() * (($angle1 + $angle2) / 360)) - 5; imagestring($image, 2, $x_values_pos[$i], $y_values_pos[$i], round(100 * $value, 2) . '%', $color_legend); $angle1 = $angle2 + 20 / $num; //print legend imagefilledrectangle($image, LEGEND_MARGIN_LEFT - 80, GRAPH_MARGIN_TOP + $i * (GRAPH_HEIGHT / 12), LEGEND_MARGIN_LEFT - 75, GRAPH_MARGIN_TOP + $i * (GRAPH_HEIGHT / 12) + 4, $color[$i]); imagestring($image, 2, LEGEND_MARGIN_LEFT - 60, GRAPH_MARGIN_TOP + ($i * (GRAPH_HEIGHT / 12) - 5), $column_names[$i], $color_legend); } $color_canvas = imagecolorallocate($image, $graph->canvas_color[r], $graph->canvas_color[g], $graph->canvas_color[b]); imagefilledarc($image, 150, 150, 50, 50, 0, 360, $color_canvas, 4); //set content type header("Content-type: image/jpeg"); //send image Imagejpeg($image, '', 100); ImageDestroy($image); }