GeoToWktConverter { public static String convertToWktString(Geoshape fieldValue) throws BackendException { if (fieldValue.getType() == Geoshape.Type.POINT) { Geoshape.Point point = fieldValue.getPoint(); return "POINT(" + point.getLongitude() + " " + point.getLatitude() + ")"; } else { throw new PermanentBackendException("Cannot index " + fieldValue.getType()); } }  static String convertToWktString(Geoshape fieldValue);  }
@Test public void testConvertGeoshapePointToWktString() throws BackendException { Geoshape p1 = Geoshape.point(35.4, 48.9); Geoshape p2 = Geoshape.point(-35.4,48.9); Geoshape p3 = Geoshape.point(35.4, -48.9); String wkt1 = "POINT(48.9 35.4)"; String actualWkt1 = GeoToWktConverter.convertToWktString(p1); String wkt2 = "POINT(48.9 -35.4)"; String actualWkt2 = GeoToWktConverter.convertToWktString(p2); String wkt3 = "POINT(-48.9 35.4)"; String actualWkt3 = GeoToWktConverter.convertToWktString(p3); assertEquals(wkt1, actualWkt1); assertEquals(wkt2, actualWkt2); assertEquals(wkt3, actualWkt3); }