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 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 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);
}
}
}
use of org.rutebanken.netex.model.LocationStructure in project tiamat by entur.
the class FareZoneImportTest method publicationDeliveryWithFareZoneAndStopPlaceMergeZonesImportTypeMatch.
@Test
public void publicationDeliveryWithFareZoneAndStopPlaceMergeZonesImportTypeMatch() throws Exception {
SimplePoint_VersionStructure point = new SimplePoint_VersionStructure().withLocation(new LocationStructure().withLatitude(new BigDecimal("9.6")).withLongitude(new BigDecimal("76")));
List<JAXBElement<? extends Zone_VersionStructure>> tariffZones1 = new ArrayList<>();
FareZone fareZone1 = new FareZone().withName(new MultilingualString().withValue("V02")).withVersion("1").withId("RUT:FareZone:01");
tariffZones1.add(new ObjectFactory().createFareZone(fareZone1));
StopPlace stopPlace = new StopPlace().withId("RUT:StopPlace:321").withName(new MultilingualString().withValue("name")).withCentroid(point).withVersion("1").withStopPlaceType(StopTypeEnumeration.ONSTREET_BUS).withTariffZones(new TariffZoneRefs_RelStructure().withTariffZoneRef(new TariffZoneRef().withVersion(fareZone1.getVersion()).withRef(fareZone1.getId())));
SiteFrame siteFrame = publicationDeliveryTestHelper.siteFrame().withTariffZones(new TariffZonesInFrame_RelStructure().withTariffZone(tariffZones1)).withStopPlaces(new StopPlacesInFrame_RelStructure().withStopPlace(stopPlace));
PublicationDeliveryStructure publicationDeliveryStructure = publicationDeliveryTestHelper.publicationDelivery(siteFrame);
ImportParams importParams = new ImportParams();
importParams.importType = ImportType.INITIAL;
// First
publicationDeliveryTestHelper.postAndReturnPublicationDelivery(publicationDeliveryStructure, importParams);
List<JAXBElement<? extends Zone_VersionStructure>> tariffZones2 = new ArrayList<>();
FareZone fareZone2 = new FareZone().withName(new MultilingualString().withValue("X09")).withVersion("1").withId("BRA:FareZone:02");
tariffZones2.add(new ObjectFactory().createFareZone(fareZone2));
stopPlace.withId("BRA:Stopplace:3").withTariffZones(new TariffZoneRefs_RelStructure().withTariffZoneRef(new TariffZoneRef().withVersion(fareZone2.getVersion()).withRef(fareZone2.getId())));
SiteFrame siteFrame2 = publicationDeliveryTestHelper.siteFrame().withTariffZones(new TariffZonesInFrame_RelStructure().withTariffZone(tariffZones2)).withStopPlaces(new StopPlacesInFrame_RelStructure().withStopPlace(stopPlace));
PublicationDeliveryStructure publicationDeliveryStructure2 = publicationDeliveryTestHelper.publicationDelivery(siteFrame2);
// Second import should match and merge farezones
importParams.importType = ImportType.MATCH;
PublicationDeliveryStructure response = publicationDeliveryTestHelper.postAndReturnPublicationDelivery(publicationDeliveryStructure2, importParams);
List<JAXBElement<? extends Zone_VersionStructure>> actualZones = publicationDeliveryTestHelper.findSiteFrame(response).getTariffZones().getTariffZone();
assertThat(actualZones).isNotEmpty();
assertThat(actualZones).hasSize(2);
}
use of org.rutebanken.netex.model.LocationStructure in project tiamat by entur.
the class ImportResourceTest method maxNumberOfDigitsInCoordinatesShouldBeSix.
@Test
public void maxNumberOfDigitsInCoordinatesShouldBeSix() throws Exception {
final int maxdigits = 6;
StopPlace stopPlace = new StopPlace().withId("XYZ:StopPlace:91").withVersion("1").withCentroid(new SimplePoint_VersionStructure().withLocation(new LocationStructure().withLatitude(new BigDecimal("10.123456789123456789123456789")).withLongitude(new BigDecimal("20.123456789123456789123456789")))).withQuays(new Quays_RelStructure().withQuayRefOrQuay(new Quay().withId("XYZ:Quay:91").withVersion("1").withName(new MultilingualString().withValue("quay number one")).withCentroid(new SimplePoint_VersionStructure().withVersion("1").withLocation(new LocationStructure().withLatitude(new BigDecimal("10.123456789123456789123456789")).withLongitude(new BigDecimal("20.123456789123456789123456789"))))));
PublicationDeliveryStructure publicationDelivery = publicationDeliveryTestHelper.createPublicationDeliveryWithStopPlace(stopPlace);
PublicationDeliveryStructure firstResponse = publicationDeliveryTestHelper.postAndReturnPublicationDelivery(publicationDelivery);
StopPlace actualStopPlace = publicationDeliveryTestHelper.findFirstStopPlace(firstResponse);
BigDecimal longitude = actualStopPlace.getCentroid().getLocation().getLongitude();
BigDecimal latitude = actualStopPlace.getCentroid().getLocation().getLatitude();
assertThat(String.valueOf(longitude).split("\\.")[1].length()).as("longitude decimals length").isLessThanOrEqualTo(maxdigits);
assertThat(String.valueOf(latitude).split("\\.")[1].length()).as("latitude decimals length").isLessThanOrEqualTo(maxdigits);
}
Aggregations