MCPcopy Create free account
hub / github.com/F-Stack/f-stack / geohashGetDistanceIfInRectangle

Function geohashGetDistanceIfInRectangle

app/redis-6.2.6/src/geohash_helper.c:254–263  ·  view source on GitHub ↗

Judge whether a point is in the axis-aligned rectangle, when the distance * between a searched point and the center point is less than or equal to * height/2 or width/2 in height and width, the point is in the rectangle. * * width_m, height_m: the rectangle * x1, y1 : the center of the box * x2, y2 : the point to be searched */

Source from the content-addressed store, hash-verified

252 * x2, y2 : the point to be searched
253 */
254int geohashGetDistanceIfInRectangle(double width_m, double height_m, double x1, double y1,
255 double x2, double y2, double *distance) {
256 double lon_distance = geohashGetDistance(x2, y2, x1, y2);
257 double lat_distance = geohashGetDistance(x2, y2, x2, y1);
258 if (lon_distance > width_m/2 || lat_distance > height_m/2) {
259 return 0;
260 }
261 *distance = geohashGetDistance(x1, y1, x2, y2);
262 return 1;
263}

Callers 1

geoAppendIfWithinShapeFunction · 0.85

Calls 1

geohashGetDistanceFunction · 0.85

Tested by

no test coverage detected