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 */
| 249 | * x2, y2 : the point to be searched |
| 250 | */ |
| 251 | int 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 | } |
no test coverage detected