• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP pi函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了PHP中pi函数的典型用法代码示例。如果您正苦于以下问题:PHP pi函数的具体用法?PHP pi怎么用?PHP pi使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了pi函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。

示例1: __construct

 function __construct($NAME = NULL, $DESCRIPTION = NULL, $LONG = NULL, $LAT = NULL, $ALT = NULL, $HEAD = NULL, $TILT = NULL, $RANGE = NULL)
 {
     $this->NAME = is_null($NAME) ? "Building and Wall" : $NAME;
     $this->DESCRIPTION = is_null($DESCRIPTION) ? "Building and Wall share textures" : $DESCRIPTION;
     $this->LONG = is_null($LONG) ? "-79.37380981445312" : $LONG;
     $this->LAT = is_null($LAT) ? "43.656211853027344" : $LAT;
     $this->ALT = is_null($ALT) ? "311" : $ALT;
     $this->HEAD = is_null($HEAD) ? "-40.34248730008207" : $HEAD;
     $this->TILT = is_null($TILT) ? "34.9531454664821" : $TILT;
     $this->RANGE = is_null($RANGE) ? "50.90180128676323" : $RANGE;
     $this->RADIAN = 180 / pi();
     //create the xml document
     $this->xmlDoc = new DOMDocument('1.0', 'UTF-8');
     $kml = $this->xmlDoc->appendChild($this->xmlDoc->createElementNS('http://www.opengis.net/kml/2.2', 'kml'));
     //create the root element
     $this->folTag = $kml->appendChild($this->xmlDoc->createElement("Folder"));
     $this->folTag->appendChild($this->xmlDoc->createElement("name", $this->NAME));
     $this->folTag->appendChild($this->xmlDoc->createElement("description", $this->DESCRIPTION));
     $lokTag = $this->folTag->appendChild($this->xmlDoc->createElement("Camera"));
     $lokTag->appendChild($this->xmlDoc->createElement("longitude", $this->LONG));
     $lokTag->appendChild($this->xmlDoc->createElement("latitude", $this->LAT));
     $lokTag->appendChild($this->xmlDoc->createElement("altitude", $this->ALT));
     $lokTag->appendChild($this->xmlDoc->createElement("heading", $this->HEAD));
     $lokTag->appendChild($this->xmlDoc->createElement("tilt", $this->TILT));
     $lokTag->appendChild($this->xmlDoc->createElement("range", $this->RANGE));
 }
开发者ID:Nemeziz,项目名称:googletwitter,代码行数:26,代码来源:setDomeKML.php


示例2: toLatLng

 /**
  * Convert this UTM reference to a latitude and longitude
  *
  * @return the converted latitude and longitude
  */
 function toLatLng()
 {
     $wgs84 = new ReferenceEllipsoid(ReferenceEllipsoid::WGS84_MAJ, ReferenceEllipsoid::WGS84_MIN);
     $UTM_F0 = 0.9996;
     $a = $wgs84->maj;
     $eSquared = $wgs84->ecc;
     $ePrimeSquared = $eSquared / (1.0 - $eSquared);
     $e1 = (1 - sqrt(1 - $eSquared)) / (1 + sqrt(1 - $eSquared));
     $x = $this->easting - 500000.0;
     $y = $this->northing;
     $zoneNumber = $this->lngZone;
     $zoneLetter = $this->latZone;
     $longitudeOrigin = ($zoneNumber - 1.0) * 6.0 - 180.0 + 3.0;
     // Correct y for southern hemisphere
     if (ord($zoneLetter) - ord("N") < 0) {
         $y -= 10000000.0;
     }
     $m = $y / $UTM_F0;
     $mu = $m / ($a * (1.0 - $eSquared / 4.0 - 3.0 * $eSquared * $eSquared / 64.0 - 5.0 * pow($eSquared, 3.0) / 256.0));
     $phi1Rad = $mu + (3.0 * $e1 / 2.0 - 27.0 * pow($e1, 3.0) / 32.0) * sin(2.0 * $mu) + (21.0 * $e1 * $e1 / 16.0 - 55.0 * pow($e1, 4.0) / 32.0) * sin(4.0 * $mu) + 151.0 * pow($e1, 3.0) / 96.0 * sin(6.0 * $mu);
     $n = $a / sqrt(1.0 - $eSquared * sin($phi1Rad) * sin($phi1Rad));
     $t = tan($phi1Rad) * tan($phi1Rad);
     $c = $ePrimeSquared * cos($phi1Rad) * cos($phi1Rad);
     $r = $a * (1.0 - $eSquared) / pow(1.0 - $eSquared * sin($phi1Rad) * sin($phi1Rad), 1.5);
     $d = $x / ($n * $UTM_F0);
     $latitude = ($phi1Rad - $n * tan($phi1Rad) / $r * ($d * $d / 2.0 - (5.0 + 3.0 * $t + 10.0 * $c - 4.0 * $c * $c - 9.0 * $ePrimeSquared) * pow($d, 4.0) / 24.0 + (61.0 + 90.0 * $t + 298.0 * $c + 45.0 * $t * $t - 252.0 * $ePrimeSquared - 3.0 * $c * $c) * pow($d, 6.0) / 720.0)) * (180.0 / pi());
     $longitude = $longitudeOrigin + ($d - (1.0 + 2.0 * $t + $c) * pow($d, 3.0) / 6.0 + (5.0 - 2.0 * $c + 28.0 * $t - 3.0 * $c * $c + 8.0 * $ePrimeSquared + 24.0 * $t * $t) * pow($d, 5.0) / 120.0) / cos($phi1Rad) * (180.0 / pi());
     return new LatLng($latitude, $longitude);
 }
