Search in sources :

Example 1 with LocationStructure

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

the class WgsCoordinateMapperTest method handleCoordinatesWithMissingLatitude.

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

Example 2 with LocationStructure

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

the class SimplePointVersionStructureConverter method convertTo.

@Override
public SimplePoint_VersionStructure convertTo(Point point, Type<SimplePoint_VersionStructure> type, MappingContext mappingContext) {
    if (point == null) {
        return null;
    }
    BigDecimal longitude = round(BigDecimal.valueOf(point.getX()));
    BigDecimal latitude = round(BigDecimal.valueOf(point.getY()));
    return new SimplePoint_VersionStructure().withLocation(new LocationStructure().withLongitude(longitude).withLatitude(latitude));
}
Also used : SimplePoint_VersionStructure(org.rutebanken.netex.model.SimplePoint_VersionStructure) LocationStructure(org.rutebanken.netex.model.LocationStructure) BigDecimal(java.math.BigDecimal)

Example 3 with LocationStructure

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

the class ExportResourceTest method exportStopPlacesWithEffectiveChangedInPeriod.

@Test
public void exportStopPlacesWithEffectiveChangedInPeriod() throws Exception {
    LocalDateTime validFrom = LocalDateTime.now().minusDays(3);
    StopPlace stopPlace1 = new StopPlace().withId("XYZ:Stopplace:1").withVersion("1").withName(new MultilingualString().withValue("Changed stop1")).withValidBetween(new ValidBetween().withFromDate(validFrom)).withCentroid(new SimplePoint_VersionStructure().withLocation(new LocationStructure().withLatitude(new BigDecimal("59.914353")).withLongitude(new BigDecimal("10.806387"))));
    StopPlace stopPlace2 = new StopPlace().withId("XYZ:Stopplace:2").withVersion("1").withName(new MultilingualString().withValue("Changed stop2")).withValidBetween(new ValidBetween().withFromDate(validFrom.plusDays(1))).withCentroid(new SimplePoint_VersionStructure().withLocation(new LocationStructure().withLatitude(new BigDecimal("22.914353")).withLongitude(new BigDecimal("11.806387"))));
    PublicationDeliveryStructure publicationDelivery = publicationDeliveryTestHelper.createPublicationDeliveryWithStopPlace(stopPlace1, stopPlace2);
    publicationDeliveryTestHelper.postAndReturnPublicationDelivery(publicationDelivery);
    UriInfo uriInfoMock = Mockito.mock(UriInfo.class);
    Mockito.when(uriInfoMock.getAbsolutePathBuilder()).thenReturn(JerseyUriBuilder.fromPath("http://test"));
    ChangedStopPlaceSearchDto search = new ChangedStopPlaceSearchDto(null, null, 0, 1);
    Response response = exportResource.exportStopPlacesWithEffectiveChangedInPeriod(search, newExportParamsBuilder().build(), uriInfoMock);
    List<StopPlace> changedStopPlaces = publicationDeliveryTestHelper.extractStopPlaces(response);
    Assert.assertEquals(1, changedStopPlaces.size());
    Assert.assertEquals(stopPlace1.getName().getValue(), changedStopPlaces.get(0).getName().getValue());
    Link link = response.getLink("next");
    Assert.assertNotNull(link);
}
Also used : LocalDateTime(java.time.LocalDateTime) StopPlace(org.rutebanken.netex.model.StopPlace) PublicationDeliveryStructure(org.rutebanken.netex.model.PublicationDeliveryStructure) SimplePoint_VersionStructure(org.rutebanken.netex.model.SimplePoint_VersionStructure) ValidBetween(org.rutebanken.netex.model.ValidBetween) LocationStructure(org.rutebanken.netex.model.LocationStructure) BigDecimal(java.math.BigDecimal) Response(javax.ws.rs.core.Response) MultilingualString(org.rutebanken.netex.model.MultilingualString) EmbeddableMultilingualString(org.rutebanken.tiamat.model.EmbeddableMultilingualString) ChangedStopPlaceSearchDto(org.rutebanken.tiamat.dtoassembling.dto.ChangedStopPlaceSearchDto) UriInfo(javax.ws.rs.core.UriInfo) Link(javax.ws.rs.core.Link) Test(org.junit.Test) TiamatIntegrationTest(org.rutebanken.tiamat.TiamatIntegrationTest)

Example 4 with LocationStructure

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

the class ExportResourceTest method insertTestStopsWithTopographicPlace.

private void insertTestStopsWithTopographicPlace() throws JAXBException, IOException, SAXException {
    if (testStopInserted) {
        return;
    }
    testStopInserted = true;
    StopPlace stopPlace = new StopPlace().withId("XYZ:Stopplace:1").withVersion("1").withName(new MultilingualString().withValue("Ă˜stre gravlund")).withCentroid(new SimplePoint_VersionStructure().withLocation(new LocationStructure().withLatitude(new BigDecimal("59.914353")).withLongitude(new BigDecimal("10.806387"))));
    PublicationDeliveryStructure publicationDelivery = publicationDeliveryTestHelper.createPublicationDeliveryWithStopPlace(stopPlace);
    publicationDeliveryTestHelper.postAndReturnPublicationDelivery(publicationDelivery);
}
Also used : StopPlace(org.rutebanken.netex.model.StopPlace) PublicationDeliveryStructure(org.rutebanken.netex.model.PublicationDeliveryStructure) SimplePoint_VersionStructure(org.rutebanken.netex.model.SimplePoint_VersionStructure) MultilingualString(org.rutebanken.netex.model.MultilingualString) EmbeddableMultilingualString(org.rutebanken.tiamat.model.EmbeddableMultilingualString) LocationStructure(org.rutebanken.netex.model.LocationStructure) BigDecimal(java.math.BigDecimal)

