public virtual void TestPrecision() { init(GeohashPrefixTree.MaxLevelsPossible); Spatial4n.Core.Shapes.IPoint iPt = ctx.MakePoint(2.8028712999999925, 48.3708044);//lon, lat AddDocument(newDoc("iPt", iPt)); Commit(); Spatial4n.Core.Shapes.IPoint qPt = ctx.MakePoint(2.4632387000000335, 48.6003516); double KM2DEG = DistanceUtils.Dist2Degrees(1, DistanceUtils.EARTH_MEAN_RADIUS_KM); double DEG2KM = 1 / KM2DEG; double DIST = 35.75;//35.7499... assertEquals(DIST, ctx.DistCalc.Distance(iPt, qPt) * DEG2KM, 0.001); //distErrPct will affect the query shape precision. The indexed precision // was set to nearly zilch via init(GeohashPrefixTree.getMaxLevelsPossible()); double distErrPct = 0.025; //the suggested default, by the way double distMult = 1 + distErrPct; assertTrue(35.74 * distMult >= DIST); checkHits(q(qPt, 35.74 * KM2DEG, distErrPct), 1, null); assertTrue(30 * distMult < DIST); checkHits(q(qPt, 30 * KM2DEG, distErrPct), 0, null); assertTrue(33 * distMult < DIST); checkHits(q(qPt, 33 * KM2DEG, distErrPct), 0, null); assertTrue(34 * distMult < DIST); checkHits(q(qPt, 34 * KM2DEG, distErrPct), 0, null); }
private SpatialArgs q(Spatial4n.Core.Shapes.IPoint pt, double distDEG, double distErrPct) { IShape shape = ctx.MakeCircle(pt, distDEG); SpatialArgs args = new SpatialArgs(SpatialOperation.Intersects, shape); args.DistErrPct = (distErrPct); return(args); }