mirror of
https://github.com/eclipse-sailing-analytics/sailing-analytics.git
synced 2026-11-06 19:12:23 +00:00
Removed attribute Type from Placemark
This commit is contained in:
1 parent
6c617eab27
commit
c752bd0020
4 files changed
+33
-20
No files matched your search
+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), "P", 232758);
|
||||
private static final Placemark KIEL = new PlacemarkImpl("Kiel", "DE", 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), "P", 1139);
|
||||
Placemark getFirstByDistance = new PlacemarkImpl("Wendtorf", "DE", new DegreePosition(54.4166667, 10.3), 1139);
|
||||
|
||||
try {
|
||||
Placemark p = geocoder.getPlacemarkLast(abroad, 20, new Placemark.ByPopulation());
|
||||
|
||||
@@ -5,12 +5,26 @@ import java.util.Comparator;
|
||||
import com.sap.sailing.domain.common.Distance;
|
||||
import com.sap.sailing.domain.common.Position;
|
||||
|
||||
/**
|
||||
* Used to define a populated place in the world.<br />
|
||||
* Used by {@link ReverseGeocoder}.
|
||||
* @author Lennart Hensler (D054527)
|
||||
*
|
||||
*/
|
||||
public interface Placemark {
|
||||
|
||||
/**
|
||||
* @return The name of the Placemark
|
||||
*/
|
||||
String getName();
|
||||
/**
|
||||
* @return The 2 letters country code of the Placemark
|
||||
*/
|
||||
String getCountryCode();
|
||||
/**
|
||||
* @return The {@link Position} of the Placemark
|
||||
*/
|
||||
Position getPosition();
|
||||
String getType();
|
||||
long getPopulation();
|
||||
|
||||
Distance distanceFrom(Position p);
|
||||
|
||||
+15
-15
@@ -4,26 +4,37 @@ import com.sap.sailing.domain.common.DegreePosition;
|
||||
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 />
|
||||
* Used by {@link ReverseGeocoder}.
|
||||
* @author Lennart Hensler (D054527)
|
||||
*
|
||||
*/
|
||||
public class PlacemarkImpl implements Placemark {
|
||||
|
||||
private String name;
|
||||
private String countryCode;
|
||||
private Position position;
|
||||
private String type;
|
||||
private long population;
|
||||
|
||||
public PlacemarkImpl(String name, String countryCode, Position position, String type, long population) {
|
||||
/**
|
||||
* Creates a new Placemark with the given parameters as attributes.
|
||||
*/
|
||||
public PlacemarkImpl(String name, String countryCode, Position position, long population) {
|
||||
this.name = name;
|
||||
this.countryCode = countryCode;
|
||||
this.position = position;
|
||||
this.type = type;
|
||||
this.population = population;
|
||||
}
|
||||
|
||||
/**
|
||||
* 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, type, 0);
|
||||
this(name, countryCode, position, 0);
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
@@ -38,10 +49,6 @@ public class PlacemarkImpl implements Placemark {
|
||||
return position;
|
||||
}
|
||||
|
||||
public String getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public long getPopulation() {
|
||||
return population;
|
||||
}
|
||||
@@ -68,7 +75,6 @@ public class PlacemarkImpl implements Placemark {
|
||||
b.append(name + ", ");
|
||||
b.append(countryCode + ", ");
|
||||
b.append(position.toString() + ", ");
|
||||
b.append(type + ", ");
|
||||
b.append(population + "]");
|
||||
|
||||
return b.toString();
|
||||
@@ -82,7 +88,6 @@ public class PlacemarkImpl implements Placemark {
|
||||
result = prime * result + ((name == null) ? 0 : name.hashCode());
|
||||
result = prime * result + (int) (population ^ (population >>> 32));
|
||||
result = prime * result + ((position == null) ? 0 : position.hashCode());
|
||||
result = prime * result + ((type == null) ? 0 : type.hashCode());
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -112,11 +117,6 @@ public class PlacemarkImpl implements Placemark {
|
||||
return false;
|
||||
} else if (!position.equals(other.position))
|
||||
return false;
|
||||
if (type == null) {
|
||||
if (other.type != null)
|
||||
return false;
|
||||
} else if (!type.equals(other.type))
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
+1
-2
@@ -137,11 +137,10 @@ public class ReverseGeocoderImpl implements ReverseGeocoder {
|
||||
}
|
||||
Position p = new DegreePosition(latDeg, lngDeg);
|
||||
|
||||
String type = (String) json.get("fcl");
|
||||
long population = (Long) json.get("population");
|
||||
|
||||
if (name != null && lngDeg != null && latDeg != null) {
|
||||
return new PlacemarkImpl(name, countryCode, p, type, population);
|
||||
return new PlacemarkImpl(name, countryCode, p, population);
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user