Giter Site home page Giter Site logo

geohash's Introduction

geohash

php geohash extension (php geohash 扩展)

编译

git clone 到机器

执行:
phpize
./configure
make
make install

然后把 geohash.so 加入到php.ini中

方法

/**
 *  $latitude    //纬度
 *  $longitude   //经度
 *  $precision   //精密度, 默认是12
 *  返回 $precision 长度的 string 
 */
geohash_encode($latitude, $longitude, $precision=12);  



/**
 *  $hash    //geohash_encode后的值
 *  返回 array // Array
 *					(
 *					    [latitude] => 39.416916975752
 *					    [longitude] => 100.92223992571
 *					    [north] => 39.416917059571
 *					    [east] => 100.92224009335
 *					    [south] => 100.92223992571
 *					    [west] => 100.92223975807
 *					)
 */
geohash_decode($hash);

/**
 *  $hash    //geohash_encode后的值
 *  返回 在$hash 8个方向的hash值 (顺序:N, NE, E, SE, S, SW, W, NW)
 *  
 *		  NW N NE
 *		    \|/
 *		  W - - E
 *		    /|\
 *		  SW S SE
 * 
 */
geohash_neighbors($hash);

/**
 *  $precision    //精密度
 *  返回 数组,array("width"=>12.0, "height"=>12.0) 
 *  表示矩形的宽和高
 */
geohash_dimension($precision);

geohash's People

Contributors

gozhhu avatar shenzhe avatar t1m30ut avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

geohash's Issues

PHP71: incorrect result for geohash_neighbors: c2b2mvrc

var_dump(geohash_neighbors('c2b2mvrc'));

array(8) {
[0]=>
string(8) "c2b2mvrf"
[1]=>
string(14) "c2b2qj24c2b2mv"
[2]=>
string(14) "c2b2qj21@��"
[3]=>
string(13) "c2b2qj21@�"
[4]=>
string(8) "c2b2mvrb"
[5]=>
string(8) "c2b2mvr8"
[6]=>
string(8) "c2b2mvr9"
[7]=>
string(8) "c2b2mvrd"
}

geohash_neighbors产生coredump

服务器版本:ubuntu 12.04
PHP版本:PHP 5.5.37

gdb stack信息如下:

#0 0x00007f825184e447 in zend_hash_destroy () from /usr/lib/apache2/modules/libphp5.so
#1 0x00007f825181f378 in zend_release_labels () from /usr/lib/apache2/modules/libphp5.so
#2 0x00007f8251808bfd in compile_file () from /usr/lib/apache2/modules/libphp5.so
#3 0x00007f825182fa4a in dtrace_compile_file () from /usr/lib/apache2/modules/libphp5.so
#4 0x00007f82516ac2c6 in ?? () from /usr/lib/apache2/modules/libphp5.so
#5 0x00007f824e686b29 in ?? () from /usr/lib/php5/20121212/opcache.so
#6 0x00007f824e6881cf in persistent_compile_file () from /usr/lib/php5/20121212/opcache.so
#7 0x00007f8251808d6c in compile_filename () from /usr/lib/apache2/modules/libphp5.so
#8 0x00007f82518ed0bb in ?? () from /usr/lib/apache2/modules/libphp5.so
#9 0x00007f82518af638 in execute_ex () from /usr/lib/apache2/modules/libphp5.so
#10 0x00007f825182fad6 in dtrace_execute_ex () from /usr/lib/apache2/modules/libphp5.so
#11 0x00007f8251831cf3 in zend_call_function () from /usr/lib/apache2/modules/libphp5.so
#12 0x00007f8251857b47 in zend_call_method () from /usr/lib/apache2/modules/libphp5.so
#13 0x00007f8251729b09 in zif_spl_autoload_call () from /usr/lib/apache2/modules/libphp5.so
#14 0x00007f825182fbe9 in dtrace_execute_internal () from /usr/lib/apache2/modules/libphp5.so
#15 0x00007f8251831eb3 in zend_call_function () from /usr/lib/apache2/modules/libphp5.so
#16 0x00007f82518325ba in zend_lookup_class_ex () from /usr/lib/apache2/modules/libphp5.so
#17 0x00007f8251832ae9 in zend_fetch_class () from /usr/lib/apache2/modules/libphp5.so
#18 0x00007f8251888c68 in ?? () from /usr/lib/apache2/modules/libphp5.so
#19 0x00007f82518af638 in execute_ex () from /usr/lib/apache2/modules/libphp5.so
#20 0x00007f825182fad6 in dtrace_execute_ex () from /usr/lib/apache2/modules/libphp5.so
#21 0x00007f82518ecae1 in ?? () from /usr/lib/apache2/modules/libphp5.so
#22 0x00007f82518af638 in execute_ex () from /usr/lib/apache2/modules/libphp5.so
#23 0x00007f825182fad6 in dtrace_execute_ex () from /usr/lib/apache2/modules/libphp5.so
#24 0x00007f82518ecae1 in ?? () from /usr/lib/apache2/modules/libphp5.so
#25 0x00007f82518af638 in execute_ex () from /usr/lib/apache2/modules/libphp5.so
#26 0x00007f825182fad6 in dtrace_execute_ex () from /usr/lib/apache2/modules/libphp5.so
#27 0x00007f82518ecae1 in ?? () from /usr/lib/apache2/modules/libphp5.so
#28 0x00007f82518af638 in execute_ex () from /usr/lib/apache2/modules/libphp5.so
#29 0x00007f825182fad6 in dtrace_execute_ex () from /usr/lib/apache2/modules/libphp5.so
#30 0x00007f82518ecae1 in ?? () from /usr/lib/apache2/modules/libphp5.so
#31 0x00007f82518af638 in execute_ex () from /usr/lib/apache2/modules/libphp5.so
#32 0x00007f825182fad6 in dtrace_execute_ex () from /usr/lib/apache2/modules/libphp5.so
#33 0x00007f82518ee40e in ?? () from /usr/lib/apache2/modules/libphp5.so
#34 0x00007f82518af638 in execute_ex () from /usr/lib/apache2/modules/libphp5.so
#35 0x00007f825182fad6 in dtrace_execute_ex () from /usr/lib/apache2/modules/libphp5.so
#36 0x00007f8251841994 in zend_execute_scripts () from /usr/lib/apache2/modules/libphp5.so
#37 0x00007f82517de96d in php_execute_script () from /usr/lib/apache2/modules/libphp5.so
#38 0x00007f82518efa9d in ?? () from /usr/lib/apache2/modules/libphp5.so
#39 0x00007f8255d906d8 in ap_run_handler ()
#40 0x00007f8255d90cce in ap_invoke_handler ()
#41 0x00007f8255da74ea in ap_process_async_request ()
#42 0x00007f8255da764f in ap_process_request ()

geohash_decode crash on PHP.7+

After some changes for PHP7:
RETURN_STRING # remove last parameter
add_next_index_string # remove last parameter

I can compile the source, but the function will be core dumped.

介绍文档错误

/**

  • $precision //精密度
  • 返回 数组,array("width"=>12.0, "height"=>12.0)
  • 表示矩形的宽和高
    */
    geohash_dimension($hash);

应该是
/**

  • $precision //精密度
  • 返回 数组,array("width"=>12.0, "height"=>12.0)
  • 表示矩形的宽和高
    */
    geohash_dimension($precision);

另外能不能说明一下这个返回的宽跟高,单位是什么啊

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.