mirror of
https://github.com/eclipse-sailing-analytics/sailing-analytics.git
synced 2026-09-20 04:35:32 +00:00
use multiple geonames.org accounts
This commit is contained in:
@@ -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;
|
||||
|
||||
/**
|
||||
|
||||
+8
-2
@@ -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);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user