geolocation - What's the difference between "area" and "BoundingBox" from Redis's source code -


http://download.redis.io/redis-stable/deps/geohash-int/geohash_helper.c url above, know there 2 conceptions , 1 geohashboundingbox ,and area,my questions what's difference between them , why need them both? why sentence "geohashgetcoordrange(&long_range, &lat_range);" called 2 times?

geohashradius geohashgetareasbyradius(double longitude, double latitude,    double radius_meters) { geohashrange long_range, lat_range; geohashradius radius = { { 0 } }; geohashbits hash = { 0 }; geohashneighbors neighbors = { { 0 } }; geohasharea area = { { 0 } }; double min_lon, max_lon, min_lat, max_lat; double bounds[4]; int steps;  geohashboundingbox(longitude, latitude, radius_meters, bounds); min_lon = bounds[0]; min_lat = bounds[1]; max_lon = bounds[2]; max_lat = bounds[3];  steps = geohashestimatestepsbyradius(radius_meters,latitude);  geohashgetcoordrange(&long_range, &lat_range); geohashencode(&long_range, &lat_range, longitude, latitude, steps, &hash); geohashneighbors(&hash, &neighbors); geohashgetcoordrange(&long_range, &lat_range); geohashdecode(long_range, lat_range, hash, &area);  if (area.latitude.min < min_lat) {     gzero(neighbors.south);     gzero(neighbors.south_west);     gzero(neighbors.south_east); } if (area.latitude.max > max_lat) {     gzero(neighbors.north);     gzero(neighbors.north_east);     gzero(neighbors.north_west); } if (area.longitude.min < min_lon) {     gzero(neighbors.west);     gzero(neighbors.south_west);     gzero(neighbors.north_west); } if (area.longitude.max > max_lon) {     gzero(neighbors.east);     gzero(neighbors.south_east);     gzero(neighbors.north_east); } radius.hash = hash; radius.neighbors = neighbors; radius.area = area; return radius; 

}

a bonding box in general smallest rectangular box contain object. can't speak exact function of geohasharea in redis, since imply have similar purpose, if both represent geographic area geohasharea more detailed polygonal representation of area simple rectangle geohashboundingbox.

for second question, presumably, since variables long_range , lat_range passed reference, there's chance

geohashencode(&long_range, &lat_range, longitude, latitude, steps, &hash); 

modifies value , function geohashgetcoordrange called again on different values.


Comments

Popular posts from this blog

javascript - Thinglink image not visible until browser resize -

firebird - Error "invalid transaction handle (expecting explicit transaction start)" executing script from Delphi -

mongodb - How to keep track of users making Stripe Payments -