开发者ID:nevstokes,项目名称:coords,代码行数:34,代码来源:UTMRef.php


示例3: metersToLatLon

 static function metersToLatLon($mx, $my)
 {
     $lng = $mx / self::originShift() * 180.0;
     $lat = $my / self::originShift() * 180.0;
     $lat = 180 / pi() * (2 * atan(exp($lat * pi() / 180.0)) - pi() / 2.0);
     return new GoogleMapPoint($lat, $lng);
 }
开发者ID:markguinn,项目名称:silverstripe-gis,代码行数:7,代码来源:GoogleMapUtility.php


示例4: TrueSolarTime

function TrueSolarTime($Hours, $ET, $SITE, $TIME)
{
    //Calculations
    if ($TIME['LocalTime'] == 1) {
        //True solar time, radian
        for ($i = 0; $i < $TIME['Ndays']; $i++) {
            for ($j = 0; $j < $TIME['Nsteps']; $j++) {
                $w[$i][$j] = ($Hours[$i][$j] - 12) * 15 * pi() / 180;
            }
        }
    } elseif ($TIME['LocalTime'] == 2) {
        //Daily loop
        for ($d = 0; $d < $TIME['Ndays']; $d++) {
            //Daylight Saving Time, DST
            if ($d < $TIME['DOCS'] || $d >= $TIME['DOCW']) {
                $DST[$d] = $TIME['DSTW'][$d];
            } else {
                $DST[$d] = $TIME['DSTS'][$d];
            }
            //Hourly loop
            for ($h = 0; $h < $TIME['Nsteps']; $h++) {
                //True solar time, radian
                $w[$d][$h] = ($Hours[$d][$h] - (12 + $DST[$d][$h])) * 15 * pi / 180 + ($SITE['Longitude'] - $SITE['StandardLongitude']) * pi / 180 + $ET[$d];
            }
        }
        //end foreach
    }
    //end elseif
    return $w;
}
开发者ID:rubennj,项目名称:SISIFO,代码行数:30,代码来源:TrueSolarTime.php


示例5: timeout

function timeout()
{
    global $da, $background, $back_width, $back_height, $frame, $images, $frame_num;
    $background->copy_area(0, 0, $back_width, $back_height, $frame, 0, 0);
    $f = $frame_num % CYCLE_LEN / CYCLE_LEN;
    $xmid = $back_width / 2.0;
    $ymid = $back_height / 2.0;
    $radius = min($xmid, $ymid) / 2.0;
    for ($i = 0; $i < N_IMAGES; $i++) {
        $ang = 2.0 * pi() * $i / N_IMAGES - $f * 2.0 * pi();
        $iw = $images[$i]->get_width();
        $ih = $images[$i]->get_height();
        $r = $radius + $radius / 3.0 * sin($f * 2.0 * pi());
        $xpos = floor($xmid + $r * cos($ang) - $iw / 2.0 + 0.5);
        $ypos = floor($ymid + $r * sin($ang) - $ih / 2.0 + 0.5);
        $k = $i & 1 ? sin($f * 2.0 * pi()) : cos($f * 2.0 * pi());
        $k = 2.0 * $k * $k;
        $k = max(0.25, $k);
        $r1 = new GdkRectangle($xpos, $ypos, $iw * $k, $ih * $k);
        $r2 = new GdkRectangle(0, 0, $back_width, $back_height);
        $dest = $r1->intersect($r2);
        $images[$i]->composite($frame, $dest->x, $dest->y, $dest->width, $dest->height, $xpos, $ypos, $k, $k, Gdk::INTERP_NEAREST, $i & 1 ? max(127, abs(255 * sin($f * 2.0 * pi()))) : max(127, abs(255 * cos($f * 2.0 * pi()))));
    }
    $da->queue_draw();
    $frame_num++;
    return true;
}
开发者ID:rakotomandimby,项目名称:php-gtk-src,代码行数:27,代码来源:bug_pixbuf-demo.php


