@Test
public void testCalcDefaultLabelPosition() throws Exception {
Geometry geometry;
GeometryFactory factory = new GeometryFactory(new PrecisionModel(), 4326);
Coordinate coordinate;
InternalFeature feature = new InternalFeatureImpl();
feature.setId("x");
feature.setLabel("Label x");
coordinate = geoService.calcDefaultLabelPosition(feature);
Assert.assertNull(coordinate);
feature.setGeometry(factory.createMultiPolygon(new Polygon[] {}));
coordinate = geoService.calcDefaultLabelPosition(feature);
Assert.assertNull(coordinate);
feature.setGeometry(JTS.toGeometry(new Envelope(10, 20, 30, 40)));
coordinate = geoService.calcDefaultLabelPosition(feature);
// this tests current behaviour, without claims that this is the "best" (or even "good") position
Assert.assertEquals(15.0, coordinate.x, DELTA);
Assert.assertEquals(35.0, coordinate.y, DELTA);
geometry = factory.createLineString(new Coordinate[] { new Coordinate(5,4), new Coordinate(30,10) });
feature.setGeometry(geometry);
coordinate = geoService.calcDefaultLabelPosition(feature);
// this tests current behaviour, without claims that this is the "best" (or even "good") position
Assert.assertEquals(5.0, coordinate.x, DELTA);
Assert.assertEquals(4.0, coordinate.y, DELTA);