diff --git a/src/test/java/org/javarosa/core/util/GeoDistanceTest.java b/src/test/java/org/javarosa/core/util/GeoDistanceTest.java index 574eb9d9b..b97eb1a4d 100644 --- a/src/test/java/org/javarosa/core/util/GeoDistanceTest.java +++ b/src/test/java/org/javarosa/core/util/GeoDistanceTest.java @@ -209,23 +209,25 @@ public void distance_throwsForNonPoint() throws IOException, XFormParser.ParseEx } @Test - public void distance_isComputedForMultipleArguments() throws IOException, XFormParser.ParseException { + public void distance_isComputedForMultiplePathArguments() throws IOException, XFormParser.ParseException { Scenario scenario = Scenario.init("string distance", html( head( title("Multi parameter distance"), model( mainInstance(t("data id=\"string-distance\"", t("point1", "38.253094215699576 21.756382658677467 0 0"), + t("point2", "38.25021274773806 21.756382658677467 0 0"), t("point3", "38.25007793942195 21.763892843919166 0 0"), t("point4", "38.25290886154963 21.763935759263404 0 0"), t("point5", "38.25146813817506 21.758421137528785 0 0"), t("distance") )), bind("/data/point1").type("geopoint"), + bind("/data/point2").type("geopoint"), bind("/data/point3").type("geopoint"), bind("/data/point4").type("geopoint"), bind("/data/point5").type("geopoint"), - bind("/data/distance").type("decimal").calculate("distance(/data/point1, '38.25021274773806 21.756382658677467 0 0', /data/point3, /data/point4, /data/point5)") + bind("/data/distance").type("decimal").calculate("distance(/data/point1, /data/point2, /data/point3, /data/point4, /data/point5)") )), body( input("/data/point1") @@ -237,6 +239,33 @@ public void distance_isComputedForMultipleArguments() throws IOException, XFormP IsCloseTo.closeTo(1801, 0.5)); } + @Test + public void distance_isComputedForMixedPathAndStringArguments() throws IOException, XFormParser.ParseException { + Scenario scenario = Scenario.init("string distance", html( + head( + title("Multi parameter distance"), + model( + mainInstance(t("data id=\"string-distance\"", + t("point2", "38.25021274773806 21.756382658677467 0 0"), + t("point3", "38.25007793942195 21.763892843919166 0 0"), + t("point5", "38.25146813817506 21.758421137528785 0 0"), + t("distance") + )), + bind("/data/point2").type("geopoint"), + bind("/data/point3").type("geopoint"), + bind("/data/point5").type("geopoint"), + bind("/data/distance").type("decimal").calculate("distance('38.253094215699576 21.756382658677467 0 0', /data/point2, /data/point3, '38.25290886154963 21.763935759263404 0 0', /data/point5)") + )), + body( + input("/data/point2") + ) + )); + + // http://www.mapdevelopers.com/area_finder.php?&points=%5B%5B38.253094215699576%2C21.756382658677467%5D%2C%5B38.25021274773806%2C21.756382658677467%5D%2C%5B38.25007793942195%2C21.763892843919166%5D%2C%5B38.25290886154963%2C21.763935759263404%5D%2C%5B38.25146813817506%2C21.758421137528785%5D%5D + assertThat(Double.parseDouble(scenario.answerOf("/data/distance").getDisplayText()), + IsCloseTo.closeTo(1801, 0.5)); + } + @Test public void distance_whenTraceHasFewerThanTwoPoints_isZero() throws Exception { Scenario scenario = Scenario.init("geotrace distance", html(