Geohash is used to obtain the range coordinates of a block.

Source: Internet
Author: User

A geohash value corresponds to a map area, and then I need the coordinates of this area, that is, the maximum and minimum values of latitude and longitude.

On the Wiki homepage of geohash, find the implementation of C and like it.

On my machine, the compilation cannot be passed directly, but the following changes have been made:

1. Change the geohash. c file to geohash. cpp.

2. Remove stdbool. H. This is the header file of c99, which is not supported by vs2005. The full text of stdbool is as follows. If it is not implemented, assign the value to the geohash. h file.

# 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
# Define bool
# Define False false
# Define 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 longtitudeprintf("%lf %lf\n" ,area->latitude.max ,area->latitude.min);printf("%lf %lf\n" ,area->longitude.max ,area->longitude.min);

Refer:

1: http://en.wikipedia.org/wiki/Geohash

2: https://github.com/lyokato/libgeohash

Original blog address: http://www.fuxiang90.com/2012/10/geohash-%E5%BE%97%E5%88%B0%E5%9D%97%E7%9A%84%E5%8C%BA%E9%97%B4%E5%9D%90%E6%A0%87/

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.