Package org.onebusaway.geospatial.model

Examples of org.onebusaway.geospatial.model.CoordinateBounds


  @Test
  public void test() {

    CoordinatePoint center = new CoordinatePoint(47.653247216758494,
        -122.30838775634766);
    CoordinateBounds bounds = SphericalGeometryLibrary.bounds(center.getLat(),
        center.getLon(), 400);
    double latDelta = (bounds.getMaxLat() - bounds.getMinLat()) / 2;
    double lonDelta = (bounds.getMaxLon() - bounds.getMinLon()) / 2;
    System.out.println(latDelta);

    TimedGridFactory factory = new TimedGridFactory(latDelta, lonDelta,
        WALKING_SPEED_METERS_PER_MS);
View Full Code Here


    _maxSearchRadius = maxSearchRadius;
  }

  public CoordinateBounds createBounds() {

    CoordinateBounds bounds = createInternalBounds();

    if (_maxSearchRadius > 0) {

      CoordinateBounds maxBounds = SphericalGeometryLibrary.bounds(_lat, _lon,
          _maxSearchRadius);

      double latSpan = (bounds.getMaxLat() - bounds.getMinLat());
      double lonSpan = (bounds.getMaxLon() - bounds.getMinLon());
      double maxLatSpan = (maxBounds.getMaxLat() - maxBounds.getMinLat());
      double maxLonSpan = (maxBounds.getMaxLon() - maxBounds.getMinLon());

      if (latSpan > maxLatSpan || lonSpan > maxLonSpan) {
        latSpan = Math.min(latSpan, maxLatSpan);
        lonSpan = Math.min(lonSpan, maxLonSpan);
        bounds = SphericalGeometryLibrary.boundsFromLatLonOffset(_lat, _lon,
View Full Code Here

      return setUnknownVersionResponse();

    if (hasErrors())
      return setValidationErrorsResponse();

    CoordinateBounds bounds = _searchBoundsFactory.createBounds();

    long time = System.currentTimeMillis();
    if (_time != 0)
      time = _time;
View Full Code Here

      double distance) {
    return bounds(point.getLat(), point.getLon(), distance);
  }

  public static CoordinateBounds bounds(CoordinateBounds b, double distance) {
    CoordinateBounds b2 = bounds(b.getMinLat(), b.getMinLon(), distance);
    CoordinateBounds b3 = bounds(b.getMaxLat(), b.getMaxLon(), distance);
    b2.addBounds(b3);
    return b2;
  }
View Full Code Here

    double latTo = toDegrees(latRadians + latOffset);

    double lonFrom = toDegrees(lonRadians - lonOffset);
    double lonTo = toDegrees(lonRadians + lonOffset);

    return new CoordinateBounds(latFrom, lonFrom, latTo, lonTo);
  }
View Full Code Here

      double lon, double latOffset, double lonOffset) {
    double latFrom = lat - latOffset;
    double latTo = lat + latOffset;
    double lonFrom = lon - lonOffset;
    double lonTo = lon + lonOffset;
    return new CoordinateBounds(latFrom, lonFrom, latTo, lonTo);
  }
View Full Code Here

   */
  public static double getOrientation(double latFrom, double lonFrom,
      double latTo, double lonTo) {

    double d = distance(latFrom, lonFrom, latTo, lonTo);
    CoordinateBounds bounds = bounds(latFrom, lonFrom, d);

    XYPoint origin = new XYPoint(lonFrom, latFrom);
    XYPoint axis = new XYPoint(bounds.getMaxLon(), latFrom);
    XYPoint target = new XYPoint(lonTo, latTo);

    double angle = GeometryLibrary.getAngle(origin, axis, target);
    if (latTo < latFrom)
      angle = 2 * Math.PI - angle;
View Full Code Here

    List<Envelope> regions = new ArrayList<Envelope>();

    for (Stop stop : _gtfsDao.getAllStops()) {

      if (_latRadius == 0 || _lonRadius == 0) {
        CoordinateBounds bounds = SphericalGeometryLibrary.bounds(
            stop.getLat(), stop.getLon(), _radius);
        _latRadius = (bounds.getMaxLat() - bounds.getMinLat()) / 2;
        _lonRadius = (bounds.getMaxLon() - bounds.getMinLon()) / 2;
      }

      Coordinate a = new Coordinate(stop.getLon() - _lonRadius, stop.getLat()
          - _latRadius);
      Coordinate b = new Coordinate(stop.getLon() + _lonRadius, stop.getLat()
View Full Code Here

    Map<StopEntry, List<StopEntry>> transfers = new FactoryMap<StopEntry, List<StopEntry>>(
        new ArrayList<StopEntry>());

    for (StopEntry stop : key.getStops()) {

      CoordinateBounds bounds = SphericalGeometryLibrary.bounds(
          stop.getStopLocation(), _constants.getMaxTransferDistance());

      List<StopEntry> nearbyStops = _transitGraphDao.getStopsByLocation(bounds);
      for (StopEntry nearbyStop : nearbyStops) {
        transfers.get(nearbyStop).add(stop);
View Full Code Here

    config.put("baseUrl", contextPath);
    config.put("apiUrl", contextPath + "/api");

    List<AgencyWithCoverageBean> agenciesWithCoverage = _transitDataService.getAgenciesWithCoverage();

    CoordinateBounds bounds = new CoordinateBounds();

    for (AgencyWithCoverageBean awc : agenciesWithCoverage) {

      if (awc.getLatSpan() <= 0 || awc.getLonSpan() <= 0)
        continue;

      bounds.addPoint(awc.getLat() + awc.getLatSpan() / 2,
          awc.getLon() + awc.getLonSpan() / 2);
      bounds.addPoint(awc.getLat() - awc.getLatSpan() / 2,
          awc.getLon() - awc.getLonSpan() / 2);
    }

    if (bounds.isEmpty()) {
      config.put("centerLat", 0.0);
      config.put("centerLon", 0.0);
      config.put("spanLat", 180.0);
      config.put("spanLon", 180.0);
    } else {
      config.put("centerLat", (bounds.getMinLat() + bounds.getMaxLat()) / 2);
      config.put("centerLon", (bounds.getMinLon() + bounds.getMaxLon()) / 2);
      config.put("spanLat", bounds.getMaxLat() - bounds.getMinLat());
      config.put("spanLon", bounds.getMaxLon() - bounds.getMinLon());
    }

    config.put("hasDefaultServiceArea",
        _serviceAreaService.hasDefaultServiceArea());
    config.put("googleMapsApiKey", _googleMapsApiKey);
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.