<?php
// ----------------------------------------------------------------------
//Copyrights © 2009 Mewsoft Corp. All rights reserved.
//Program Author : Dr. Ahmed Amin Elsheshtawy, Ph.D
//Home Page : http://www.islamware.com, http://www.mewsoft.com
//Contact Email : support@mewsoft.com
//Products : Auction, Classifieds, Directory, PPC, Forums, Snapshotter
// ----------------------------------------------------------------------
// LICENSE
// This program is open source product; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public License (LGPL)
// as published by the Free Software Foundation; either version 3
// of the License, or (at your option) any later version.
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Lesser General Public License for more details.
// You should have received a copy of the GNU Lesser General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
// ----------------------------------------------------------------------
require_once(dirname(__FILE__)."/Qiblah.class.php");
//-------------------------------------------------------------------------------------------------------
// http://localhost/php/Qiblah-Class/QiblahDirection.php?latitude=10&longitude=20
if (isset($_REQUEST['latitude']) && isset($_REQUEST['longitude'])) {
$origin_latitude = floatval ($_REQUEST['latitude']);
$origin_longitude = floatval ($_REQUEST['longitude']);
}
else {
// default for Cairo, Egypt
$origin_latitude = 30.1;
$origin_longitude = 31.3;
}
$qiblah = new Qiblah();
$qiblah_angle = $qiblah->getDirection($origin_latitude, $origin_longitude);
//$qiblah_angle = 300;
//echo "GCDistance: " . $qiblah->GreatCircleDistance(30.1, 31.3, 21, 40) . " <br />\n";
//-------------------------------------------------------------------------------------------------------
//-------------------------------------------------------------------------------------------------------
function draw_radius($im, $x, $y, $radius, $angle, $color)
{
$x1 = $x + $radius * cos(deg2rad($angle-90));
$y1 = $y + $radius * sin(deg2rad($angle-90));
imageline($im, $x, $y, $x1, $y1, $color);
arrow($im, $x, $y, $x1, $y1, 10, 3, $color);
}
function arrow($img, $x1, $y1, $x2, $y2, $arrow_length, $arrow_width, $color)
{
$distance = sqrt(pow($x1 - $x2, 2) + pow($y1 - $y2, 2));
$dx = $x2 + ($x1 - $x2) * $arrow_length / $distance;
$dy = $y2 + ($y1 - $y2) * $arrow_length / $distance;
$k = $arrow_width / $arrow_length;
$x2o = $x2 - $dx;
$y2o = $dy - $y2;
$x3 = $y2o * $k + $dx;
$y3 = $x2o * $k + $dy;
$x4 = $dx - $y2o * $k;
$y4 = $dy - $x2o * $k;
imageline($img, $x1, $y1, $dx, $dy, $color);
imageline($img, $x3, $y3, $x4, $y4, $color);
imageline($img, $x3, $y3, $x2, $y2, $color);
imageline($img, $x2, $y2, $x4, $y4, $color);
}
//-------------------------------------------------------------------------------------------------------
//-------------------------------------------------------------------------------------------------------
/**
add compass background image
*/
$image_compass = imagecreatefromgif('qiblahcompass.gif');
imageantialias($im, true);
$centrx = imagesx($image_compass)/2;
$centry = imagesy($image_compass)/2;
$radius_percentage = 0.65;
$radius = imagesx($image_compass)/2 * $radius_percentage;
imagesetthickness($image_compass, 3);
//$pointer_color = ImageColorAllocate($im, 255, hexdec("CC"), 00);
//$pointer_color = ImageColorAllocate($im, 155, 240, 100);
//$pointer_color = ImageColorAllocate($im, 255, 0, 0);
$pointer_color = ImageColorAllocate($image_compass, 0, 255, 0);
//-------------------------------------------------------------------------------------------------------
/**
draw the line and arraw from the origin source location to Kaba location
*/
draw_radius($image_compass, $centrx, $centry, $radius, $qiblah_angle, $pointer_color);
//-------------------------------------------------------------------------------------------------------
/**
Merge the Kaba image with the compass image at the kaba location
*/
$image_kaba = imagecreatefromjpeg('kaba.jpg');
$radius_kaba_percentage = .85;
$radius_kaba = imagesx($image_compass)/2 * $radius_kaba_percentage;
$x1 = $centrx + $radius_kaba * cos(deg2rad($qiblah_angle-90));
$y1 = $centry + $radius_kaba * sin(deg2rad($qiblah_angle-90));
imagecopymerge($image_compass,
$image_kaba, $x1-imagesx($image_kaba)/2, $y1-imagesy($image_kaba)/2,
0, 0,
imagesx($image_kaba), imagesy($image_kaba),
75
);
//-------------------------------------------------------------------------------------------------------
// Output the HTTP header Content-type
//Header('Content-type: image/gif');
// Send GIF output to client browser
ImageGif($image_compass);
ImageDestroy($image_compass);
//-------------------------------------------------------------------------------------------------------
//-------------------------------------------------------------------------------------------------------
//print "$qiblah_angle \n<br>";
?>
|