Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public static GeoPoint improveDistanceMetric(double radius, GeoPoint location,
- double degree, DistanceMetric distanceMetric){
- double factor = 0.5;
- double error = radius * 0.01;
- //Constantes de oblación
- double latOblacion = 110540;
- double longOblacion = 111320;
- GeoPoint frontierPoint = new GeoPoint();
- double dLat, dLong, distance;
- do{
- dLat = radius * Math.sin(Math.toRadians(degree)) * factor;
- dLong = radius * Math.cos(Math.toRadians(degree)) * factor;
- frontierPoint.setLatitude(location.getLatitude() + dLat / latOblacion);
- frontierPoint.setLongitude(location.getLongitude() + dLong / (longOblacion
- * Math.cos(Math.toRadians(location.getLatitude()))));
- distance = distanceMetric.calculateDistance(location, frontierPoint);
- if(distance * 1000 < radius - error){
- factor += 0.01;
- }
- else if(distance * 1000 > radius + error){
- factor -= 0.01;
- }
- }while(!(distance * 1000 > radius - error && distance * 1000 < radius + error));
- return frontierPoint;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement