MCPcopy Create free account
hub / github.com/Snapchat/KeyDB / geohashGetDistanceIfInRectangle

Function geohashGetDistanceIfInRectangle

src/geohash_helper.cpp:251–260  ·  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

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

Callers 1

geoAppendIfWithinShapeFunction · 0.85

Calls 1

geohashGetDistanceFunction · 0.85

Tested by

no test coverage detected