示例6: approximate

 public function approximate()
 {
     $correlation = $this->getCorrelation();
     $step = $this->getStep();
     $this->_tau = 0;
     for ($i = 0; $i < count($correlation); $i++) {
         if ($correlation[$i] < 0) {
             $p1 = new Model_Coordinate($step * ($i - 1), $correlation[$i - 1]);
             $p2 = new Model_Coordinate($step * $i, $correlation[$i]);
             $k = ($p2->getY() - $p1->getY()) / ($p2->getX() - $p1->getX());
             $b = $p2->getY() - $k * $p2->getX();
             $this->_tau = -$b / $k;
             break;
         }
     }
     $this->_beta = pi() / (2 * $this->_tau);
     $s1 = 0;
     $s2 = 0;
     for ($i = 0; $i * $step < $this->_tau; $i++) {
         $tau = $i * $step;
         $ro_tau = $correlation[$i];
         $s1 += abs($tau * log($ro_tau / cos($this->_beta * $tau)));
         $s2 += $tau * $tau;
     }
     if ($this->_tau < $step) {
         $this->_alpha = 1;
     } else {
         $this->_alpha = $s1 / $s2;
     }
 }
开发者ID:nikita-prikazchikov,项目名称:RoadEstimation,代码行数:30,代码来源:Microprofile.php


示例7: testGetTheVolumeOfSphere

 public function testGetTheVolumeOfSphere()
 {
     $radius = 4;
     $result = 4 / 3 * pi() * sqrt($radius) * $radius;
     $volume_sphere = new Shape() / Sphere($radius);
     $this->assertEquals($result, $volume_sphere);
 }
开发者ID:arnacmj,项目名称:Assignment-Shapes,代码行数:7,代码来源:SphereTest.php


示例8: direction

function direction($u, $v, $good)
{
    $stringNum = array("N" => 0, "NNE" => 2, "NE" => 4, "ENE" => 6, "E" => 8, "ESE" => 10, "SE" => 12, "SSE" => 14, "S" => 16, "SSO" => 18, "SO" => 20, "OSO" => 22, "O" => 24, "ONO" => 26, "NO" => 28, "NNO" => 30);
    $dirString = array(0 => "N", 1 => "NNE", 2 => "NNE", 3 => "NE", 4 => "NE", 5 => "ENE", 6 => "ENE", 7 => "E", 8 => "E", 9 => "ESE", 10 => "ESE", 11 => "SE", 12 => "SE", 13 => "SSE", 14 => "SSE", 15 => "S", 16 => "S", 17 => "SSO", 18 => "SSO", 19 => "SO", 20 => "SO", 21 => "OSO", 22 => "OSO", 23 => "O", 24 => "O", 25 => "ONO", 26 => "ONO", 27 => "NO", 28 => "NO", 29 => "NNO", 30 => "NNO", 31 => "N", 32 => "N");
    $dir = (atan2($u, $v) / pi() + 1) * 180;
    $dirSecteur = round($dir / 11.25);
    $goods = str_getcsv($good);
    //var_dump($goods);
    $col = "white";
    foreach ($goods as $good) {
        //echo $good . '?';
        if ($good != '') {
            $num = $stringNum[$good];
            // echo 'ref='.$num.' et wind='.$dirSecteur . '! ';
            //je n'arrive pas Ó bien formuler l'intervalle sur mes numÚros de secteur
            if ($num + 3 >= $dirSecteur and $num - 3 <= $dirSecteur) {
                $col = "lightgreen";
            }
            if ($num == 0) {
                if ($dirSecteur == 31 or $dirSecteur == 30 or $dirSecteur == 29) {
                    $col = "lightgreen";
                }
            }
            if ($num == 1) {
                if ($dirSecteur == 31) {
                    $col = "lightgreen";
                }
            }
        }
    }
    print "<td bgcolor='" . $col . "'>" . $dirString[$dirSecteur] . "</td>";
}
开发者ID:nbald,项目名称:RASP-User,代码行数:32,代码来源:rasp.php


