Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Empty file modified src/client/images/agency_logo.png
100755 → 100644
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import org.opentripplanner.standalone.OTPServer;
import org.opentripplanner.standalone.Router;
import org.opentripplanner.updater.GraphUpdater;
import org.opentripplanner.updater.GraphUpdaterManager;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
Expand All @@ -19,40 +18,272 @@
@Produces(MediaType.APPLICATION_JSON)
public class UpdaterStatusResource {


private static final Logger LOG = LoggerFactory.getLogger(UpdaterStatusResource.class);

/** Choose short or long form of results. */
@QueryParam("detail") private boolean detail = false;
/**
* Choose short or long form of results.
*/
@QueryParam("detail")
private boolean detail = false;

Router router;

public UpdaterStatusResource (@Context OTPServer otpServer, @PathParam("routerId") String routerId) {
/**
*
* @param otpServer
* @param routerId id of the router
*/
public UpdaterStatusResource(@Context OTPServer otpServer, @PathParam("routerId") String routerId) {
router = otpServer.getRouter(routerId);
}

/** Return a list of all agencies in the graph. */
/**
*
* Returns view of the important data on real time status updates.
*
* @return general information about updates(errors of the updates, types
* of updates, received and applied updates)
*
*/
@GET
public Response getUpdaters () {
public Response getDescription() {
GraphUpdaterManager updaterManager = router.graph.updaterManager;
if (updaterManager == null) {
return Response.status(Response.Status.NOT_FOUND).entity("No updaters running.").build();
return Response.status(Response.Status.NOT_FOUND).entity("There are no updaters running.").build();
}
return Response.status(Response.Status.OK).entity(updaterManager.getUpdaterDescriptions()).build();
return Response.status(Response.Status.OK).entity(updaterManager.getDescription()).build();
}

/** Return status for a specific updater. */
/**
*
* Returns all agencies for specific feed.
* @param feedId id of the feed
* @return a list of all agencies in the graph for the specific feed,
* if such exist otherwise return null
*/
@GET
@Path("/agency/{feedId}")
public Response getAgencies(@PathParam("feedId") String feedId) {
GraphUpdaterManager updaterManager = router.graph.updaterManager;
if (updaterManager == null) {
return Response.status(Response.Status.NOT_FOUND).entity("There are no updaters running.").build();
}
return Response.status(Response.Status.OK).entity(updaterManager.getAgency(feedId)).build();
}

/**
*
* Returns information on specific updater.
* @param updaterId id of the updater
* @return Description for the updater with updater id.
* If such does not exist "Updater does not exist." is reported.
*/
@GET
@Path("/{updaterId}")
public Response getUpdaters (@PathParam("updaterId") int updaterId) {
public Response getTypeOfUpdater(@PathParam("updaterId") int updaterId) {
GraphUpdaterManager updaterManager = router.graph.updaterManager;
if (updaterManager == null) {
return Response.status(Response.Status.NOT_FOUND).entity("There are no updaters running.").build();
}
return Response.status(Response.Status.OK).entity(updaterManager.getUpdater(updaterId)).build();
}

/**
*
* Returns information on stream addresses.
* @return set of all correct stream addresses and list of information on all
* stream addresses.
*/
@GET
@Path("/stream")
public Response getStreamAddresses() {
GraphUpdaterManager updaterManager = router.graph.updaterManager;
if (updaterManager == null) {
return Response.status(Response.Status.NOT_FOUND).entity("There are no updaters running.").build();
}
return Response.status(Response.Status.OK).entity(updaterManager.getStreamAddresses()).build();
}

/**
*
* Returns types of updaters.
* @return a list of all types of updaters
*/
@GET
@Path("/types")
public Response getTypes() {
GraphUpdaterManager updaterManager = router.graph.updaterManager;
if (updaterManager == null) {
return Response.status(Response.Status.NOT_FOUND).entity("There are no updaters running.").build();
}
return Response.status(Response.Status.OK).entity(updaterManager.getAllTypes()).build();
}

/**
*
* Returns short information on the updater.
* @param updaterId id of the updater
* @return type of updater for updater id,
* if such does not exist "No updater." is reported
*/
@GET
@Path("/types/{id}")
public Response getTypePerId(@PathParam("id") int updaterId) {
GraphUpdaterManager updaterManager = router.graph.updaterManager;
if (updaterManager == null) {
return Response.status(Response.Status.NOT_FOUND).entity("No updaters running.").build();
return Response.status(Response.Status.NOT_FOUND).entity("There are no updaters running.").build();
}
GraphUpdater updater = updaterManager.getUpdater(updaterId);
if (updater == null) {
return Response.status(Response.Status.NOT_FOUND).entity("No updater with that ID.").build();
return Response.status(Response.Status.OK).entity(updaterManager.getType(updaterId)).build();
}

/**
*
* Returns a list of received updates.
* @return all updates grouped by trip id,
* exposing the number of times each trip was updated
*/
@GET
@Path("/updates")
public Response getUpdates() {
GraphUpdaterManager updaterManager = router.graph.updaterManager;
if (updaterManager == null) {
return Response.status(Response.Status.NOT_FOUND).entity("There are no updaters running.").build();
}
return Response.status(Response.Status.OK).entity(updaterManager.getReceived()).build();
}

/**
*
* Returns the number of updates per type.
*/
@GET
@Path("/updates/types")
public Response getUpdatesTypes() {
GraphUpdaterManager updaterManager = router.graph.updaterManager;
if (updaterManager == null) {
return Response.status(Response.Status.NOT_FOUND).entity("There are no updaters running.").build();
}
return Response.status(Response.Status.OK).entity(updaterManager.getUpdatesTypes()).build();
}

/**
* Returns the number of applied updates.
* @return the number of applied updates grouped by trip id
*/
@GET
@Path("/updates/applied")
public Response getApplied() {
GraphUpdaterManager updaterManager = router.graph.updaterManager;
if (updaterManager == null) {
return Response.status(Response.Status.NOT_FOUND).entity("There are no updaters running.").build();
}
return Response.status(Response.Status.OK).entity(updater.getClass()).build();
return Response.status(Response.Status.OK).entity(updaterManager.getApplied()).build();
}

/**
* Returns errors that occurred for non-applied updates.
* @return errors for updates grouped by its string representation
* exposing the number of occurrences for each error
*/
@GET
@Path("/updates/errors")
public Response getErrors() {
GraphUpdaterManager updaterManager = router.graph.updaterManager;
if (updaterManager == null) {
return Response.status(Response.Status.NOT_FOUND).entity("There are no updaters running.").build();
}
return Response.status(Response.Status.OK).entity(updaterManager.getErrors()).build();
}

/**
* Returns errors that occurred for last block of non-applied updates.
* @return errors for the last block of updates
*/
@GET
@Path("/updates/errors/last")
public Response getLastErrors() {
GraphUpdaterManager updaterManager = router.graph.updaterManager;
if (updaterManager == null) {
return Response.status(Response.Status.NOT_FOUND).entity("There are no updaters running.").build();
}
return Response.status(Response.Status.OK).entity(updaterManager.getLastErrors()).build();
}

/**
*
* Returns information on the last updated trip.
* @return time when update occurred, id of the trip being updated for
* each last received and last applied update
*/
@GET
@Path("/updates/last")
public Response getLastAppliedReceived() {
GraphUpdaterManager updaterManager = router.graph.updaterManager;
if (updaterManager == null) {
return Response.status(Response.Status.NOT_FOUND).entity("There are no updaters running.").build();
}
return Response.status(Response.Status.OK).entity(updaterManager.getLastAppliedReceived()).build();
}

/**
*
* Returns the ratio between received and applied updates.
* @return the number of received and applied updates
*/
@GET
@Path("/updates/ratio")
public Response getReceivedApplied() {
GraphUpdaterManager updaterManager = router.graph.updaterManager;
if (updaterManager == null) {
return Response.status(Response.Status.NOT_FOUND).entity("There are no updaters running.").build();
}
return Response.status(Response.Status.OK).entity(updaterManager.getReceivedApplied()).build();
}

/**
* Returns the number of applied updates for feed and trip.
* @param feedId id of the feed
* @param tripId id of the trip
* @return the number of updates for specific feed and trip, grouped by type
*/
@GET
@Path("/updates/applied/feed/{feedId}/trip/{tripId}")
public Response getUpdatesPerFeedPerTrip(@PathParam("feedId") String feedId, @PathParam("tripId") String tripId) {
GraphUpdaterManager updaterManager = router.graph.updaterManager;
if (updaterManager == null) {
return Response.status(Response.Status.NOT_FOUND).entity("There are no updaters running.").build();
}
return Response.status(Response.Status.OK).entity(updaterManager.getTypeAppliedPerFeedPerTrip(feedId, tripId)).build();
}

/**
* Returns the number of applied updates for provided feed.
* @param feedId id of the feed
* @return the number of applied updates for specific feed
*/
@GET
@Path("/updates/applied/feed/{feedId}")
public Response getAppliedPerFeed(@PathParam("feedId") String feedId) {
GraphUpdaterManager updaterManager = router.graph.updaterManager;
if (updaterManager == null) {
return Response.status(Response.Status.NOT_FOUND).entity("There are no updaters running.").build();
}
return Response.status(Response.Status.OK).entity(updaterManager.getAppliedPerFeed(feedId)).build();
}

/**
* Returns the information on applied updates not older than provided parameter.
* @param minutes the number of minutes (all updates older than 60 minutes are discarded)
* @return information about applied updates that occurred in the last number of minutes
*/
@GET
@Path("updates/applied/{lastMinutes}")
public Response getAppliedLastMinutes(@PathParam("lastMinutes") int minutes) {
GraphUpdaterManager updaterManager = router.graph.updaterManager;
if (updaterManager == null) {
return Response.status(Response.Status.NOT_FOUND).entity("There are no updaters running.").build();
}
return Response.status(Response.Status.OK).entity(updaterManager.getAppliedLastMinutes(minutes)).build();
}
}
14 changes: 12 additions & 2 deletions src/main/java/org/opentripplanner/routing/graph/Graph.java
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,8 @@ public class Graph implements Serializable {

public final Deduplicator deduplicator = new Deduplicator();

private static Set<String> correctStreamAddresses = new HashSet<>();

/**
* Map from GTFS ServiceIds to integers close to 0. Allows using BitSets instead of Set<Object>.
* An empty Map is created before the Graph is built to allow registering IDs from multiple feeds.
Expand Down Expand Up @@ -1033,7 +1035,7 @@ public SampleFactory getSampleFactory() {
*
* This speeds up calculation, but problem is that median needs to have all of latitudes/longitudes
* in memory, this can become problematic in large installations. It works without a problem on New York State.
* @see GraphEnvelope
* //@see GraphEnvelope
*/
public void calculateTransitCenter() {
if (hasTransit) {
Expand Down Expand Up @@ -1070,4 +1072,12 @@ public long getTransitServiceStarts() {
public long getTransitServiceEnds() {
return transitServiceEnds;
}
}

public Set<String> getCorrectStreamAddresses() {
return correctStreamAddresses;
}

public void addCorrectStreamAddress(String correctStreamAddress) {
correctStreamAddresses.add(correctStreamAddress);
}
}
24 changes: 14 additions & 10 deletions src/main/java/org/opentripplanner/routing/graph/GraphIndex.java
Original file line number Diff line number Diff line change
Expand Up @@ -563,16 +563,20 @@ public Timetable currentUpdatedTimetableForTripPattern (TripPattern tripPattern)
* stops -- no guessing is reasonable without that information.
*/
public void clusterStops() {
switch (graph.stopClusterMode) {
case "parentStation":
clusterByParentStation();
break;
case "proximity":
clusterByProximity();
break;
default:
clusterByProximity();
}
if (graph.stopClusterMode != null) {
switch (graph.stopClusterMode) {
case "parentStation":
clusterByParentStation();
break;
case "proximity":
clusterByProximity();
break;
default:
clusterByProximity();
}
} else {
clusterByProximity();
}
}

private void clusterByProximity() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,9 @@ the License, or (props, at your option) any later version.
/**
* Implements the default GTFS fare rules as described in
* http://groups.google.com/group/gtfs-changes/msg/4f81b826cb732f3b
*
*
* @author novalis
*
*
*/
public class DefaultFareServiceFactory implements FareServiceFactory {

Expand Down Expand Up @@ -111,9 +111,9 @@ public void configure(JsonNode config) {
/**
* Build a specific FareServiceFactory given the config node, or fallback to the default if none
* specified.
*
*
* Accept different formats. Examples:
*
*
* <pre>
* { fares : "seattle" }
* --------------------------
Expand Down Expand Up @@ -172,6 +172,9 @@ public static FareServiceFactory fromConfig(JsonNode config) {
case "bike-rental-time-based":
retval = new TimeBasedBikeRentalFareServiceFactory();
break;
case "dutch":
retval = new DutchFareServiceFactory();
break;
case "san-francisco":
retval = new SFBayFareServiceFactory();
break;
Expand Down
Loading