Search in sources :

Example 56 with CoordinateBounds

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

the class CoordinateBoundsTest method testAddBounds.

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

Example 57 with CoordinateBounds

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

the class CoordinateBoundsTest method testSetEmpty.

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

Example 58 with CoordinateBounds

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

the class CoordinateBoundsTest method testCoordinateBounds.

@Test
public void testCoordinateBounds() {
    CoordinateBounds bounds = new CoordinateBounds();
    assertTrue(bounds.isEmpty());
    bounds.addPoint(1, 2);
    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 59 with CoordinateBounds

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

the class SphericalGeometryLibraryTest method testGetCenterOfBounds.

@Test
public void testGetCenterOfBounds() {
    CoordinateBounds b = new CoordinateBounds(-1.0, -2.0, 4.0, 3.6);
    CoordinatePoint p = SphericalGeometryLibrary.getCenterOfBounds(b);
    assertEquals(1.5, p.getLat(), 0.0);
    assertEquals(0.8, p.getLon(), 0.0);
}
Also used : CoordinatePoint(org.onebusaway.geospatial.model.CoordinatePoint) CoordinateBounds(org.onebusaway.geospatial.model.CoordinateBounds) Test(org.junit.Test)

Example 60 with CoordinateBounds

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

the class SphericalGeometryLibraryTest method testBoundsLatAndLon.

@Test
public void testBoundsLatAndLon() {
    CoordinateBounds bounds = SphericalGeometryLibrary.bounds(47.97527158291236, -122.3527193069458, 400, 200);
    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(400, d3, 0.1);
    double d4 = SphericalGeometryLibrary.distance(bounds.getMaxLat(), bounds.getMaxLon(), bounds.getMaxLat(), bounds.getMinLon());
    assertEquals(400, d4, 0.1);
}
Also used : 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