if (entity instanceof MapNode) {
return getDistKM(lat, lon, ((MapNode) entity).getLat(),
((MapNode) entity).getLon());
} else if (entity instanceof MapWay) {
MapWay way = (MapWay) entity;
BoundingBox bb = way.computeBoundingBox();
float bbLat = (Math.abs(lat - bb.getLatMin()) < Math.abs(lat
- bb.getLatMax())) ? bb.getLatMin() : bb.getLatMax();
float bbLon = (Math.abs(lon - bb.getLonMin()) < Math.abs(lon
- bb.getLonMax())) ? bb.getLonMin() : bb.getLonMax();
return getDistKM(lat, lon, bbLat, bbLon);