private void checkBBox(Point ctr, double distKm) {
String msg = "ctr: "+ctr+" distKm: "+distKm;
double dist = distKm * KM_TO_DEG;
Rectangle r = dc().calcBoxByDistFromPt(ctr, dist, ctx, null);
double horizAxisLat = dc().calcBoxByDistFromPt_yHorizAxisDEG(ctr, dist, ctx);
if (!Double.isNaN(horizAxisLat))
assertTrue(r.relateYRange(horizAxisLat, horizAxisLat).intersects());
//horizontal
if (r.getWidth() >= 180) {
double deg = dc().distance(ctr, r.getMinX(), r.getMaxY() == 90 ? 90 : -90);
double calcDistKm = deg * DEG_TO_KM;
assertTrue(msg, calcDistKm <= distKm + EPS);
//horizAxisLat is meaningless in this context
} else {
Point tPt = findClosestPointOnVertToPoint(r.getMinX(), r.getMinY(), r.getMaxY(), ctr);
double calcDistKm = dc().distance(ctr, tPt) * DEG_TO_KM;
assertEquals(msg, distKm, calcDistKm, EPS);
assertEquals(msg, tPt.getY(), horizAxisLat, EPS);
}
//vertical
double topDistKm = dc().distance(ctr, ctr.getX(), r.getMaxY()) * DEG_TO_KM;
if (r.getMaxY() == 90)
assertTrue(msg, topDistKm <= distKm + EPS);
else
assertEquals(msg, distKm, topDistKm, EPS);
double botDistKm = dc().distance(ctr, ctr.getX(), r.getMinY()) * DEG_TO_KM;
if (r.getMinY() == -90)
assertTrue(msg, botDistKm <= distKm + EPS);
else
assertEquals(msg, distKm, botDistKm, EPS);
}