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));
}
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);
}
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);
}
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);
}
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);
}
}
}
Aggregations