Example 5 with LocationStructure

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

the class FareZoneImportTest method mergeFareZonesForStopPlace.

@Test
public void mergeFareZonesForStopPlace() throws Exception {
    SimplePoint_VersionStructure point = new SimplePoint_VersionStructure().withLocation(new LocationStructure().withLatitude(new BigDecimal("77")).withLongitude(new BigDecimal("9.7")));
    List<JAXBElement<? extends Zone_VersionStructure>> tariffZones1 = new ArrayList<>();
    FareZone fareZone1 = new FareZone().withName(new MultilingualString().withValue("V03")).withVersion("1").withId("ATB:FareZone:01");
    tariffZones1.add(new ObjectFactory().createFareZone(fareZone1));
    StopPlace stopPlace = new StopPlace().withId("ATB:StopPlace:322").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("X08")).withVersion("1").withId("NTR:FareZone:03");
    tariffZones2.add(new ObjectFactory().createFareZone(fareZone2));
    StopPlace stopPlace2 = new StopPlace().withId("NTR:StopPlace:322").withVersion("2").withStopPlaceType(StopTypeEnumeration.ONSTREET_BUS).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(stopPlace2));
    PublicationDeliveryStructure publicationDeliveryStructure2 = publicationDeliveryTestHelper.publicationDelivery(siteFrame2);
    // Second import should match and merge tariffzones
    importParams.importType = ImportType.MATCH;
    PublicationDeliveryStructure matchReponse = publicationDeliveryTestHelper.postAndReturnPublicationDelivery(publicationDeliveryStructure2, importParams);
    List<JAXBElement<? extends Zone_VersionStructure>> actualZones = publicationDeliveryTestHelper.findSiteFrame(matchReponse).getTariffZones().getTariffZone();
    assertThat(actualZones).isNotEmpty();
    assertThat(actualZones).hasSize(2);
    List<StopPlace> actualIdMatchedStopPlaces = publicationDeliveryTestHelper.extractStopPlaces(matchReponse);
    assertThat(actualIdMatchedStopPlaces).hasSize(1);
    assertThat(actualIdMatchedStopPlaces.get(0).getTariffZones().getTariffZoneRef()).as("number of tariff zone refs").hasSize(2);
    importParams.importType = ImportType.ID_MATCH;
    PublicationDeliveryStructure idMatchResponse = publicationDeliveryTestHelper.postAndReturnPublicationDelivery(publicationDeliveryStructure2, importParams);
    actualZones = publicationDeliveryTestHelper.findSiteFrame(idMatchResponse).getTariffZones().getTariffZone();
    assertThat(actualZones).isNotEmpty();
    assertThat(actualZones).hasSize(2);
    actualIdMatchedStopPlaces = publicationDeliveryTestHelper.extractStopPlaces(matchReponse);
    assertThat(actualIdMatchedStopPlaces).hasSize(1);
    assertThat(actualIdMatchedStopPlaces.get(0).getTariffZones().getTariffZoneRef()).as("number of tariff zone refs").hasSize(2);
}
Also used : TariffZoneRefs_RelStructure(org.rutebanken.netex.model.TariffZoneRefs_RelStructure) StopPlace(org.rutebanken.netex.model.StopPlace) SiteFrame(org.rutebanken.netex.model.SiteFrame) TariffZonesInFrame_RelStructure(org.rutebanken.netex.model.TariffZonesInFrame_RelStructure) ArrayList(java.util.ArrayList) PublicationDeliveryStructure(org.rutebanken.netex.model.PublicationDeliveryStructure) SimplePoint_VersionStructure(org.rutebanken.netex.model.SimplePoint_VersionStructure) JAXBElement(javax.xml.bind.JAXBElement) FareZone(org.rutebanken.netex.model.FareZone) StopPlacesInFrame_RelStructure(org.rutebanken.netex.model.StopPlacesInFrame_RelStructure) LocationStructure(org.rutebanken.netex.model.LocationStructure) BigDecimal(java.math.BigDecimal) ObjectFactory(org.rutebanken.netex.model.ObjectFactory) ImportParams(org.rutebanken.tiamat.importer.ImportParams) Zone_VersionStructure(org.rutebanken.netex.model.Zone_VersionStructure) MultilingualString(org.rutebanken.netex.model.MultilingualString) TariffZoneRef(org.rutebanken.netex.model.TariffZoneRef) Test(org.junit.Test) TiamatIntegrationTest(org.rutebanken.tiamat.TiamatIntegrationTest)

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