示例9: getClubs

 public static function getClubs($userLongitude, $userLatitude, $range = 10)
 {
     $searchRange = 180 / pi() * ($range / 6372.797);
     $lngR = abs($searchRange / cos($userLatitude * pi() / 180.0));
     $maxLat = $userLatitude + $searchRange;
     $minLat = $userLatitude - $searchRange;
     $maxLng = $userLongitude + $lngR;
     $minLng = $userLongitude - $lngR;
     $con = DBUtil::connectDB();
     $sql = "SELECT * FROM club where ((latitude BETWEEN {$minLat} AND {$maxLat}) AND (longitude BETWEEN {$minLng} AND {$maxLng}))";
     $result = mysql_query($sql, $con);
     $clubs = [];
     while ($row = mysql_fetch_array($result)) {
         $r = [];
         $r['id'] = $row['id'];
         $r['name'] = $row['name'];
         $r['longitude'] = $row['longitude'];
         $r['latitude'] = $row['latitude'];
         $r['images'] = json_decode($row['images']);
         $r['address'] = $row['address'];
         $r['meta'] = json_decode($row['meta']);
         $clubs[] = $r;
     }
     mysql_close();
     return $clubs;
 }
开发者ID:BurizaDo,项目名称:iPartyCloud,代码行数:26,代码来源:ClubDBUtil.php


示例10: distance

 public static function distance($lat1, $long1, $lat2, $long2)
 {
     //радиус Земли
     $R = 6372795;
     //перевод коордитат в радианы
     $lat1 *= pi() / 180;
     $lat2 *= pi() / 180;
     $long1 *= pi() / 180;
     $long2 *= pi() / 180;
     //вычисление косинусов и синусов широт и разницы долгот
     $cl1 = cos($lat1);
     $cl2 = cos($lat2);
     $sl1 = sin($lat1);
     $sl2 = sin($lat2);
     $delta = $long2 - $long1;
     $cdelta = cos($delta);
     $sdelta = sin($delta);
     //вычисления длины большого круга
     $y = sqrt(pow($cl2 * $sdelta, 2) + pow($cl1 * $sl2 - $sl1 * $cl2 * $cdelta, 2));
     $x = $sl1 * $sl2 + $cl1 * $cl2 * $cdelta;
     $ad = atan2($y, $x);
     $dist = $ad * $R;
     $dist = round($dist);
     return $dist;
 }
开发者ID:neolinks,项目名称:cabinet,代码行数:25,代码来源:Helpers.php


示例11: distanceBetween

	public function distanceBetween(Geopoint $pointA, Geopoint $pointB, $algorithm = 'flat', $unit = null) {

		if (!$unit) $unit = $this->defaultUnit;

		switch ($algorithm) {
			case 'haversine':
				$theta = ($pointA->longitude - $pointB->longitude); 
				$dist = sin(deg2rad($pointA->latitude)) * sin(deg2rad($pointB->latitude)) +  cos(deg2rad($pointA->latitude)) * cos(deg2rad($pointB->latitude)) * cos(deg2rad($theta)); 
				$dist = acos($dist); 
				
				$distance = rad2deg($dist);
			break;
			case 'flat':
			default:	
				$distanceEW = ($pointB->longitude - $pointA->longitude) * cos($pointA->latitude);
				$distanceNS = $pointB->latitude - $pointA->latitude;
				
				$distance = sqrt( ($distanceEW * $distanceEW) + ($distanceNS * $distanceNS));
			break;
		}
		
		$distance *= 2 * pi() * $this->earthRadius[$unit] / 360.0;
		
		return $distance;
		
	}
开发者ID:rjdjohnston,项目名称:Geotools-for-CodeIgniter,代码行数:26,代码来源:geotools.php


