use of net.opengis.gml._3.DirectPositionListType in project geotoolkit by Geomatys.
the class GeometrytoJTSTest method gmlPolygonToJTSTest2D.
@Test
public void gmlPolygonToJTSTest2D() throws Exception {
GeometryFactory fact = GF;
final Coordinate[] coordinates = new Coordinate[5];
coordinates[0] = new Coordinate(0, 0);
coordinates[1] = new Coordinate(0, 1);
coordinates[2] = new Coordinate(1, 1);
coordinates[3] = new Coordinate(1, 0);
coordinates[4] = new Coordinate(0, 0);
LinearRing linear = GF.createLinearRing(coordinates);
Polygon expected = new Polygon(linear, null, fact);
expected.setSRID(2154);
LinearRingType exterior = new LinearRingType();
List<Double> coords = new ArrayList<>();
coords.add(0.0);
coords.add(0.0);
coords.add(0.0);
coords.add(1.0);
coords.add(1.0);
coords.add(1.0);
coords.add(1.0);
coords.add(0.0);
coords.add(0.0);
coords.add(0.0);
exterior.setPosList(new DirectPositionListType(coords));
PolygonType gml = new PolygonType(exterior, null);
final Geometry result = GeometrytoJTS.toJTS((org.geotoolkit.gml.xml.Polygon) gml);
Assert.assertEquals(expected, result);
}
use of net.opengis.gml._3.DirectPositionListType in project tiamat by entur.
the class LineStringConverter method convertFrom.
@Override
public LineStringType convertFrom(LineString lineString, Type<LineStringType> typ, MappingContext mappingContext) {
LineStringType lineStringType = new LineStringType();
DirectPositionListType directPositionListType = new DirectPositionListType();
if (lineString.getCoordinates() != null) {
logger.debug("Converting coordinates {}", lineString.getCoordinates());
List<Double> positions = directPositionListType.getValue();
for (Coordinate coordinate : lineString.getCoordinates()) {
positions.add(coordinate.y);
positions.add(coordinate.x);
}
directPositionListType.setCount(BigInteger.valueOf(positions.size()));
directPositionListType.setSrsDimension(BigInteger.valueOf(2L));
}
lineStringType.setPosList(directPositionListType);
lineStringType.setId(LineString.class.getSimpleName());
lineStringType.setSrsDimension(BigInteger.valueOf(2L));
return lineStringType;
}
use of net.opengis.gml._3.DirectPositionListType in project tiamat by entur.
the class PathLinkImportTest method publicationDeliveryWithPathLink.
@Test
public void publicationDeliveryWithPathLink() throws Exception {
StopPlace fromStopPlace = new StopPlace().withId("RUT:StopPlace:123123").withVersion("1").withCentroid(new SimplePoint_VersionStructure().withLocation(new LocationStructure().withLatitude(new BigDecimal("9")).withLongitude(new BigDecimal("71"))));
StopPlace toStopPlace = new StopPlace().withId("RUT:StopPlace:321654").withVersion("1").withCentroid(new SimplePoint_VersionStructure().withLocation(new LocationStructure().withLatitude(new BigDecimal("9.6")).withLongitude(new BigDecimal("76"))));
LineStringType lineStringType = new LineStringType().withId("LineString").withPosList(new DirectPositionListType().withSrsDimension(BigInteger.valueOf(new GeometryFactoryConfig().geometryFactory().getSRID())).withValue(9.1, 71.1, 9.5, 74.1));
Duration duration = Duration.ofMillis(10000);
PathLink netexPathLink = new PathLink().withId("NRI:ConnectionLink:762130479_762130479").withVersion("1").withAllowedUse(PathDirectionEnumeration.TWO_WAY).withTransferDuration(new TransferDurationStructure().withDefaultDuration(duration)).withLineString(lineStringType).withFrom(new PathLinkEndStructure().withPlaceRef(new PlaceRefStructure().withRef(fromStopPlace.getId()))).withTo(new PathLinkEndStructure().withPlaceRef(new PlaceRefStructure().withRef(toStopPlace.getId()).withVersion("1")));
PublicationDeliveryStructure publicationDelivery = publicationDeliveryTestHelper.createPublicationDeliveryWithStopPlace(fromStopPlace, toStopPlace);
publicationDeliveryTestHelper.addPathLinks(publicationDelivery, netexPathLink);
PublicationDeliveryStructure response = publicationDeliveryTestHelper.postAndReturnPublicationDelivery(publicationDelivery);
List<PathLink> result = publicationDeliveryTestHelper.extractPathLinks(response);
assertThat(result).as("Expecting path link in return").hasSize(1);
PathLink importedPathLink = result.get(0);
assertThat(importedPathLink.getAllowedUse()).isEqualTo(netexPathLink.getAllowedUse());
assertThat(importedPathLink.getFrom().getPlaceRef().getRef()).contains(fromStopPlace.getClass().getSimpleName());
assertThat(importedPathLink.getTo().getPlaceRef().getRef()).contains(toStopPlace.getClass().getSimpleName());
assertThat(importedPathLink.getTransferDuration().getDefaultDuration()).isEqualTo(duration);
assertThat(importedPathLink.getLineString()).isNotNull();
assertThat(importedPathLink.getLineString().getPosList()).isNotNull();
assertThat(importedPathLink.getLineString().getPosList().getValue()).hasSize(4);
}
use of net.opengis.gml._3.DirectPositionListType in project tiamat by entur.
the class TopographicPlaceImportTest method publicationDeliveryWithTopographicPlaceAndPolygon.
@Test
public void publicationDeliveryWithTopographicPlaceAndPolygon() throws Exception {
List<Double> values = new ArrayList<>();
values.add(9.8468);
values.add(59.2649);
values.add(9.8456);
values.add(59.2654);
values.add(9.8457);
values.add(59.2655);
values.add(9.8443);
values.add(59.2663);
values.add(values.get(0));
values.add(values.get(1));
DirectPositionListType positionList = new DirectPositionListType().withValue(values);
LinearRingType linearRing = new LinearRingType().withPosList(positionList);
PolygonType polygonType = new PolygonType().withId("KVE-07").withExterior(new AbstractRingPropertyType().withAbstractRing(openGisObjectFactory.createLinearRing(linearRing)));
MultilingualString nameDescriptor = new MultilingualString().withValue("Vestfold").withLang("nb");
TopographicPlace topographicPlace = new TopographicPlace().withId("KVE:TopographicPlace:07").withName(nameDescriptor).withVersion("1").withDescriptor(new TopographicPlaceDescriptor_VersionedChildStructure().withName(nameDescriptor)).withTopographicPlaceType(TopographicPlaceTypeEnumeration.COUNTY).withCountryRef(new CountryRef().withValue("NO")).withPolygon(polygonType);
PublicationDeliveryStructure publicationDelivery = publicationDeliveryTestHelper.createPublicationDeliveryTopographicPlace(topographicPlace);
PublicationDeliveryStructure response = publicationDeliveryTestHelper.postAndReturnPublicationDelivery(publicationDelivery);
List<TopographicPlace> result = publicationDeliveryTestHelper.extractTopographicPlace(response);
assertThat(result).as("Expecting topographic place in return").hasSize(1);
TopographicPlace actualTopographicPlace = result.get(0);
assertThat(actualTopographicPlace.getPolygon()).as("polygon must not be null").isNotNull();
List<Double> actualExteriorValues = polygonConverter.extractValues(topographicPlace.getPolygon().getExterior());
assertThat(actualExteriorValues).isEqualTo(values);
assertThat(actualTopographicPlace.getId()).isEqualTo(topographicPlace.getId());
}
use of net.opengis.gml._3.DirectPositionListType in project tiamat by entur.
the class PolygonConverterTest method convertFrom.
@Test
public void convertFrom() throws Exception {
List<Double> values = new ArrayList<>();
values.add(9.8468);
values.add(59.2649);
values.add(9.8456);
values.add(59.2654);
values.add(9.8457);
values.add(59.2655);
values.add(values.get(0));
values.add(values.get(1));
DirectPositionListType positionList = new DirectPositionListType().withValue(values);
LinearRingType linearRing = new LinearRingType().withPosList(positionList);
PolygonType polygonType = new PolygonType().withId("KVE-07").withExterior(new AbstractRingPropertyType().withAbstractRing(openGisObjectFactory.createLinearRing(linearRing)));
Polygon polygon = polygonConverter.convertFrom(polygonType, new TypeBuilder<Polygon>() {
}.build(), new MappingContext(new HashMap<>()));
assertThat(polygon).isExactlyInstanceOf(Polygon.class).isNotNull();
assertThat(polygon.getExteriorRing().getCoordinates()).hasSize(values.size() / 2);
assertCoordinatesMatch(polygon.getExteriorRing(), values, "Exterior ring");
}
Aggregations