Search in sources :

Example 26 with CoordinateBounds

use of org.onebusaway.geospatial.model.CoordinateBounds in project onebusaway-application-modules by camsys.

the class CoordinateBoundsTest method testContains.

@Test
public void testContains() {
    CoordinateBounds bounds = new CoordinateBounds(1, 2, 3, 4);
    assertTrue(bounds.contains(1, 2));
    assertTrue(bounds.contains(3, 4));
    assertTrue(bounds.contains(2, 3));
    assertFalse(bounds.contains(0, 3));
    assertFalse(bounds.contains(2, 0));
}
Also used : CoordinateBounds(org.onebusaway.geospatial.model.CoordinateBounds) Test(org.junit.Test)

Example 27 with CoordinateBounds

use of org.onebusaway.geospatial.model.CoordinateBounds in project onebusaway-application-modules by camsys.

the class CoordinateBoundsTest method testCoordinateBoundsCoordinateBounds.

@Test
public void testCoordinateBoundsCoordinateBounds() {
    CoordinateBounds bounds = new CoordinateBounds(1, 2);
    bounds = new CoordinateBounds(bounds);
    assertFalse(bounds.isEmpty());
    assertEquals(1, bounds.getMinLat(), 0);
    assertEquals(2, bounds.getMinLon(), 0);
    assertEquals(1, bounds.getMaxLat(), 0);
    assertEquals(2, bounds.getMaxLon(), 0);
}
Also used : CoordinateBounds(org.onebusaway.geospatial.model.CoordinateBounds) Test(org.junit.Test)

Example 28 with CoordinateBounds

use of org.onebusaway.geospatial.model.CoordinateBounds in project onebusaway-application-modules by camsys.

the class CoordinateBoundsTest method testAddPoint.

@Test
public void testAddPoint() {
    CoordinateBounds bounds = new CoordinateBounds();
    bounds.addPoint(1, 2);
    assertEquals(1, bounds.getMinLat(), 0);
    assertEquals(2, bounds.getMinLon(), 0);
    assertEquals(1, bounds.getMaxLat(), 0);
    assertEquals(2, bounds.getMaxLon(), 0);
    bounds.addPoint(0, 5);
    assertEquals(0, bounds.getMinLat(), 0);
    assertEquals(2, bounds.getMinLon(), 0);
    assertEquals(1, bounds.getMaxLat(), 0);
    assertEquals(5, bounds.getMaxLon(), 0);
}
Also used : CoordinateBounds(org.onebusaway.geospatial.model.CoordinateBounds) Test(org.junit.Test)

Example 29 with CoordinateBounds

use of org.onebusaway.geospatial.model.CoordinateBounds in project onebusaway-application-modules by camsys.

the class SphericalGeometryLibraryTest method testBounds.

@Test
public void testBounds() {
    CoordinateBounds bounds = SphericalGeometryLibrary.bounds(47.97527158291236, -122.3527193069458, 400);
    double d1 = SphericalGeometryLibrary.distance(bounds.getMaxLat(), bounds.getMaxLon(), bounds.getMinLat(), bounds.getMaxLon());
    assertEquals(800, d1, 0.01);
    double d2 = SphericalGeometryLibrary.distance(bounds.getMaxLat(), bounds.getMinLon(), bounds.getMinLat(), bounds.getMinLon());
    assertEquals(800, d2, 0.01);
    double d3 = SphericalGeometryLibrary.distance(bounds.getMinLat(), bounds.getMaxLon(), bounds.getMinLat(), bounds.getMinLon());
    assertEquals(800, d3, 0.1);
    double d4 = SphericalGeometryLibrary.distance(bounds.getMaxLat(), bounds.getMaxLon(), bounds.getMaxLat(), bounds.getMinLon());
    assertEquals(800, d4, 0.1);
}
Also used : CoordinateBounds(org.onebusaway.geospatial.model.CoordinateBounds) Test(org.junit.Test)

Example 30 with CoordinateBounds

use of org.onebusaway.geospatial.model.CoordinateBounds in project onebusaway-application-modules by camsys.

