Search in sources :

Example 1 with TariffZone

use of org.rutebanken.tiamat.model.TariffZone in project tiamat by entur.

the class TariffZoneSaverServiceTest method saveNewTariffZone.

@Test
public void saveNewTariffZone() {
    TariffZone newVersion = new TariffZone();
    Geometry geometry = geometryFactory.createPoint(new Coordinate(9.84, 59.26)).buffer(20);
    LinearRing linearRing = new LinearRing(new CoordinateArraySequence(geometry.getCoordinates()), geometryFactory);
    newVersion.setPolygon(geometryFactory.createPolygon(linearRing, null));
    TariffZone actual = tariffZoneSaverService.saveNewVersion(newVersion);
    assertThat(actual.getPolygon()).isNotNull();
    assertThat(actual.getVersion()).isEqualTo(1L);
}
Also used : Geometry(org.locationtech.jts.geom.Geometry) TariffZone(org.rutebanken.tiamat.model.TariffZone) Coordinate(org.locationtech.jts.geom.Coordinate) LinearRing(org.locationtech.jts.geom.LinearRing) CoordinateArraySequence(org.locationtech.jts.geom.impl.CoordinateArraySequence) Test(org.junit.Test) TiamatIntegrationTest(org.rutebanken.tiamat.TiamatIntegrationTest)

Example 2 with TariffZone

use of org.rutebanken.tiamat.model.TariffZone in project tiamat by entur.

the class TariffZoneRepositoryImplTest method findTariffZonesByIdPrefix.

@Test
public void findTariffZonesByIdPrefix() throws Exception {
    TariffZone tariffZone2V = new TariffZone();
    tariffZone2V.setName(new EmbeddableMultilingualString("2V"));
    tariffZone2V.setNetexId("RUT:TariffZone:2V");
    TariffZone tariffZone412 = new TariffZone();
    tariffZone412.setNetexId("BRA:TariffZone:412");
    tariffZone412.setName(new EmbeddableMultilingualString("Kongsberg"));
    tariffZoneRepository.save(tariffZone2V);
    tariffZoneRepository.save(tariffZone412);
    TariffZoneSearch search = TariffZoneSearch.newTariffZoneSearchBuilder().query("RUT").build();
    List<TariffZone> tariffZoneList = tariffZoneRepository.findTariffZones(search);
    assertThat(tariffZoneList).hasSize(1).extracting(TariffZone::getNetexId).containsOnly(tariffZone2V.getNetexId());
}
Also used : TariffZone(org.rutebanken.tiamat.model.TariffZone) TariffZoneSearch(org.rutebanken.tiamat.exporter.params.TariffZoneSearch) EmbeddableMultilingualString(org.rutebanken.tiamat.model.EmbeddableMultilingualString) Test(org.junit.Test) TiamatIntegrationTest(org.rutebanken.tiamat.TiamatIntegrationTest)

Example 3 with TariffZone

use of org.rutebanken.tiamat.model.TariffZone in project tiamat by entur.

the class TariffZoneRepositoryImplTest method findTariffZonesByName.

@Test
public void findTariffZonesByName() throws Exception {
    TariffZone tariffZone2V = new TariffZone();
    tariffZone2V.setName(new EmbeddableMultilingualString("2V"));
    tariffZone2V.setNetexId("RUT:TariffZone:2V");
    TariffZone tariffZone412 = new TariffZone();
    tariffZone412.setNetexId("BRA:TariffZone:412");
    tariffZone412.setName(new EmbeddableMultilingualString("Kongsberg"));
    tariffZoneRepository.save(tariffZone2V);
    tariffZoneRepository.save(tariffZone412);
    TariffZoneSearch search = TariffZoneSearch.newTariffZoneSearchBuilder().query("Kongsberg").build();
    List<TariffZone> tariffZoneList = tariffZoneRepository.findTariffZones(search);
    assertThat(tariffZoneList).hasSize(1).extracting(TariffZone::getNetexId).containsOnly(tariffZone412.getNetexId());
}
Also used : TariffZone(org.rutebanken.tiamat.model.TariffZone) TariffZoneSearch(org.rutebanken.tiamat.exporter.params.TariffZoneSearch) EmbeddableMultilingualString(org.rutebanken.tiamat.model.EmbeddableMultilingualString) Test(org.junit.Test) TiamatIntegrationTest(org.rutebanken.tiamat.TiamatIntegrationTest)

Example 4 with TariffZone

use of org.rutebanken.tiamat.model.TariffZone in project tiamat by entur.

the class TariffZoneRepositoryImplTest method findTariffZonesById.

