use of org.opentripplanner.geocoder.Geocoder in project OpenTripPlanner by opentripplanner.
the class GeocoderServerTest method testGeocodeValidAddress.
@Test
public void testGeocodeValidAddress() {
final double lat = 78.121;
final double lng = -43.237;
final String description = "121 elm street";
geocoderServer.geocoder = new Geocoder() {
@Override
public GeocoderResults geocode(String address, Envelope bbox) {
GeocoderResult result = new GeocoderResult(lat, lng, description);
return new GeocoderResults(Arrays.asList(result));
}
};
GeocoderResults results = geocoderServer.geocode("121 elm street", null);
for (GeocoderResult result : results.getResults()) {
// should only have one result
assertEquals("description matches", description, result.getDescription());
assertEquals(lat, result.getLat(), 0.001);
assertEquals(lng, result.getLng(), 0.001);
}
}
use of org.opentripplanner.geocoder.Geocoder in project OpenTripPlanner by opentripplanner.
the class GeocoderServerTest method testGeocodeInvalidAddress.
@Test
public void testGeocodeInvalidAddress() {
final String error = "uh oh";
geocoderServer.geocoder = new Geocoder() {
@Override
public GeocoderResults geocode(String address, Envelope bbox) {
return new GeocoderResults(error);
}
};
GeocoderResults result = geocoderServer.geocode("121 elm street", null);
assertEquals("error returned", error, result.getError());
}
Aggregations