示例12: distanceBetween

 public static function distanceBetween(Geopoint $pointA, Geopoint $pointB, $algorithm, $units)
 {
     switch ($algorithm) {
         case 'haversine':
             $theta = $pointA->getLongitude() - $pointB->getLongitude();
             $dist = sin(deg2rad($pointA->getLatitude())) * sin(deg2rad($pointB->getLatitude())) + cos(deg2rad($pointA->getLatitude())) * cos(deg2rad($pointB->getLatitude())) * cos(deg2rad($theta));
             $dist = acos($dist);
             $distance = rad2deg($dist);
             break;
         case 'flat':
         default:
             $distanceEW = ($pointB->getLongitude() - $pointA->getLongitude()) * cos($pointA->getLatitude());
             $distanceNS = $pointB->getLatitude() - $pointA->getLatitude();
             $distance = sqrt($distanceEW * $distanceEW + $distanceNS * $distanceNS);
             break;
     }
     switch ($units) {
         case self::GEO_UNIT_KM:
             $radius = self::EARTH_RADIUS_KM;
             break;
         case self::GEO_UNIT_MILES:
             $radius = self::EARTH_RADIUS_MILES;
             break;
     }
     $distance *= 2 * pi() * $radius / 360.0;
     return $distance;
 }
开发者ID:weejames,项目名称:geotools,代码行数:27,代码来源:Tools.php


示例13: get_condition

 private function get_condition()
 {
     if ($this->input['jd'] || $this->input['wd']) {
         //gps坐标转百度坐标
         $baidu_zuobiao = GpsToBaidu($this->input['jd'], $this->input['wd']);
         $this->input['baidu_longitude'] = $baidu_zuobiao['x'];
         $this->input['baidu_latitude'] = $baidu_zuobiao['y'];
     }
     $distance = $this->input['distance'];
     if ($this->input['baidu_longitude'] && $this->input['baidu_latitude'] && $distance) {
         $baidu_longitude = $this->input['baidu_longitude'];
         $baidu_latitude = $this->input['baidu_latitude'];
         $range = 180 / pi() * $distance / 6372.797;
         //里面的 $distance 就代表搜索 $distance 之内,单位km
         $lngR = $range / cos($baidu_latitude * pi() / 180);
         //echo $range;exit()
         $maxLat = $baidu_latitude + $range;
         //最大纬度
         $minLat = $baidu_latitude - $range;
         //最小纬度
         $maxLng = $baidu_longitude + $lngR;
         //最大经度
         $minLng = $baidu_longitude - $lngR;
         //最小经度
         $condition .= ' AND t1.baidu_longitude >=' . $minLng . ' AND t1.baidu_longitude <=' . $maxLng . ' AND t1.baidu_latitude >=' . $minLat . ' AND t1.baidu_latitude <= ' . $maxLat . ' AND t1.baidu_latitude != "" AND t1.baidu_longitude != ""';
     }
     return $condition;
 }
开发者ID:h3len,项目名称:Project,代码行数:28,代码来源:get_station_all.php


示例14: MetersToLatLon

 public function MetersToLatLon($mx, $my)
 {
     $lon = $mx / $this->originShift * 180.0;
     $lat = $my / $this->originShift * 180.0;
     $lat = 180 / pi() * (2 * atan(exp($lat * pi() / 180.0)) - pi() / 2.0);
     return array($lat, $lon);
 }
开发者ID:netconstructor,项目名称:cartodb-staticmap-php,代码行数:7,代码来源:class.cartodb-staticmap.php


示例15: explodeTestData

 protected function explodeTestData($locale, $currencyCode)
 {
     // valid values for all currencies
     $validDomainValues = [(double) -10, (double) 0, (double) 10];
     // invalid values for all currencies
     $invalidDomainValues = [-1, 0, 1, null, false, true, "", "123", "foo", [], ['foo' => 'bar'], new \stdClass(), NAN, INF, -INF];
     $tmpValid = $validDomainValues;
     $tmpInvalid = $invalidDomainValues;
     // Build fraction digits test data
     $formatter = new \NumberFormatter($locale, \NumberFormatter::CURRENCY);
     $formatter->setTextAttribute($formatter::CURRENCY_CODE, $currencyCode);
     $fractionDigits = $formatter->getAttribute(\NumberFormatter::FRACTION_DIGITS);
     $tmpValid[] = (double) (1 + pow(10, -$fractionDigits));
     $tmpInvalid[] = (double) (1 + pow(10, -($fractionDigits + 1)));
     $pi = pi();
     $tmpValid[] = round($pi, $fractionDigits);
     if ($fractionDigits > 2) {
         $tmpValid[] = round($pi, $fractionDigits - 1);
         $tmpValid[] = (double) (1 + pow(10, -($fractionDigits - 1)));
     }
     $tmpInvalid[] = round($pi, $fractionDigits + 1);
     $return = [];
     foreach ($tmpValid as $value) {
         $return[] = [$value, true];
     }
     foreach ($tmpInvalid as $value) {
         $return[] = [$value, false];
     }
     return $return;
 }
