コード例 #1
0
         }
         $dLat = $_REQUEST['lat'];
         $dLng = $_REQUEST['lng'];
         // if we have lat lng values for the user we use it as the center
     } elseif (is_numeric($gBitUser->getField('lat'))) {
         $dLat = $gBitUser->getField('lat');
         $dLng = $gBitUser->getField('lng');
     }
     require_once UTIL_PKG_PATH . 'geocalc/GeoCalc.class.php';
     $oGC = new GeoCalc();
     // distance in kilometers
     // @TODO turn this into a package config default
     $dRadius = $_REQUEST['distance'];
     // Calculate the boundary distance in degrees longitude / latitude
     $dAddLat = $oGC->getLatPerKm() * $dRadius;
     $dAddLon = $oGC->getLonPerKmAtLat($dLat) * $dRadius;
     // trip the geo service
     $_REQUEST['up_lat'] = $dLat + $dAddLat;
     $_REQUEST['right_lng'] = $dLng + $dAddLon;
     $_REQUEST['down_lat'] = $dLat - $dAddLat;
     $_REQUEST['left_lng'] = $dLng - $dAddLon;
 }
 // can force a general lookup using Any param if distance is not specified
 if (!empty($_REQUEST['content_type_guid']) && $_REQUEST['content_type_guid'] == 'Any') {
     $_REQUEST['content_type_guid'] = NULL;
 }
 //forces return of $contentList from get_content_list_inc.php
 $_REQUEST['output'] = 'raw';
 //forces only geo located data
 $_REQUEST['geo_notnull'] = TRUE;
 include_once LIBERTY_PKG_PATH . 'list_content.php';
コード例 #2
0
function resellersCloseToZip($dRadius = null, $zip = null, $product = null, $elite = false)
{
    global $debug;
    //	if (!isset($dRadius) || !isset($zip) || !isset($resellers)) {
    if (!isset($dRadius) || !isset($zip) || !isset($product)) {
        if ($debug) {
            echo "<br />someone tried to pass an empty var to resellersCloseToZip()<br />";
        }
        return false;
    }
    //get the input zips lat and long
    $dLatitude = getZipsLat($zip);
    $dLongitude = getZipsLong($zip);
    $oGC = new GeoCalc();
    $dAddLat = $oGC->getLatPerKm() * $dRadius;
    $dAddLon = $oGC->getLonPerKmAtLat($dLatitude) * $dRadius;
    //calculate the search range around the input zip's lat/lon
    $dNorthBounds = $dLatitude + $dAddLat;
    $dSouthBounds = $dLatitude - $dAddLat;
    $dEastBounds = $dLongitude + $dAddLon;
    $dWestBounds = $dLongitude - $dAddLon;
    if ($debug) {
        echo "northbounds: {$dNorthBounds}<br/>";
        echo "southbounds: {$dSouthBounds}<br/>";
        echo "eastbounds: {$dEastBounds}<br/>";
        echo "westbounds: {$dWestBounds}<br/>";
    }
    // grab all resellers that fall within this geodesic range
    $sqlResellerLocations = "Select `resellers`.id, `resellers`.company FROM `resellers` ";
    if ($product != 'all') {
        $sqlResellerLocations .= "JOIN `reseller_products` ON `resellers`.id = `reseller_products`.reseller_id ";
    }
    $sqlResellerLocations .= "WHERE lat > '" . $dSouthBounds . "'" . " AND lat < '" . $dNorthBounds . "'" . " AND lon > '" . $dWestBounds . "'" . " AND lon < '" . $dEastBounds . "'";
    if (!$elite) {
        $sqlResellerLocations .= " AND elite = '0'";
    } else {
        $sqlResellerLocations .= " AND elite = '1'";
    }
    if ($product != "all") {
        $sqlResellerLocations .= " AND `reseller_products`.product_id = '" . $product . "'";
    }
    //$sqlResellerLocations .= " LIMIT 0, 4";
    $sqlResellerLocations .= " AND  `resellers`.country_id = '247'";
    $rResellerLocations = mysql_query($sqlResellerLocations) or die('died trying to get listing of US resellers. <br /> sql: ' . $sqlResellerLocations . ' <br /> error:' . mysql_error());
    if ($debug) {
        echo "sql: " . $sqlResellerLocations;
        echo "<br />Resellers found for this area: " . mysql_num_rows($rResellerLocations) . "<br />";
    }
    while ($row = mysql_fetch_assoc($rResellerLocations)) {
        if ($debug) {
            echo "reseller: " . $row['id'] . " company: " . $row['company'] . "<br />";
        }
        //add to accessible resellers list
        $resellers[] = $row['id'];
    }
    if (isset($resellers)) {
        return $resellers;
    }
}