当前位置:网站首页>Php:redis uses geospatial
Php:redis uses geospatial
2022-06-12 10:20:00 【Qu Shuai 369】
Go straight to the code :
//geoAdd: Will give the space element ( longitude 、 latitude 、 name ) Add to the specified key . The data will be stored in keys in an ordered set , To make it look like GEORADIUS and GEORADIUSBYMEMBER Such a command can later retrieve these elements through a location query
//geoAdd($key, $longitude( longitude ), $latitude( latitude ), $name [, $longitude, $latitude, $member, ...]);
$redis->del("myplaces");
//key Whether the value exists
$redis->exists("myplaces");
// The effective longitude is -180 C to 180 degree
// The effective latitude is -85.05112878 C to 85.05112878 degree ( All data will fail to be added as long as invalid longitude and latitude occur )
$result = $redis->geoAdd('myplaces', '-157.478799', '21.235456', 'Honolulu', '116.404269', '39.91582', 'beijing', '121.47879', '31.235456', 'shanghai');
dump($result);
//geoHash(key,name1,name2,namen) Returns the... Of one or more positional elements Geohash character string Returns one or more elements Geohash Array of strings
$hashes = $redis->geoHash("myplaces", "San Francisco", "Honolulu","beijing","shanghai");//['87z9pyek3y0','8e8y6d5jps0']
dump($hashes);
//geoPos(key,name1,name2,namen): Return all the positions of the positioning elements from the key ( Longitude and latitude ) Command returns an array , Each item in the array consists of two elements ( longitude , latitude ) form
$positions = $redis->geoPos("myplaces", "San Francisco", "Honolulu");//[[37.773, -122.431],[-157.858, 21.315]]
dump($positions);
//GeoDist(key,name1,name2 [, $unit='m']): Returns the distance between two given positions unit contain m、km、mi( miles )、ft( feet )
$kilometers = $redis->geoPos("myplaces", "San Francisco", "Honolulu",'km');//168.2752
dump($kilometers);
//geoRadius($key, $longitudee( longitude ), $latitude( latitude ), $radius( radius ), $unit [, Array $options]): Centered on a given latitude and longitude , Return key contains position elements , The distance from the center shall not exceed the given maximum radius radius All position elements of the distance
dump($redis->geoRadius("myplaces", 123.858, 42.306, 10000, 'km'));
// Express 10000km Extraction of ranges 2 individual
$options['count'] = 2;
//ASC|DESC
$options[] = 'ASC';
//WITHCOORD: It also returns the longitude of the matching item , Latitude coordinates .
$options[] = 'WITHCOORD';
//WITHDIST: Also return to the designated center to return the distance of the item . The distance is returned in the same units as the radius parameter specified for the command .
$options[] = 'WITHDIST';
dump($redis->geoRadius("myplaces", 123.858, 42.306, 10000, 'km', $options));
//geoRadiusByMember($key, $name, $radius, $units [, Array $options]): Function and geoRadius It's just that the origin is name Decide not like geoRadius Enter longitude and latitude to determine
dump($redis->geoRadiusByMember("myplaces", "shanghai", 3000, 'km'));Execution results :
int(3)
array(4) {
[0] => bool(false)
[1] => string(11) "8eb0b3z3w00"
[2] => string(11) "wx4g0f7n800"
[3] => string(11) "wtw3sq4psz0"
}
array(2) {
[0] => array(0) {
}
[1] => array(2) {
[0] => string(22) "-157.47879713773727417"
[1] => string(20) "21.23545663354175161"
}
}
array(3) {
[0] => array(0) {
}
[1] => array(2) {
[0] => string(22) "-157.47879713773727417"
[1] => string(20) "21.23545663354175161"
}
[2] => array(0) {
}
}
array(3) {
[0] => string(8) "shanghai"
[1] => string(7) "beijing"
[2] => string(8) "Honolulu"
}
array(2) {
[0] => array(3) {
[0] => string(7) "beijing"
[1] => string(8) "678.5471"
[2] => array(2) {
[0] => string(21) "116.40426903963088989"
[1] => string(20) "39.91581928642635546"
}
}
[1] => array(3) {
[0] => string(8) "shanghai"
[1] => string(9) "1249.2980"
[2] => array(2) {
[0] => string(21) "121.47878855466842651"
[1] => string(20) "31.23545629441388627"
}
}
}
array(2) {
[0] => string(8) "shanghai"
[1] => string(7) "beijing"
}
array(1) {
[0] => array(0) {
}
}
边栏推荐
- JVM (IV) Class file structure (complete parsing of bytecode attached)
- 容器江湖的爱恨情仇
- Jump to wechat in app and open wechat
- [926. flip the string to monotonic increment]
- np.meshgrid()函数 以及 三维空间中的坐标位置生成 以及 numpy.repeat()函数介绍
- 2021-03-26
- [Wayland] Wayland agreement description
- [CEGUI] concept introduction
- ASP. Net core permission system practice (zero)
- postgresql 使用存储过程,拼接多张表,查询数据
猜你喜欢

Research on autojs wechat: the control IP in wechat on different versions of wechat or simulators is different.

Remote desktop cannot copy and paste solution

ASP. Net core permission system practice (zero)

JVM (VI) Virtual machine bytecode execution engine (with stack execution process and bytecode instruction table)

Pycharm view the current version of opencv
![[CEGUI] log system](/img/5d/c8f76194b1ae2a62d3f5a1e84a5603.jpg)
[CEGUI] log system

Shen Min, CIO of science and technology innovator Digital China Group: the best practice model is failing, and open source accelerates Distributed Innovation

一文读懂Dfinity生态中的首个NFT平台:IMPOSSIBLE THINGS
![[Mozilla] basic concept analysis of IPDL](/img/b2/97b4db069052133ee614ecb1a8369e.jpg)
[Mozilla] basic concept analysis of IPDL

pycharm 查看opencv当前的版本
随机推荐
Raw socket usage
Yarn scheduling
QT custom window fillets
[CEGUI] resource loading process
Papaya Mobile: cross border marketing has entered the era of "information flow", allowing independent station sellers to share opportunities to go to sea
Circuitbreaker fuse of resilience4j - circuitbreakerevent event
JVM (VIII) Thread safety and lock optimization
Using C language code to realize factory LCD RGB test program
FPGA VGA display based on de2-115 platform
Redis (II) Memory mapped data structure
2021-09-15
Add jar package under idea2018 web project
How PLC constructs shift function block (FC) by itself
[DDS] dds-rpc implementation based on opendds
远程桌面不能复制粘贴解决办法
Introduction to on-line circuit simulation and open source electronic hardware design
CLAHE in opencv for 16 bit image enhancement display
Strange error -- frame detected by contour detection, expansion corrosion, and reversal of opening and closing operation effect
Canal ha mode configuration
redis学习记录:字典(dict)源码分析