/** * Call this function to find the "nearby points" to publish to * on a grid of quantized (latitude, longitude) pairs * which are spaced at most $miles apart. * @method forPublishers * @static * @param {double} $latitude The latitude of the coordinates to search around * @param {double} $longitude The longitude of the coordinates to search around * @param {array} [$milesArray=null] To override the default in "Places"/"nearby"/"miles" config * @return {array} Returns an array of several ($streamName => $info) pairs * where the $streamName is the name of the stream corresponding to the "nearby point" * and $info includes the keys "latitude", "longitude", and "miles". */ static function forPublishers($latitude, $longitude, $milesArray = null) { $result = array(); if (!isset($milesArray)) { $milesArray = Q_Config::expect('Places', 'nearby', 'miles'); } foreach ($milesArray as $miles) { if ($longitude > 180) { $longitude = $longitude % 180 - 180; } if ($longitude < -180) { $longitude = $longitude % 180 + 180; } if ($latitude > 90) { $latitude = $latitude % 90 - 90; } if ($latitude < -90) { $latitude = $latitude % 90 + 90; } list($latQuantized, $longQuantized, $latGrid, $longGrid) = Places::quantize($latitude, $longitude, $miles); $streamName = Places_Nearby::streamName($latQuantized, $longQuantized, $miles); $result[$streamName] = array('latitude' => $latQuantized, 'longitude' => $longQuantized, 'geohash' => Places_Geohash::encode($latQuantized, $longQuantized, 6), 'miles' => $miles); } return $result; }