diff --git a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/SearchBuilder.java b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/SearchBuilder.java index 7d1eec98499..fa3dbbca590 100644 --- a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/SearchBuilder.java +++ b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/SearchBuilder.java @@ -2123,6 +2123,7 @@ public class SearchBuilder implements ISearchBuilder { } else if (distance < 0.0) { throw new IllegalArgumentException("Invalid " + Location.SP_NEAR_DISTANCE + " parameter '" + distance + "' must be >= 0.0"); } else { + // FIXME KHS scale distance based on lat/long Double latitude = Double.valueOf(latitudeValue); latitudePredicate = theBuilder.and( theBuilder.greaterThanOrEqualTo(theFrom.get("myLatitude"), latitude - distance), diff --git a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/util/CoordCalculator.java b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/util/CoordCalculator.java new file mode 100644 index 00000000000..52fd8f4b307 --- /dev/null +++ b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/util/CoordCalculator.java @@ -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); + } +} diff --git a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/util/CoordCalculatorTest.java b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/util/CoordCalculatorTest.java new file mode 100644 index 00000000000..8fe9c86eb09 --- /dev/null +++ b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/util/CoordCalculatorTest.java @@ -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); + } +}