Search in sources :

Example 21 with LineStringType

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;
    }
}
Also used : SimpleMultiPointType(net.opengis.gml.x33.ce.SimpleMultiPointType) DirectPositionListType(net.opengis.gml.x32.DirectPositionListType) LineStringType(net.opengis.gml.x32.LineStringType) ComparableValue(org.n52.shetland.ogc.om.values.ComparableValue) RangeValue(org.n52.shetland.ogc.swe.RangeValue) SimpleMultiPointDocument(net.opengis.gml.x33.ce.SimpleMultiPointDocument) LineStringDocument(net.opengis.gml.x32.LineStringDocument) XmlObject(org.apache.xmlbeans.XmlObject)

Example 22 with LineStringType

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)));
}
Also used : LineStringType(org.geosdi.geoplatform.xml.gml.v311.LineStringType) File(java.io.File) Test(org.junit.Test)

Example 23 with 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;
}
Also used : Coordinate(org.locationtech.jts.geom.Coordinate) LineString(org.locationtech.jts.geom.LineString) DirectPositionListType(net.opengis.gml._3.DirectPositionListType) LineStringType(net.opengis.gml._3.LineStringType)

Example 24 with 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);
}
Also used : StopPlace(org.rutebanken.netex.model.StopPlace) DirectPositionListType(net.opengis.gml._3.DirectPositionListType) PublicationDeliveryStructure(org.rutebanken.netex.model.PublicationDeliveryStructure) SimplePoint_VersionStructure(org.rutebanken.netex.model.SimplePoint_VersionStructure) Duration(java.time.Duration) PlaceRefStructure(org.rutebanken.netex.model.PlaceRefStructure) LineStringType(net.opengis.gml._3.LineStringType) TransferDurationStructure(org.rutebanken.netex.model.TransferDurationStructure) LocationStructure(org.rutebanken.netex.model.LocationStructure) BigDecimal(java.math.BigDecimal) GeometryFactoryConfig(org.rutebanken.tiamat.config.GeometryFactoryConfig) PathLink(org.rutebanken.netex.model.PathLink) PathLinkEndStructure(org.rutebanken.netex.model.PathLinkEndStructure) Test(org.junit.Test) TiamatIntegrationTest(org.rutebanken.tiamat.TiamatIntegrationTest)

Example 25 with LineStringType

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);
}
Also used : CoordinateSequence(org.locationtech.jts.geom.CoordinateSequence) DoubleValuesToCoordinateSequence(org.rutebanken.tiamat.geo.DoubleValuesToCoordinateSequence) Coordinate(org.locationtech.jts.geom.Coordinate) LineString(org.locationtech.jts.geom.LineString) TypeBuilder(ma.glasnost.orika.metadata.TypeBuilder) LineStringType(net.opengis.gml._3.LineStringType) CoordinateArraySequence(org.locationtech.jts.geom.impl.CoordinateArraySequence) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)11 LineString (org.locationtech.jts.geom.LineString)9 Coordinate (org.locationtech.jts.geom.Coordinate)7 ArrayList (java.util.ArrayList)6 JAXBElement (javax.xml.bind.JAXBElement)6 Geometry (org.locationtech.jts.geom.Geometry)6 LineStringType (net.opengis.gml._3.LineStringType)5 LineStringType (net.opengis.gml.v_3_2_1.LineStringType)5 LineStringType (ogc.schema.opengis.gml.v_2_1_2.LineStringType)5 MultiLineStringType (ogc.schema.opengis.gml.v_2_1_2.MultiLineStringType)5 LineString (com.vividsolutions.jts.geom.LineString)4 MultiLineString (com.vividsolutions.jts.geom.MultiLineString)4 List (java.util.List)4 DirectPositionListType (net.opengis.gml._3.DirectPositionListType)4 LineStringType (net.opengis.gml.v_3_1_1.LineStringType)3 LineStringType (org.geotoolkit.gml.xml.v311.LineStringType)3 MultiPoint (org.locationtech.jts.geom.MultiPoint)3 Point (org.locationtech.jts.geom.Point)3 BigDecimal (java.math.BigDecimal)2 TypeBuilder (ma.glasnost.orika.metadata.TypeBuilder)2