begin with failing test
This commit is contained in:
parent
b07b87954d
commit
8b8088a3a2
|
@ -2123,6 +2123,7 @@ public class SearchBuilder implements ISearchBuilder {
|
||||||
} else if (distance < 0.0) {
|
} else if (distance < 0.0) {
|
||||||
throw new IllegalArgumentException("Invalid " + Location.SP_NEAR_DISTANCE + " parameter '" + distance + "' must be >= 0.0");
|
throw new IllegalArgumentException("Invalid " + Location.SP_NEAR_DISTANCE + " parameter '" + distance + "' must be >= 0.0");
|
||||||
} else {
|
} else {
|
||||||
|
// FIXME KHS scale distance based on lat/long
|
||||||
Double latitude = Double.valueOf(latitudeValue);
|
Double latitude = Double.valueOf(latitudeValue);
|
||||||
latitudePredicate = theBuilder.and(
|
latitudePredicate = theBuilder.and(
|
||||||
theBuilder.greaterThanOrEqualTo(theFrom.get("myLatitude"), latitude - distance),
|
theBuilder.greaterThanOrEqualTo(theFrom.get("myLatitude"), latitude - distance),
|
||||||
|
|
|
@ -0,0 +1,13 @@
|
||||||
|
package ca.uhn.fhir.jpa.util;
|
||||||
|
|
||||||
|
import org.springframework.data.geo.Point;
|
||||||
|
|
||||||
|
public class CoordCalculator {
|
||||||
|
public static Point findTarget(double theLatitude, double theLongitude, double theBearing, double theDistance) {
|
||||||
|
double x;
|
||||||
|
double y;
|
||||||
|
x = theLatitude;
|
||||||
|
y = theLatitude;
|
||||||
|
return new Point(x, y);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,20 @@
|
||||||
|
package ca.uhn.fhir.jpa.util;
|
||||||
|
|
||||||
|
import org.junit.Test;
|
||||||
|
import org.springframework.data.geo.Point;
|
||||||
|
|
||||||
|
import static org.junit.Assert.*;
|
||||||
|
|
||||||
|
public class CoordCalculatorTest {
|
||||||
|
@Test
|
||||||
|
public void testCoordCalculator() {
|
||||||
|
double latitude = 52.20472;
|
||||||
|
double longitude = 0.14056;
|
||||||
|
double bearing = 1.57;
|
||||||
|
double distance = 15.0;
|
||||||
|
|
||||||
|
Point result = CoordCalculator.findTarget(latitude, longitude, bearing, distance);
|
||||||
|
assertEquals(52.20444, result.getX(), 0.00001);
|
||||||
|
assertEquals(0.36056, result.getX(), 0.00001);
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue