use of net.opengis.gml.v_3_2_1.LineStringType in project arctic-sea by 52North.
the class AbstractRectifiedGridCoverageTypeEncoder method encodeDomainSet.
private XmlObject encodeDomainSet(RectifiedGridCoverage rectifiedGridCoverage) {
List<ComparableValue<?, ?>> domainSet = rectifiedGridCoverage.getDomainSet();
if (!checkForRange(domainSet)) {
SimpleMultiPointDocument smpd = SimpleMultiPointDocument.Factory.newInstance();
SimpleMultiPointType smpt = smpd.addNewSimpleMultiPoint();
smpt.setId("smp_" + rectifiedGridCoverage.getGmlId());
DirectPositionListType dplt = smpt.addNewPosList();
List<String> uoms = getUoms(domainSet);
if (!uoms.isEmpty()) {
dplt.setUomLabels(Lists.newArrayList(uoms));
}
dplt.setListValue(getList(rectifiedGridCoverage.getDomainSet()));
return smpd;
} else {
LineStringDocument lsd = LineStringDocument.Factory.newInstance();
LineStringType lst = lsd.addNewLineString();
lst.setId("ls_" + rectifiedGridCoverage.getGmlId());
lst.setUomLabels(getUoms(domainSet));
for (ComparableValue<?, ?> quantityValued : domainSet) {
Object value = quantityValued.getValue();
if (value instanceof Double) {
lst.addNewPos().setListValue(Lists.newArrayList((Double) value));
} else if (value instanceof RangeValue) {
lst.addNewPos().setListValue(((RangeValue) value).getRangeAsList());
}
}
return lsd;
}
}
use of net.opengis.gml.v_3_2_1.LineStringType in project geo-platform by geosdi.
the class GMLLineStringGeoJsonParserTest method lineStringGeoJsonParserTest.
@Test
public void lineStringGeoJsonParserTest() throws Exception {
LineStringType lineStringType = jaxbContextBuilder.unmarshal(new File(dirFiles.concat("LineString.xml")), LineStringType.class);
logger.info("#######################LINE_STRING_AS_GEOJSON : \n{}\n", mapper.writeValueAsString(lineParser.parseGeometryAsGeoJson(lineStringType)));
}
use of net.opengis.gml.v_3_2_1.LineStringType 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.v_3_2_1.LineStringType 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.v_3_2_1.LineStringType in project tiamat by entur.
the class LineStringConverterTest method convertFromLineStringToNetexGmlLineStringType.
@Test
public void convertFromLineStringToNetexGmlLineStringType() throws Exception {
Coordinate[] coordinates = new Coordinate[2];
coordinates[0] = new Coordinate(11, 60);
coordinates[1] = new Coordinate(11.1, 60.1);
CoordinateSequence points = new CoordinateArraySequence(coordinates);
LineString lineString = new LineString(points, geometryFactory);
LineStringType gisLineString = lineStringConverter.convertFrom(lineString, new TypeBuilder<LineStringType>() {
}.build(), mappingContext);
assertThat(gisLineString).isNotNull();
assertThat(gisLineString.getPosList().getCount().intValue()).isEqualTo(4);
assertThat(gisLineString.getId()).isNotEmpty();
// Check that the format is Y,X
assertThat(gisLineString.getPosList().getValue().get(0)).isEqualTo(coordinates[0].y);
assertThat(gisLineString.getPosList().getValue().get(1)).isEqualTo(coordinates[0].x);
assertThat(gisLineString.getPosList().getValue().get(2)).isEqualTo(coordinates[1].y);
assertThat(gisLineString.getPosList().getValue().get(3)).isEqualTo(coordinates[1].x);
assertThat(gisLineString.getSrsDimension().intValue()).isEqualTo(2);
}
Aggregations