Search in sources :

Example 21 with LocationStructure

use of org.rutebanken.netex.model.LocationStructure in project tiamat by entur.

the class StopPlaceMatchingTest method matchImportedStopWithoutLeadingZeroOriginalId.

@Test
public void matchImportedStopWithoutLeadingZeroOriginalId() throws Exception {
    StopPlace stopPlaceToBeMatched = new StopPlace().withId("RUT:StopPlace:0111111111").withVersion("1").withCentroid(new SimplePoint_VersionStructure().withLocation(new LocationStructure().withLatitude(new BigDecimal("11")).withLongitude(new BigDecimal("77"))));
    ImportParams importParams = new ImportParams();
    importParams.importType = ImportType.INITIAL;
    PublicationDeliveryStructure publicationDelivery = publicationDeliveryTestHelper.createPublicationDeliveryWithStopPlace(stopPlaceToBeMatched);
    publicationDeliveryTestHelper.postAndReturnPublicationDelivery(publicationDelivery, importParams);
    // match even without leading zero and different prefix
    stopPlaceToBeMatched.setId("AKT:StopPlace:111111111");
    PublicationDeliveryStructure publicationDelivery2 = publicationDeliveryTestHelper.createPublicationDeliveryWithStopPlace(stopPlaceToBeMatched);
    importParams.importType = ImportType.ID_MATCH;
    PublicationDeliveryStructure response = publicationDeliveryTestHelper.postAndReturnPublicationDelivery(publicationDelivery2, importParams);
    System.out.println("Got response: \n" + response);
    List<StopPlace> result = publicationDeliveryTestHelper.extractStopPlaces(response);
    assertThat(result).hasSize(1);
    publicationDeliveryTestHelper.hasOriginalId("RUT:StopPlace:0111111111", result.get(0));
}
Also used : StopPlace(org.rutebanken.netex.model.StopPlace) ImportParams(org.rutebanken.tiamat.importer.ImportParams) PublicationDeliveryStructure(org.rutebanken.netex.model.PublicationDeliveryStructure) SimplePoint_VersionStructure(org.rutebanken.netex.model.SimplePoint_VersionStructure) LocationStructure(org.rutebanken.netex.model.LocationStructure) BigDecimal(java.math.BigDecimal) Test(org.junit.Test) TiamatIntegrationTest(org.rutebanken.tiamat.TiamatIntegrationTest)

Example 22 with LocationStructure

use of org.rutebanken.netex.model.LocationStructure in project tiamat by entur.

the class SimplePointVersionStructureConverterTest method nullCheckLongitude.

@Test
public void nullCheckLongitude() {
    SimplePoint_VersionStructure simplePointversionStructure = new SimplePoint_VersionStructure().withLocation(new LocationStructure().withLatitude(BigDecimal.valueOf(10.00)));
    simplePointVersionStructureConverter.convertFrom(simplePointversionStructure, pointType, mappingContext);
}
Also used : SimplePoint_VersionStructure(org.rutebanken.netex.model.SimplePoint_VersionStructure) LocationStructure(org.rutebanken.netex.model.LocationStructure) Test(org.junit.Test)

Example 23 with LocationStructure

use of org.rutebanken.netex.model.LocationStructure in project OpenTripPlanner by opentripplanner.

the class WgsCoordinateMapperTest method handleCoordinatesWithMissingLongitude.

@Test(expected = IllegalArgumentException.class)
public void handleCoordinatesWithMissingLongitude() {
    SimplePoint_VersionStructure p;
    p = new SimplePoint_VersionStructure().withLocation(new LocationStructure().withLatitude(LATITUDE));
    WgsCoordinateMapper.mapToDomain(p);
}
Also used : SimplePoint_VersionStructure(org.rutebanken.netex.model.SimplePoint_VersionStructure) LocationStructure(org.rutebanken.netex.model.LocationStructure) Test(org.junit.Test)

Example 24 with LocationStructure

use of org.rutebanken.netex.model.LocationStructure in project OpenTripPlanner by opentripplanner.

the class WgsCoordinateMapperTest method handleCoordinatesWithValuesSet.

@Test
public void handleCoordinatesWithValuesSet() {
    // Given a valid point
    final SimplePoint_VersionStructure point = new SimplePoint_VersionStructure().withLocation(new LocationStructure().withLongitude(LONGITUDE).withLatitude(LATITUDE));
    // When map coordinates
    WgsCoordinate c = WgsCoordinateMapper.mapToDomain(point);
    // Then verify coordinate
    assertEquals(LONGITUDE_VALUE, c.longitude(), DELTA);
    assertEquals(LATITUDE_VALUE, c.latitude(), DELTA);
}
Also used : WgsCoordinate(org.opentripplanner.model.WgsCoordinate) SimplePoint_VersionStructure(org.rutebanken.netex.model.SimplePoint_VersionStructure) LocationStructure(org.rutebanken.netex.model.LocationStructure) Test(org.junit.Test)

Example 25 with LocationStructure

use of org.rutebanken.netex.model.LocationStructure in project tiamat by entur.

the class QuayMapper method mapBtoA.

