本文整理汇总了PHP中SphinxClient::setGeoAnchor方法的典型用法代码示例。如果您正苦于以下问题:PHP SphinxClient::setGeoAnchor方法的具体用法?PHP SphinxClient::setGeoAnchor怎么用?PHP SphinxClient::setGeoAnchor使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SphinxClient
的用法示例。
在下文中一共展示了SphinxClient::setGeoAnchor方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: filters
/**
* @brief set query filters, SQL-like syntax - 'additional where_condition'
* @param array $filters
* @return $this chain
*/
public function filters($filters)
{
$this->criteria->filters = $filters;
//set filters
if ($filters && is_array($filters)) {
foreach ($filters as $fil => $vol) {
// geo filter
if ($fil == 'geo') {
$min = (double) (isset($vol['min']) ? $vol['min'] : 0);
$point = explode(' ', str_replace('POINT(', '', trim($vol['point'], ')')));
$this->client->setGeoAnchor('latitude', 'longitude', (double) $point[1] * (pi() / 180), (double) $point[0] * (pi() / 180));
$this->client->setFilterFloatRange('@geodist', $min, (double) $vol['buffer']);
// usual filter
}
if ($fil == 'range') {
// $point = explode(' ', str_replace('POINT(', '', trim($vol['point'], ')')));
// $this->client->setGeoAnchor('latitude', 'longitude', (float) $point[1] * ( pi() / 180 ), (float) $point[0] * ( pi() / 180 ));
if (is_array($vol)) {
foreach ($vol as $kk => $vv) {
$min = (double) (isset($vv['min']) ? $vv['min'] : 0);
$this->client->setFilterFloatRange($kk, $min, (double) $vv['max']);
}
}
// usual filter
} else {
if ($vol) {
$this->client->SetFilter($fil, is_array($vol) ? $vol : array($vol));
}
}
}
}
return $this;
}
示例2: getSphinxSearchedResult
/**
* @brief 위치 기반 Sphinx 검색 부분 (외부/내부 호출용..)
* @param $document_srl 문서 번호
* @param $lat 위도
* @param $lon 경도
* @return 검색된 결과 리스트
*/
function getSphinxSearchedResult($document_srl, $lat, $lon)
{
$s = new SphinxClient();
$oModuleModel =& getModel('module');
$config = $oModuleModel->getModuleConfig('aroundmap');
$s->setServer($config->serverName, $config->serverPort);
$s->setLimits(0, 10);
$s->setMatchMode(SPH_MATCH_ALL);
$s->SetSortMode(SPH_SORT_EXTENDED, '@geodist ASC');
$s->setFilter("document_srl", array($document_srl), true);
$s->SetFilterFloatRange("@geodist", 0, 10000);
$s->setMaxQueryTime(3);
$s->setGeoAnchor("lat", "lon", (double) deg2rad($lat), (double) deg2rad($lon));
$result = $s->query("", "idx_aroundmap");
$ret = array();
if ($result[total_found] > 0) {
$ret = $result[matches];
}
return $ret;
}