一个geohash的 值是对应的一个地图区域的,然后我需要的这个区域的坐标区间 ,即经纬度的最大最小值。
那么在geohash 的wiki主页上找到c的实现,赞一个。
在我的机器上还不能直接编译通过,做了如下改变:
1 geohash.c 文件改成geohash.cpp
2 去掉 stdbool.h 这是C99 的头文件,vs2005 不支持,stdbool的全文如下,实现不行,就赋值内容到geohash.h文件中去
#ifndef _STDBOOL_H
#define _STDBOOL_H
#ifndef __cplusplus
#define bool _Bool
#define true 1
#define false 0
#else /* __cplusplus */
/* Supporting <stdbool.h> in C++ is a GCC extension. */
#define _Bool bool
#define bool bool
#define false false
#define true true
#endif /* __cplusplus */
/* Signal that all the definitions are present. */
#define __bool_true_false_are_defined 1
#endif /* stdbool.h */
GEOHASH_area *area;
area = GEOHASH_decode("ws3x7");
area->longitude.max;
///* You can get the range of both latitude and longtitude
printf("%lf %lf\n" ,area->latitude.max ,area->latitude.min);
printf("%lf %lf\n" ,area->longitude.max ,area->longitude.min);
参考:
1: http://en.wikipedia.org/wiki/Geohash