@Test
public void findTariffZonesById() throws Exception {
    TariffZone tariffZone2V = new TariffZone();
    tariffZone2V.setName(new EmbeddableMultilingualString("2V"));
    tariffZone2V.setNetexId("RUT:TariffZone:2V");
    TariffZone tariffZone412 = new TariffZone();
    tariffZone412.setNetexId("BRA:TariffZone:412");
    tariffZone412.setName(new EmbeddableMultilingualString("Kongsberg"));
    tariffZoneRepository.save(tariffZone2V);
    tariffZoneRepository.save(tariffZone412);
    TariffZoneSearch search = TariffZoneSearch.newTariffZoneSearchBuilder().query(tariffZone412.getNetexId()).build();
    List<TariffZone> tariffZoneList = tariffZoneRepository.findTariffZones(search);
    assertThat(tariffZoneList).hasSize(1).extracting(TariffZone::getNetexId).containsOnly(tariffZone412.getNetexId());
}
Also used : TariffZone(org.rutebanken.tiamat.model.TariffZone) TariffZoneSearch(org.rutebanken.tiamat.exporter.params.TariffZoneSearch) EmbeddableMultilingualString(org.rutebanken.tiamat.model.EmbeddableMultilingualString) Test(org.junit.Test) TiamatIntegrationTest(org.rutebanken.tiamat.TiamatIntegrationTest)

Example 5 with TariffZone

use of org.rutebanken.tiamat.model.TariffZone in project tiamat by entur.

the class StopPlaceRefUpdaterServiceTest method setup.

@Transactional(propagation = Propagation.REQUIRES_NEW)
public StopPlace setup() {
    TariffZone tariffZone = new TariffZone();
    tariffZone.setVersion(1L);
    Point point = geometryFactory.createPoint(new Coordinate(9.84, 59.26));
    Geometry bufferedPoint = point.buffer(20);
    LinearRing tariffZoneLinearRing = new LinearRing(new CoordinateArraySequence(bufferedPoint.getCoordinates()), geometryFactory);
    tariffZone.setPolygon(geometryFactory.createPolygon(tariffZoneLinearRing, null));
    tariffZoneRepository.saveAndFlush(tariffZone);
    TopographicPlace topographicPlace = new TopographicPlace();
    topographicPlace.setVersion(1L);
    topographicPlace.setTopographicPlaceType(TopographicPlaceTypeEnumeration.MUNICIPALITY);
    LinearRing topographicPlaceLinearRing = new LinearRing(new CoordinateArraySequence(bufferedPoint.getCoordinates()), geometryFactory);
    topographicPlace.setPolygon(geometryFactory.createPolygon(topographicPlaceLinearRing, null));
    topographicPlaceRepository.saveAndFlush(topographicPlace);
    StopPlace stopPlace = new StopPlace();
    stopPlace.setName(new EmbeddableMultilingualString("some stop place"));
    stopPlace.setCentroid(point);
    stopPlace.setVersion(1L);
    stopPlaceRepository.saveAndFlush(stopPlace);
    return stopPlace;
}
Also used : Geometry(org.locationtech.jts.geom.Geometry) TariffZone(org.rutebanken.tiamat.model.TariffZone) StopPlace(org.rutebanken.tiamat.model.StopPlace) Coordinate(org.locationtech.jts.geom.Coordinate) TopographicPlace(org.rutebanken.tiamat.model.TopographicPlace) Point(org.locationtech.jts.geom.Point) LinearRing(org.locationtech.jts.geom.LinearRing) EmbeddableMultilingualString(org.rutebanken.tiamat.model.EmbeddableMultilingualString) CoordinateArraySequence(org.locationtech.jts.geom.impl.CoordinateArraySequence) Transactional(org.springframework.transaction.annotation.Transactional)

Aggregations

TariffZone (org.rutebanken.tiamat.model.TariffZone)25 Test (org.junit.Test)18 TiamatIntegrationTest (org.rutebanken.tiamat.TiamatIntegrationTest)16 EmbeddableMultilingualString (org.rutebanken.tiamat.model.EmbeddableMultilingualString)14 StopPlace (org.rutebanken.tiamat.model.StopPlace)8 Instant (java.time.Instant)5 Coordinate (org.locationtech.jts.geom.Coordinate)5 Geometry (org.locationtech.jts.geom.Geometry)5 LinearRing (org.locationtech.jts.geom.LinearRing)5 CoordinateArraySequence (org.locationtech.jts.geom.impl.CoordinateArraySequence)5 TariffZoneSearch (org.rutebanken.tiamat.exporter.params.TariffZoneSearch)5 TariffZoneRef (org.rutebanken.tiamat.model.TariffZoneRef)5 ValidBetween (org.rutebanken.tiamat.model.ValidBetween)4 SiteFrame (org.rutebanken.netex.model.SiteFrame)3 StopPlace (org.rutebanken.netex.model.StopPlace)3 TariffZoneRef (org.rutebanken.netex.model.TariffZoneRef)3 TariffZoneRefs_RelStructure (org.rutebanken.netex.model.TariffZoneRefs_RelStructure)3 ByteArrayInputStream (java.io.ByteArrayInputStream)2 ByteArrayOutputStream (java.io.ByteArrayOutputStream)2 ArrayList (java.util.ArrayList)2