# File: Qiblah.php

 Recommend this page to a friend!
 Classes of Dr Ahmed Elsheshtawy Qiblah Direction Calculator Qiblah.php Download
File: Qiblah.php Example script text/plain Qibla Graphic Direction Test Qiblah Direction Calculator Determine the Qiblah direction By Dr Ahmed Elsheshtawy 14 years ago 5,450 bytes

## Contents

 ``` . // ----------------------------------------------------------------------         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) . "
\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
"; ?> ```
 About us Advertise on this site Site map Newsletter Statistics Site tips Privacy policy Contact
For more information send a message to `info at phpclasses dot org`.