the class FederatedServiceFactoryBeanTest method go.

@Test
public void go() throws Exception {
    SimpleFederatedService serviceA = Mockito.mock(SimpleFederatedService.class);
    SimpleFederatedService serviceB = Mockito.mock(SimpleFederatedService.class);
    Map<String, List<CoordinateBounds>> firstProviderAgenciesAndCoverage = new HashMap<String, List<CoordinateBounds>>();
    firstProviderAgenciesAndCoverage.put("a1", Arrays.asList(new CoordinateBounds(1, 1, 3, 3), new CoordinateBounds(2, 2, 4, 4)));
    firstProviderAgenciesAndCoverage.put("a2", Arrays.asList(new CoordinateBounds(2, 5, 4, 6)));
    Map<String, List<CoordinateBounds>> secondProviderAgenciesAndCoverage = new HashMap<String, List<CoordinateBounds>>();
    secondProviderAgenciesAndCoverage.put("b1", Arrays.asList(new CoordinateBounds(5, 5, 7, 7), new CoordinateBounds(6, 6, 8, 8)));
    secondProviderAgenciesAndCoverage.put("b2", Arrays.asList(new CoordinateBounds(5, 2, 7, 4)));
    Mockito.when(serviceA.getAgencyIdsWithCoverageArea()).thenReturn(firstProviderAgenciesAndCoverage);
    Mockito.when(serviceB.getAgencyIdsWithCoverageArea()).thenReturn(secondProviderAgenciesAndCoverage);
    LazyFederatedServiceCollectionImpl collection = new LazyFederatedServiceCollectionImpl();
    collection.setServiceInterface(SimpleFederatedService.class);
    collection.setServiceProviders(Arrays.asList(serviceA, serviceB));
    FederatedServiceFactoryBean factory = new FederatedServiceFactoryBean();
    factory.setCollection(collection);
    factory.setServiceInterface(SimpleFederatedService.class);
    factory.afterPropertiesSet();
    SimpleFederatedService service = (SimpleFederatedService) factory.getObject();
    service.getValueForId("a1_test1");
    service.getValueForId("a2_test2");
    service.getValueForId("b1_test3");
    service.getValueForId("b2_test4");
    Mockito.verify(serviceA).getValueForId("a1_test1");
    Mockito.verify(serviceA).getValueForId("a2_test2");
    Mockito.verify(serviceB).getValueForId("b1_test3");
    Mockito.verify(serviceB).getValueForId("b2_test4");
}
Also used : HashMap(java.util.HashMap) LazyFederatedServiceCollectionImpl(org.onebusaway.federations.impl.LazyFederatedServiceCollectionImpl) List(java.util.List) CoordinateBounds(org.onebusaway.geospatial.model.CoordinateBounds) Test(org.junit.Test)

Aggregations

CoordinateBounds (org.onebusaway.geospatial.model.CoordinateBounds)70 Test (org.junit.Test)20 ArrayList (java.util.ArrayList)17 HashMap (java.util.HashMap)16 AgencyAndId (org.onebusaway.gtfs.model.AgencyAndId)15 List (java.util.List)14 SearchQueryBean (org.onebusaway.transit_data.model.SearchQueryBean)12 Map (java.util.Map)9 StopBean (org.onebusaway.transit_data.model.StopBean)9 CoordinatePoint (org.onebusaway.geospatial.model.CoordinatePoint)7 RouteBean (org.onebusaway.transit_data.model.RouteBean)7 StopsBean (org.onebusaway.transit_data.model.StopsBean)7 Envelope (com.vividsolutions.jts.geom.Envelope)5 OutOfServiceAreaServiceException (org.onebusaway.exceptions.OutOfServiceAreaServiceException)5 STRtree (com.vividsolutions.jts.index.strtree.STRtree)4 File (java.io.File)4 IOException (java.io.IOException)4 Filters (org.onebusaway.api.actions.siri.impl.SiriSupportV2.Filters)4 DetailLevel (org.onebusaway.api.actions.siri.model.DetailLevel)4 RoutesBean (org.onebusaway.transit_data.model.RoutesBean)4