mirror of
https://github.com/eclipse-sailing-analytics/sailing-analytics.git
synced 2026-11-06 19:12:23 +00:00
Added country name as attribut to Placemark to prevent dependency cycle
This commit is contained in:
1 parent
38669a725f
commit
07cb5cc61f
6 files changed
+14
-12
No files matched your search
+1
@@ -940,4 +940,5 @@ public abstract class TrackedRaceImpl implements TrackedRace, CourseListener {
|
||||
public void speedAveragingChanged(long oldMillisecondsOverWhichToAverage, long newMillisecondsOverWhichToAverage) {
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
+2
-2
@@ -11,8 +11,8 @@ public class PlacemarkTest {
|
||||
|
||||
@Test
|
||||
public void placemarkEqualsTest() {
|
||||
Placemark p1 = new PlacemarkImpl("Kiel", "DE", new DegreePosition(55, 10), "P");
|
||||
Placemark p2 = new PlacemarkImpl("Kiel", "DE", new DegreePosition(55, 10), "P");
|
||||
Placemark p1 = new PlacemarkImpl("Kiel", "DE", "Germany", new DegreePosition(55, 10), "P");
|
||||
Placemark p2 = new PlacemarkImpl("Kiel", "DE", "Germany", new DegreePosition(55, 10), "P");
|
||||
Assert.assertEquals(p1, p2);
|
||||
}
|
||||
|
||||
|
||||
+2
-2
@@ -17,7 +17,7 @@ import com.sap.sailing.geocoding.impl.PlacemarkImpl;
|
||||
public class ReverseGeocoderTest {
|
||||
|
||||
private ReverseGeocoder geocoder = ReverseGeocoder.INSTANCE;
|
||||
private static final Placemark KIEL = new PlacemarkImpl("Kiel", "DE", new DegreePosition(54.32132926107913, 10.1348876953125), 232758);
|
||||
private static final Placemark KIEL = new PlacemarkImpl("Kiel", "DE", "Germany", new DegreePosition(54.32132926107913, 10.1348876953125), 232758);
|
||||
private static final Position KIEL_POSITION = new DegreePosition(54.3231063453431, 10.12265682220459);
|
||||
|
||||
@Test
|
||||
@@ -48,7 +48,7 @@ public class ReverseGeocoderTest {
|
||||
@Test
|
||||
public void getPlacemarkBestTest() {
|
||||
Position abroad = new DegreePosition(54.43334, 10.299999);
|
||||
Placemark getFirstByDistance = new PlacemarkImpl("Wendtorf", "DE", new DegreePosition(54.4166667, 10.3), 1139);
|
||||
Placemark getFirstByDistance = new PlacemarkImpl("Wendtorf", "DE", "Germany", new DegreePosition(54.4166667, 10.3), 1139);
|
||||
|
||||
try {
|
||||
Placemark p = geocoder.getPlacemarkLast(abroad, 20, new Placemark.ByPopulation());
|
||||
|
||||
@@ -6,7 +6,6 @@ Bundle-Version: 1.0.0.qualifier
|
||||
Bundle-Vendor: SAP
|
||||
Bundle-RequiredExecutionEnvironment: JavaSE-1.6
|
||||
Export-Package: com.sap.sailing.geocoding,
|
||||
com.sap.sailing.geocoding.impl
|
||||
com.sap.sailing.geocoding.impl;x-friends:="com.sap.sailing.geocoding.test"
|
||||
Require-Bundle: org.json.simple;bundle-version="1.1.0",
|
||||
com.sap.sailing.domain.common
|
||||
Import-Package: com.sap.sailing.util
|
||||
+6
-5
@@ -5,7 +5,6 @@ import com.sap.sailing.domain.common.Distance;
|
||||
import com.sap.sailing.domain.common.Position;
|
||||
import com.sap.sailing.geocoding.Placemark;
|
||||
import com.sap.sailing.geocoding.ReverseGeocoder;
|
||||
import com.sap.sailing.util.CountryCodeFactory;
|
||||
|
||||
/**
|
||||
* Used to define a populated place in the world.<br />
|
||||
@@ -17,15 +16,17 @@ public class PlacemarkImpl implements Placemark {
|
||||
|
||||
private String name;
|
||||
private String countryCode;
|
||||
private String countryName;
|
||||
private Position position;
|
||||
private long population;
|
||||
|
||||
/**
|
||||
* Creates a new Placemark with the given parameters as attributes.
|
||||
*/
|
||||
public PlacemarkImpl(String name, String countryCode, Position position, long population) {
|
||||
public PlacemarkImpl(String name, String countryCode, String countryName,Position position, long population) {
|
||||
this.name = name;
|
||||
this.countryCode = countryCode;
|
||||
this.countryName = countryName;
|
||||
this.position = position;
|
||||
this.population = population;
|
||||
}
|
||||
@@ -33,8 +34,8 @@ public class PlacemarkImpl implements Placemark {
|
||||
/**
|
||||
* Creates a new Placemark with the given parameters as attributes and a <code>population</code> of <code>0</code>;
|
||||
*/
|
||||
public PlacemarkImpl(String name, String countryCode, Position position, String type) {
|
||||
this(name, countryCode, position, 0);
|
||||
public PlacemarkImpl(String name, String countryCode, String countryName, Position position, String type) {
|
||||
this(name, countryCode, countryName, position, 0);
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
@@ -66,7 +67,7 @@ public class PlacemarkImpl implements Placemark {
|
||||
|
||||
@Override
|
||||
public String getCountryName() {
|
||||
return CountryCodeFactory.INSTANCE.getFromTwoLetterISOName(countryCode).getName();
|
||||
return countryName;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+2
-1
@@ -119,6 +119,7 @@ public class ReverseGeocoderImpl implements ReverseGeocoder {
|
||||
private Placemark JSONToPlacemark(JSONObject json) {
|
||||
String name = (String) json.get("toponymName");
|
||||
String countryCode = (String) json.get("countryCode");
|
||||
String countryName = (String) json.get("countryName");
|
||||
|
||||
// Tries are necessary, because some latitude or longitude values delivered by Geonames have no decimal places
|
||||
// and are interpreted as Long
|
||||
@@ -140,7 +141,7 @@ public class ReverseGeocoderImpl implements ReverseGeocoder {
|
||||
long population = (Long) json.get("population");
|
||||
|
||||
if (name != null && lngDeg != null && latDeg != null) {
|
||||
return new PlacemarkImpl(name, countryCode, p, population);
|
||||
return new PlacemarkImpl(name, countryCode, countryName, p, population);
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user