@Override
public void mapBtoA(org.rutebanken.tiamat.model.Quay quay, Quay quay2, MappingContext context) {
    super.mapBtoA(quay, quay2, context);
    if (quay.getPlaceEquipments() != null && quay.getPlaceEquipments().getInstalledEquipment() != null && quay.getPlaceEquipments().getInstalledEquipment().isEmpty()) {
        quay.setPlaceEquipments(null);
        quay2.setPlaceEquipments(null);
    }
    if (quay.getAlternativeNames() != null && !quay.getAlternativeNames().isEmpty()) {
        List<AlternativeName> alternativeNames = quay.getAlternativeNames();
        List<org.rutebanken.netex.model.AlternativeName> netexAlternativeNames = new ArrayList<>();
        for (org.rutebanken.tiamat.model.AlternativeName alternativeName : alternativeNames) {
            if (alternativeName != null && alternativeName.getName() != null && alternativeName.getName().getValue() != null && !alternativeName.getName().getValue().isEmpty()) {
                // Only include non-empty alternative names
                org.rutebanken.netex.model.AlternativeName netexAltName = new org.rutebanken.netex.model.AlternativeName();
                mapperFacade.map(alternativeName, netexAltName);
                netexAltName.setId(alternativeName.getNetexId());
                netexAlternativeNames.add(netexAltName);
            }
        }
        if (!netexAlternativeNames.isEmpty()) {
            AlternativeNames_RelStructure altName = new AlternativeNames_RelStructure();
            altName.getAlternativeName().addAll(netexAlternativeNames);
            quay2.setAlternativeNames(altName);
        }
    } else {
        quay2.setAlternativeNames(null);
    }
    if (quay.getBoardingPositions() != null && !quay.getBoardingPositions().isEmpty()) {
        final List<BoardingPosition> boardingPositions = quay.getBoardingPositions();
        List<org.rutebanken.netex.model.BoardingPosition> netexBoardingPositions = new ArrayList<>();
        for (BoardingPosition boardingPosition : boardingPositions) {
            if (boardingPosition != null && boardingPosition.getPublicCode() != null && !boardingPosition.getPublicCode().isEmpty()) {
                // Only Include non-empty boarding-positions
                final org.rutebanken.netex.model.BoardingPosition netexBoardingPosition = new org.rutebanken.netex.model.BoardingPosition();
                mapperFacade.map(boardingPosition, netexBoardingPosition);
                netexBoardingPosition.setId(boardingPosition.getNetexId());
                netexBoardingPosition.setPublicCode(boardingPosition.getPublicCode());
                if (boardingPosition.getCentroid() != null) {
                    SimplePoint_VersionStructure simplePoint = new SimplePoint_VersionStructure().withLocation(new LocationStructure().withLatitude(BigDecimal.valueOf(boardingPosition.getCentroid().getY())).withLongitude(BigDecimal.valueOf(boardingPosition.getCentroid().getX())));
                    netexBoardingPosition.setCentroid(simplePoint);
                }
                netexBoardingPositions.add(netexBoardingPosition);
            }
        }
        if (!netexBoardingPositions.isEmpty()) {
            final BoardingPositions_RelStructure boardingPositionsRelStructure = new BoardingPositions_RelStructure();
            boardingPositionsRelStructure.getBoardingPositionRefOrBoardingPosition().addAll(netexBoardingPositions);
            quay2.setBoardingPositions(boardingPositionsRelStructure);
        }
    }
}
Also used : AlternativeNames_RelStructure(org.rutebanken.netex.model.AlternativeNames_RelStructure) ArrayList(java.util.ArrayList) AlternativeName(org.rutebanken.tiamat.model.AlternativeName) SimplePoint_VersionStructure(org.rutebanken.netex.model.SimplePoint_VersionStructure) LocationStructure(org.rutebanken.netex.model.LocationStructure) AlternativeName(org.rutebanken.tiamat.model.AlternativeName) BoardingPosition(org.rutebanken.tiamat.model.BoardingPosition) BoardingPositions_RelStructure(org.rutebanken.netex.model.BoardingPositions_RelStructure)

Aggregations

LocationStructure (org.rutebanken.netex.model.LocationStructure)47 SimplePoint_VersionStructure (org.rutebanken.netex.model.SimplePoint_VersionStructure)47 Test (org.junit.Test)44 BigDecimal (java.math.BigDecimal)37 PublicationDeliveryStructure (org.rutebanken.netex.model.PublicationDeliveryStructure)36 StopPlace (org.rutebanken.netex.model.StopPlace)36 TiamatIntegrationTest (org.rutebanken.tiamat.TiamatIntegrationTest)35 MultilingualString (org.rutebanken.netex.model.MultilingualString)31 ImportParams (org.rutebanken.tiamat.importer.ImportParams)21 Quay (org.rutebanken.netex.model.Quay)16 Quays_RelStructure (org.rutebanken.netex.model.Quays_RelStructure)16 ArrayList (java.util.ArrayList)11 LocalDateTime (java.time.LocalDateTime)9 ValidBetween (org.rutebanken.netex.model.ValidBetween)8 Response (javax.ws.rs.core.Response)7 KeyValueStructure (org.rutebanken.netex.model.KeyValueStructure)7 Sets (com.google.common.collect.Sets)6 ByteArrayInputStream (java.io.ByteArrayInputStream)6 ByteArrayOutputStream (java.io.ByteArrayOutputStream)6 IOException (java.io.IOException)6