Closed hunterlee closed 13 years ago
I must look at the testcase that checks that a circular query around WGS84Point(10.00254, 76.30627) with 2.5km radius does only yield one hash...
Can you provide a testcase?
sorry for delaying the response...
here is my test case: WGS84Point center = new WGS84Point(39.86391280373075, 116.37356590048701); //set the radius is 589 meters GeoHashCircleQuery query = new GeoHashCircleQuery(center, 589);
//the distance between center and test1 is about 430 meters
WGS84Point test1 = new WGS84Point(39.8648866576058, 116.378465869303);
//the distance between center and test2 is about 510 meters
WGS84Point test2 = new WGS84Point(39.8664787092599, 116.378552856158);
//return 2 hashes
List<GeoHash> list = query.getSearchHashes();
for(GeoHash hash : list) {
boolean status = hash.contains(test1);
System.out.println(status);
status = hash.contains(test2);
System.out.println(status);
}
result is: false false false false
that means neither of the searched geohash contains these two test points. however, the two points are in the circle.
I added your test case and fixes the code. I also added a new method that lets you easily check wether a WGS84Point is inside the bounding box defined by any query.
Cheers.
line 34 in GeoHashCircleQuery.java is wrong: double halfRadius = radius / 2.0;
the "halfRadius" is meaningLess. you should use the radius to create the BoundingBox, which will exactly overlap the circle.