开发者ID:leodido,项目名称:moneylaundry,代码行数:30,代码来源:DomainTest.php


示例16: get_bearing

 /**
  * Get bearing from position to another
  *
  * Code from http://www.corecoding.com/getfile.php?file=25
  */
 function get_bearing($from, $to)
 {
     if (round($from['longitude'], 1) == round($to['longitude'], 1)) {
         if ($from['latitude'] < $to['latitude']) {
             $bearing = 0;
         } else {
             $bearing = 180;
         }
     } else {
         $dist = org_routamc_positioning_utils::get_distance($from, $to, 'N');
         $arad = acos((sin(deg2rad($to['latitude'])) - sin(deg2rad($from['latitude'])) * cos(deg2rad($dist / 60))) / (sin(deg2rad($dist / 60)) * cos(deg2rad($from['latitude']))));
         $bearing = $arad * 180 / pi();
         if (sin(deg2rad($to['longitude'] - $from['longitude'])) < 0) {
             $bearing = 360 - $bearing;
         }
     }
     $dirs = array("N", "E", "S", "W");
     $rounded = round($bearing / 22.5) % 16;
     if ($rounded % 4 == 0) {
         $dir = $dirs[$rounded / 4];
     } else {
         $dir = $dirs[2 * floor((floor($rounded / 4) + 1) % 4 / 2)];
         $dir .= $dirs[1 + 2 * floor($rounded / 8)];
     }
     return $dir;
 }
开发者ID:nemein,项目名称:openpsa,代码行数:31,代码来源:utils.php


示例17: drawRhythm

	function drawRhythm($daysAlive, $period, $color)
	{
	    global $daysToShow, $image, $diagramWidth, $diagramHeight;

	    // get day on which to center
	    $centerDay = $daysAlive - ($daysToShow / 2);

	    // calculate diagram parameters
	    $plotScale = ($diagramHeight - 25) / 2;
	    $plotCenter = ($diagramHeight - 25) / 2;

	    // draw the curve
	    for($x = 0; $x <= $daysToShow; $x++)
	    {
		// calculate phase of curve at this day, then Y value
		// within diagram
		$phase = (($centerDay + $x) % $period) / $period * 2 * pi();
		$y = 1 - sin($phase) * (float)$plotScale + (float)$plotCenter;

		// draw line from last point to current point
		if($x > 0)
		    imageLine($image, $oldX, $oldY,
			      $x * $diagramWidth / $daysToShow, $y, $color);

		// save current X/Y coordinates as start point for next line
		$oldX = $x * $diagramWidth / $daysToShow;
		$oldY = $y;
	    }

	}
开发者ID:esyacelga,项目名称:sisadmaca,代码行数:30,代码来源:biorhythm.php


