use multiple geonames.org accounts

This commit is contained in:
Axel Uhl
2012-06-23 19:58:20 +02:00
parent 12cb23d3ca
commit 7a99a4d2f5
3 changed files with 11 additions and 3 deletions
@@ -12,7 +12,6 @@ import com.sap.sailing.geocoding.impl.ReverseGeocoderImpl;
public interface ReverseGeocoder {
final ReverseGeocoder INSTANCE = new ReverseGeocoderImpl();
final String GEONAMES_USER = "sailtracking";
final double POSITION_CACHE_DISTANCE_LIMIT_IN_KM = 5.0;
/**
@@ -12,6 +12,7 @@ import java.util.Collections;
import java.util.Comparator;
import java.util.Iterator;
import java.util.List;
import java.util.Random;
import org.json.simple.JSONArray;
import org.json.simple.JSONObject;
@@ -236,7 +237,7 @@ public class ReverseGeocoderImpl implements ReverseGeocoder {
StringBuilder url = new StringBuilder(NEARBY_PLACE_SERVICE);
url.append("&lat=" + Double.toString(position.getLatDeg()));
url.append("&lng=" + Double.toString(position.getLngDeg()));
url.append("&username=" + GEONAMES_USER);
url.append("&username=" + getGeonamesUser());
URL request = new URL(url.toString());
URLConnection connection = request.openConnection();
@@ -254,7 +255,7 @@ public class ReverseGeocoderImpl implements ReverseGeocoder {
url.append("&lng=" + Double.toString(position.getLngDeg()));
url.append("&radius=" + Double.toString(radius));
url.append("&maxRows=" + Integer.toString(maxRows));
url.append("&username=" + GEONAMES_USER);
url.append("&username=" + getGeonamesUser());
URL request = new URL(url.toString());
URLConnection connection = request.openConnection();
@@ -265,4 +266,9 @@ public class ReverseGeocoderImpl implements ReverseGeocoder {
return geonames;
}
final String GEONAMES_USER = "sailtracking";
private String getGeonamesUser() {
return GEONAMES_USER+new Random().nextInt(10);
}
}