Package org.onebusaway.geospatial.model

Examples of org.onebusaway.geospatial.model.CoordinateBounds


    }

    _tree = new STRtree(shapeIdsByGridCell.size());

    for (Map.Entry<CoordinateBounds, List<AgencyAndId>> entry : shapeIdsByGridCell.entrySet()) {
      CoordinateBounds b = entry.getKey();
      Envelope env = new Envelope(b.getMinLon(), b.getMaxLon(), b.getMinLat(),
          b.getMaxLat());
      List<AgencyAndId> shapeIds = entry.getValue();
      _tree.insert(env, shapeIds);
    }

    _tree.build();
View Full Code Here


      addFieldError("maxCount", "must be greater than zero");

    if (hasErrors())
      return setValidationErrorsResponse();

    CoordinateBounds bounds = getSearchBounds();

    SearchQueryBean searchQuery = new SearchQueryBean();
    searchQuery.setBounds(bounds);
    searchQuery.setMaxCount(maxCount);
    searchQuery.setType(EQueryType.BOUNDS);
View Full Code Here

    Map<String, CoordinateBounds> boundsByAgencyId = new HashMap<String, CoordinateBounds>();

    for (AgencyEntry agency : _graph.getAllAgencies()) {

      CoordinateBounds bounds = new CoordinateBounds();
     
      for( RouteCollectionEntry routeCollection : agency.getRouteCollections()) {
        for( RouteEntry route : routeCollection.getChildren() ) {
          for (TripEntry trip : route.getTrips() ) {
            for( StopTimeEntry stopTime : trip.getStopTimes() ) {
              StopEntry stop = stopTime.getStop();
              bounds.addPoint(stop.getStopLat(), stop.getStopLon());
            }
          }
        }
      }
View Full Code Here

        RefreshableResources.SHAPE_GEOSPATIAL_INDEX);

    Map<CoordinateBounds, List<AgencyAndId>> shapeIdsByBounds = ObjectSerializationLibrary.readObject(path);
    assertEquals(5, shapeIdsByBounds.size());

    CoordinateBounds b = new CoordinateBounds(47.65048049686506,
        -122.30767397879845, 47.654977097836735, -122.300997795721);
    assertEquals(Arrays.asList(shapeIdA), shapeIdsByBounds.get(b));

    b = new CoordinateBounds(47.65947369880841, -122.32102634495334,
        47.66397029978009, -122.3143501618759);
    assertEquals(Arrays.asList(shapeIdB), shapeIdsByBounds.get(b));
    b = new CoordinateBounds(47.66397029978009, -122.32770252803078,
        47.66846690075177, -122.32102634495334);
    assertEquals(Arrays.asList(shapeIdB), shapeIdsByBounds.get(b));
    b = new CoordinateBounds(47.65947369880841, -122.3143501618759,
        47.66397029978009, -122.30767397879845);
    assertEquals(Arrays.asList(shapeIdB), shapeIdsByBounds.get(b));
    b = new CoordinateBounds(47.65947369880841, -122.32770252803078,
        47.66397029978009, -122.32102634495334);
    assertEquals(Arrays.asList(shapeIdB), shapeIdsByBounds.get(b));
  }
View Full Code Here

    Mockito.when(dao.getAllStops()).thenReturn(allStops);

    service.initialize();

    List<AgencyAndId> stops = service.getStopsByBounds(new CoordinateBounds(-1,
        -1, 0, 0));
    assertEquals(1, stops.size());
    assertTrue(stops.contains(stopA.getId()));

    stops = service.getStopsByBounds(new CoordinateBounds(0, -1, 1, 0));
    assertEquals(1, stops.size());
    assertTrue(stops.contains(stopC.getId()));

    stops = service.getStopsByBounds(new CoordinateBounds(-1, -1, 1, 0));
    assertEquals(2, stops.size());
    assertTrue(stops.contains(stopA.getId()));
    assertTrue(stops.contains(stopC.getId()));

    stops = service.getStopsByBounds(new CoordinateBounds(-1, -1, 1, 1));
    assertEquals(4, stops.size());
    assertTrue(stops.contains(stopA.getId()));
    assertTrue(stops.contains(stopB.getId()));
    assertTrue(stops.contains(stopC.getId()));
    assertTrue(stops.contains(stopD.getId()));

    stops = service.getStopsByBounds(new CoordinateBounds(0.8, 0.8, 1, 1));
    assertEquals(0, stops.size());
  }
