Package org.onebusaway.gtfs.model

Examples of org.onebusaway.gtfs.model.Stop


      double lon = 0;
      for (Stop stop : stops) {
        lat += stop.getLat();
        lon += stop.getLon();
      }     
      Stop stop = stops.get(0);
      Stop station = new Stop();
      station.setId(id(stop.getParentStation()));
      station.setName(stop.getName());
      station.setLat(lat / stops.size());
      station.setLon(lon / stops.size());
      station.setLocationType(1);
      _dao.saveEntity(station);
    }
  }
View Full Code Here


    boolean first = true;

    for (JourneyTimePointElement timePoint : journey.getTimePoints()) {
      String stopId = timePoint.getLocationId();
      Stop stop = findStop(stopId);
      if (stop == null && !_keepTripsWithMissingStops) {
        _prunedTripsCount++;
        return false;
      }
    }

    for (JourneyTimePointElement timePoint : journey.getTimePoints()) {
      String stopId = timePoint.getLocationId();
      Stop stop = findStop(stopId);

      /**
       * A NULL stop indicates a stop that has been pruned because it doesn't
       * have location information. We do not produce stop times for these
       * stops.
 
View Full Code Here

    throw new AtcoCifException("no stop found with id " + stopId);
  }

  private Stop getNaptanStop(NaPTANStop naptanStop) {
    AgencyAndId id = id(naptanStop.getAtcoCode());
    Stop stop = _dao.getStopForId(id);
    if (stop == null) {
      stop = new Stop();
      stop.setId(id);
      stop.setName(naptanStop.getCommonName());
      stop.setLat(naptanStop.getLatitude());
      stop.setLon(naptanStop.getLongitude());
      _dao.saveEntity(stop);
    }
    return stop;
  }
View Full Code Here

  }

  private Stop getAtcoStop(LocationElement location) {
    String locationId = location.getLocationId();
    AgencyAndId id = id(locationId);
    Stop stop = _dao.getStopForId(id);
    if (stop == null) {
      LocationProvider locationSource = _additionalLocationById.get(locationId);
      if (locationSource == null) {
        throw new AtcoCifException("found location with id=" + locationId
            + " but no additional location information found");
      }

      LocationProvider nxLocationSource = _nxLocationGeoDetailById.get(locationId);
      if (nxLocationSource != null) {
        locationSource = nxLocationSource;
      }

      if (locationSource.getLat() == 0.0 || locationSource.getLon() == 0.0) {
        if (_stopsWithNoLocationInfo.add(locationId)) {
          _log.info("stop with no location: " + locationId);
          _prunedStopsWithNoLocationInfoCount++;
        }
        if (!_keepStopsWithNoLocationInfo) {
          return null;
        }
      }
      String name = location.getName();
      NationalExpressLocationNameElement nxNameElement = _nxLocationNamesById.get(locationId);
      if (nxNameElement != null && !nxNameElement.getShortName().isEmpty()) {
        name = nxNameElement.getShortName();
      }

      stop = new Stop();
      stop.setId(id(locationId));
      stop.setName(name);
      stop.setLat(locationSource.getLat());
      stop.setLon(locationSource.getLon());

      String clusterId = _clusterIdByLocationId.get(locationId);
      if (clusterId != null) {
        AgencyAndId stationId = id(clusterId + "-station");
        stop.setParentStation(stationId.getId());
        List<Stop> stops = _stopsByClusterId.get(clusterId);
        if (stops == null) {
          stops = new ArrayList<Stop>();
          _stopsByClusterId.put(clusterId, stops);
        }
View Full Code Here

  }

  private Stop getGreaterManchesterRowListStop(
      GreaterManchesterTimetableRowListElement rowList) {
    AgencyAndId id = id(rowList.getLocationReference());
    Stop stop = _dao.getStopForId(id);
    if (stop == null) {
      stop = new Stop();
      stop.setId(id);
      stop.setName(rowList.getFullLocation());
      _dao.saveEntity(stop);
    }
    return stop;
  }
View Full Code Here

                ((StreetLocation)fromVertex).getExtra().add(ppse);
            }
        }
       
        if (opt.startingTransitStopId != null) {
            Stop stop = graph.index.stopForId.get(opt.startingTransitStopId);
            TransitStop tstop = graph.index.stopVertexForStop.get(stop);
            startingStop = tstop.departVertex;
        }
        origin = opt.arriveBy ? toVertex : fromVertex;
        originBackEdge = opt.arriveBy ? toBackEdge : fromBackEdge;
View Full Code Here

        }
        for (Vertex vertex : vertices) {
            vertexForId.put(vertex.getLabel(), vertex);
            if (vertex instanceof TransitStop) {
                TransitStop transitStop = (TransitStop) vertex;
                Stop stop = transitStop.getStop();
                stopForId.put(stop.getId(), stop);
                stopVertexForStop.put(stop, transitStop);
                stopsForParentStation.put(stop.getParentStation(), stop);
            }
        }
        for (TransitStop stopVertex : stopVertexForStop.values()) {
            Envelope envelope = new Envelope(stopVertex.getCoordinate());
            stopSpatialIndex.insert(envelope, stopVertex);
View Full Code Here

            // No need to explicitly add s0 to the cluster. It will be found in the spatial index query below.
            Envelope env = new Envelope(new Coordinate(s0.getLon(), s0.getLat()));
            env.expandBy(SphericalDistanceLibrary.metersToLonDegrees(CLUSTER_RADIUS, s0.getLat()),
                    SphericalDistanceLibrary.metersToDegrees(CLUSTER_RADIUS));
            for (TransitStop ts1 : stopSpatialIndex.query(env)) {
                Stop s1 = ts1.getStop();
                double geoDistance = SphericalDistanceLibrary.getInstance().fastDistance(s0.getLat(), s0.getLon(), s1.getLat(), s1.getLon());
                if (geoDistance < CLUSTER_RADIUS) {
                    String s1normalizedName = StopNameNormalizer.normalize(s1.getName());
                    // LOG.info("   --> {}", s1normalizedName);
                    // LOG.info("       geodist {} stringdist {}", geoDistance, stringDistance);
                    if (s1normalizedName.equals(s0normalizedName)) {
                        // Create a bidirectional relationship between the stop and its cluster
                        cluster.children.add(s1);
View Full Code Here

        checkNotNull(fromStop);
        checkNotNull(toStop);
       
        // Reverse from and to if we are moving backwards in time
        if (!forwardInTime) {
            Stop tempStop = fromStop;
            fromStop = toStop;
            toStop = tempStop;
            Trip tempTrip = fromTrip;
            fromTrip = toTrip;
            toTrip = tempTrip;
View Full Code Here

   /** Return specific transit stop in the graph, by ID. */
   @GET
   @Path("/stops/{stopId}")
   public Response getStop (@PathParam("stopId") String stopIdString) {
       AgencyAndId stopId = GtfsLibrary.convertIdFromString(stopIdString);
       Stop stop = index.stopForId.get(stopId);
       if (stop != null) {
           return Response.status(Status.OK).entity(stop).build();
       } else {
           return Response.status(Status.NOT_FOUND).entity(MSG_404).build();
       }
View Full Code Here

TOP

Related Classes of org.onebusaway.gtfs.model.Stop

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.