use of ma.glasnost.orika.metadata.TypeBuilder in project tiamat by entur.
the class PolygonConverterTest method convertToWithHoles.
@Test
public void convertToWithHoles() throws Exception {
Coordinate[] coordinates = new Coordinate[] { new Coordinate(9.8468, 59.2649), new Coordinate(9.8456, 59.2654), new Coordinate(9.8457, 59.2655), new Coordinate(9.8468, 59.2649) };
LinearRing linearRing = new LinearRing(new CoordinateArraySequence(coordinates), geometryFactory);
LinearRing[] holes = new LinearRing[] { new LinearRing(new CoordinateArraySequence(coordinates), geometryFactory) };
Polygon polygon = new Polygon(linearRing, holes, geometryFactory);
PolygonType actual = polygonConverter.convertTo(polygon, new TypeBuilder<PolygonType>() {
}.build(), new MappingContext(new HashMap<>()));
assertThat(actual).isNotNull();
List<Double> actualDoublevalues = polygonConverter.extractValues(actual.getExterior());
assertThat(actualDoublevalues).hasSize(coordinates.length * 2);
List<Double> actualHoleDoubleValues = polygonConverter.extractValues(actual.getInterior().get(0));
assertThat(actualHoleDoubleValues).hasSize(coordinates.length * 2);
}
use of ma.glasnost.orika.metadata.TypeBuilder in project tiamat by entur.
the class PolygonConverterTest method convertTo.
@Test
public void convertTo() throws Exception {
Coordinate[] coordinates = new Coordinate[] { new Coordinate(9.8468, 59.2649), new Coordinate(9.8456, 59.2654), new Coordinate(9.8457, 59.2655), new Coordinate(9.8468, 59.2649) };
LinearRing linearRing = new LinearRing(new CoordinateArraySequence(coordinates), geometryFactory);
Polygon polygon = new Polygon(linearRing, null, geometryFactory);
PolygonType actual = polygonConverter.convertTo(polygon, new TypeBuilder<PolygonType>() {
}.build(), new MappingContext(new HashMap<>()));
assertThat(actual).isNotNull();
assertThat(actual.getId()).isNotEmpty();
List<Double> values = polygonConverter.extractValues(actual.getExterior());
assertThat(values).hasSize(coordinates.length * 2);
// Tiamat is storing polygons with X, Y
// In NeTEx we receive polygons with Y, X
// Expect Y, X when converting to PolygonType (Netex)
int counter = 0;
for (Coordinate coordinate : coordinates) {
assertThat(values.get(counter++).doubleValue()).isEqualTo(coordinate.y);
assertThat(values.get(counter++).doubleValue()).isEqualTo(coordinate.x);
}
}
Aggregations