View Full Code Here

  }

  private StopsBean getStopsByBounds(SearchQueryBean queryBean)
      throws ServiceException {

    CoordinateBounds bounds = queryBean.getBounds();

    List<AgencyAndId> stopIds = _geospatialBeanService.getStopsByBounds(bounds);

    boolean limitExceeded = BeanServiceSupport.checkLimitExceeded(stopIds,
        queryBean.getMaxCount());
View Full Code Here

  }

  private StopsBean getStopsByBoundsAndQuery(SearchQueryBean queryBean)
      throws ServiceException {

    CoordinateBounds bounds = queryBean.getBounds();
    String query = queryBean.getQuery();
    int maxCount = queryBean.getMaxCount();

    CoordinatePoint center = SphericalGeometryLibrary.getCenterOfBounds(bounds);

    SearchResult<AgencyAndId> stops;
    try {
      stops = _searchService.searchForStopsByCode(query, 10, MIN_SCORE);
    } catch (ParseException e) {
      throw new InvalidArgumentServiceException("query", "queryParseError");
    } catch (IOException e) {
      _log.error("error executing stop search: query=" + query, e);
      e.printStackTrace();
      throw new ServiceException();
    }

    Min<StopBean> closest = new Min<StopBean>();
    List<StopBean> stopBeans = new ArrayList<StopBean>();

    for (AgencyAndId aid : stops.getResults()) {
      StopBean stopBean = _stopBeanService.getStopForId(aid);
      if (bounds.contains(stopBean.getLat(), stopBean.getLon()))
        stopBeans.add(stopBean);
      double distance = SphericalGeometryLibrary.distance(center.getLat(),
          center.getLon(), stopBean.getLat(), stopBean.getLon());
      closest.add(distance, stopBean);
    }
View Full Code Here

    List<AgencyAndId> stopIds = new ArrayList<AgencyAndId>();
    stopIds.add(stopIdA);
    stopIds.add(stopIdB);

    CoordinateBounds bounds = SphericalGeometryLibrary.bounds(stop.getLat(),
        stop.getLon(), 400);
    Mockito.when(_geoBeanService.getStopsByBounds(bounds)).thenReturn(stopIds);

    List<AgencyAndId> nearby = _service.getNearbyStops(stop, 400);
    assertEquals(1, nearby.size());
View Full Code Here

      Map<Date, Record> recordsByTime) {
    Set<BlockSequenceIndex> allIndices = null;

    for (Record record : recordsByTime.values()) {

      CoordinateBounds bounds = SphericalGeometryLibrary.bounds(
          record.getLocation(), record.getAccuracy());

      Set<BlockSequenceIndex> indices = _blockGeospatialService.getBlockSequenceIndexPassingThroughBounds(bounds);
      if (allIndices == null)
        allIndices = indices;
View Full Code Here

  @Cacheable
  public List<AgencyAndId> getNearbyStops(
      @CacheableArgument(keyProperty = "id") StopBean stopBean, double radius) {

    CoordinateBounds bounds = SphericalGeometryLibrary.bounds(
        stopBean.getLat(), stopBean.getLon(), radius);
    List<AgencyAndId> ids = _geospatialBeanService.getStopsByBounds(bounds);

    List<AgencyAndId> excludingSource = new ArrayList<AgencyAndId>();
View Full Code Here

TOP

Related Classes of org.onebusaway.geospatial.model.CoordinateBounds

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.