示例18: returnGeo

 function returnGeo($lat, $lng, $radius, $tableName, $limit = 10)
 {
     $r = $radius / 3956;
     $latRadians = $lat * pi() / 180;
     $maxLat = 180 * ($latRadians + $r) / pi();
     $minLat = 180 * ($latRadians - $r) / pi();
     $lonRadians = $lng * pi() / 180;
     $deltaLon = asin(sin($r) / cos($latRadians));
     //return $deltaLon;
     $maxLon = 180 * (($lonRadians + $deltaLon) / pi());
     $minLon = 180 * (($lonRadians - $deltaLon) / pi());
     // return array($lat,$lng,$radius,$tableName,$limit);
     if ($tableName == 'cities') {
         $query = "SELECT *, 3956 * 2 * ASIN(SQRT(POWER(SIN(abs(" . $lat . " - latitude) * pi()/180 /2),2)+ " . "(COS(" . $lat . "* pi()/180) * COS(abs(latitude) * pi()/180) * " . "POWER(SIN(abs(" . $lng . " - longitude) * pi()/180 / 2),2)) )) " . " as Distance FROM " . $tableName . " WHERE latitude < " . $maxLat . " AND latitude > " . $minLat . " AND longitude < " . $maxLon . " AND longitude > " . $minLon . " having Distance < " . $radius . " ORDER BY population DESC, Distance ASC LIMIT " . $limit . ";";
     } else {
         $query = "SELECT *, 3956 * 2 * ASIN(SQRT(POWER(SIN(abs(" . $lat . " - latitude) * pi()/180 /2),2)+ " . "(COS(" . $lat . "* pi()/180) * COS(abs(latitude) * pi()/180) * " . "POWER(SIN(abs(" . $lng . " - longitude) * pi()/180 / 2),2)) )) " . " as Distance FROM " . $tableName . " WHERE latitude < " . $maxLat . " AND latitude > " . $minLat . " AND longitude < " . $maxLon . " AND longitude > " . $minLon . "having Distance < " . $radius . " ORDER BY Distance ASC LIMIT " . $limit . ";";
     }
     //return $query;
     $results = $this->query($query);
     //if (!$results) return array('problem'=>$query);
     foreach ($results as $key => $value) {
         $results[$key] = $value[$tableName];
         $results[$key]['distance'] = $value[0]['Distance'];
     }
     return $results;
 }
开发者ID:sgh1986915,项目名称:cakephp2-bpong,代码行数:26,代码来源:AppModel.php


示例19: imagecharx

function imagecharx($img, $char, $x0, $y0, $ylist)
{
    global $bk_color, $fg_color;
    $da = @imagecreate(10, 20) or die("Cannot Initialize new GD image stream");
    $background_color = imagecolorallocate($da, $bk_color[0], $bk_color[1], $bk_color[2]);
    $text_color = imagecolorallocate($da, $fg_color[0], $fg_color[1], $fg_color[2]);
    $color = imagecolorallocate($img, $fg_color[0], $fg_color[1], $fg_color[2]);
    $arg = rand(0, 18) / 100.0 * pi();
    imagestring($da, 18, 0, 0, $char, $text_color);
    for ($i = 0; $i < 200; $i++) {
        $y = @floor($i / 10);
        $x = $i % 10;
        $point_color = imagecolorat($da, $x, $y);
        if ($point_color == $text_color) {
            for ($j = 0; $j < 12; $j++) {
                $dx = 0;
                $dy = 0;
                $p = 6;
                for ($s = 0; $s < $p; $s++) {
                    $dx += rand(0, 1000 / $p) / 100;
                    $dy += rand(0, 1000 / $p) / 100;
                }
                $xx = $x * 5 + $dx - 25;
                $yy = $y * 5 + $dy - 50;
                $x1 = cos($arg) * $xx - sin($arg) * $yy + 25;
                $y1 = sin($arg) * $xx + cos($arg) * $yy + 50;
                imagesetpixel($img, $x0 + $x1, $y0 + $y1, $color);
            }
        }
    }
    imagedestroy($da);
}
开发者ID:sdgdsffdsfff,项目名称:json-db,代码行数:32,代码来源:spray.php


示例20: latitudeRange

 public static function latitudeRange($latitude, $longitude, $distance)
 {
     // Estimate the min and max latitudes within $distance of a given location.
     $long = deg2rad($longitude);
     $lat = deg2rad($latitude);
     $radius = self::earthRadius($latitude);
     $angle = $distance / $radius;
     $minlat = $lat - $angle;
     $maxlat = $lat + $angle;
     $rightangle = pi() / 2;
     if ($minlat < -$rightangle) {
         // wrapped around the south pole
         $overshoot = -$minlat - $rightangle;
         $minlat = -$rightangle + $overshoot;
         if ($minlat > $maxlat) {
             $maxlat = $minlat;
         }
         $minlat = -$rightangle;
     }
     if ($maxlat > $rightangle) {
         // wrapped around the north pole
         $overshoot = $maxlat - $rightangle;
         $maxlat = $rightangle - $overshoot;
         if ($maxlat < $minlat) {
             $minlat = $maxlat;
         }
         $maxlat = $rightangle;
     }
     return array(rad2deg($minlat), rad2deg($maxlat));
 }
开发者ID:kmergen,项目名称:yii2-location,代码行数:30,代码来源:Geo.php



注:本文中的pi函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP pi18n函数代码示例发布时间:2022-05-15
下一篇:
PHP phutil_utf8v函数代码示例发布时间:2022-05-15
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap