use of org.opentripplanner.util.WorldEnvelope in project OpenTripPlanner by opentripplanner.
the class Graph method calculateEnvelope.
/**
* Calculates envelope out of all OSM coordinates
*
* Transit stops are added to the envelope as they are added to the graph
*/
public void calculateEnvelope() {
this.envelope = new WorldEnvelope();
for (Vertex v : this.getVertices()) {
Coordinate c = v.getCoordinate();
this.envelope.expandToInclude(c);
}
}
use of org.opentripplanner.util.WorldEnvelope in project OpenTripPlanner by opentripplanner.
the class Router method startup.
/**
* Below is functionality moved into Router from the "router lifecycle manager" interface and implementation.
* Current responsibilities are: 1) Binding proper services (depending on the configuration from command-line or
* JSON config files) and 2) starting / stopping real-time updaters (delegated to the GraphUpdaterConfigurator class).
*/
/**
* Start up a new router once it has been created.
* @param config The configuration (loaded from Graph.properties for example).
*/
public void startup(JsonNode config) {
this.tileRendererManager = new TileRendererManager(this.graph);
// Analyst Modules FIXME make these optional based on JSON?
{
this.tileCache = new TileCache(this.graph);
this.renderer = new Renderer(this.tileCache);
this.sampleGridRenderer = new SampleGridRenderer(this.graph);
this.isoChroneSPTRenderer = new IsoChroneSPTRendererAccSampling(this.sampleGridRenderer);
}
/* Create the default router parameters from the JSON router config. */
JsonNode routingDefaultsNode = config.get("routingDefaults");
if (routingDefaultsNode != null) {
LOG.info("Loading default routing parameters from JSON:");
ReflectiveInitializer<RoutingRequest> scraper = new ReflectiveInitializer(RoutingRequest.class);
this.defaultRoutingRequest = scraper.scrape(routingDefaultsNode);
} else {
LOG.info("No default routing parameters were found in the router config JSON. Using built-in OTP defaults.");
this.defaultRoutingRequest = new RoutingRequest();
}
/* Apply single timeout. */
JsonNode timeout = config.get("timeout");
if (timeout != null) {
if (timeout.isNumber()) {
this.timeouts = new double[] { timeout.doubleValue() };
} else {
LOG.error("The 'timeout' configuration option should be a number of seconds.");
}
}
/* Apply multiple timeouts. */
JsonNode timeouts = config.get("timeouts");
if (timeouts != null) {
if (timeouts.isArray() && timeouts.size() > 0) {
this.timeouts = new double[timeouts.size()];
int i = 0;
for (JsonNode node : timeouts) {
this.timeouts[i++] = node.doubleValue();
}
} else {
LOG.error("The 'timeouts' configuration option should be an array of values in seconds.");
}
}
LOG.info("Timeouts for router '{}': {}", this.id, this.timeouts);
JsonNode requestLogFile = config.get("requestLogFile");
if (requestLogFile != null) {
this.requestLogger = createLogger(requestLogFile.asText());
LOG.info("Logging incoming requests at '{}'", requestLogFile.asText());
} else {
LOG.info("Incoming requests will not be logged.");
}
JsonNode boardTimes = config.get("boardTimes");
if (boardTimes != null && boardTimes.isObject()) {
graph.boardTimes = new EnumMap<>(TraverseMode.class);
for (TraverseMode mode : TraverseMode.values()) {
if (boardTimes.has(mode.name())) {
graph.boardTimes.put(mode, boardTimes.get(mode.name()).asInt(0));
}
}
}
JsonNode alightTimes = config.get("alightTimes");
if (alightTimes != null && alightTimes.isObject()) {
graph.alightTimes = new EnumMap<>(TraverseMode.class);
for (TraverseMode mode : TraverseMode.values()) {
if (alightTimes.has(mode.name())) {
graph.alightTimes.put(mode, alightTimes.get(mode.name()).asInt(0));
}
}
}
JsonNode stopClusterMode = config.get("stopClusterMode");
if (stopClusterMode != null) {
graph.stopClusterMode = stopClusterMode.asText();
} else {
graph.stopClusterMode = "proximity";
}
/* Create Graph updater modules from JSON config. */
GraphUpdaterConfigurator.setupGraph(this.graph, config);
/* Compute ellipsoidToGeoidDifference for this Graph */
try {
WorldEnvelope env = graph.getEnvelope();
double lat = (env.getLowerLeftLatitude() + env.getUpperRightLatitude()) / 2;
double lon = (env.getLowerLeftLongitude() + env.getUpperRightLongitude()) / 2;
graph.ellipsoidToGeoidDifference = ElevationUtils.computeEllipsoidToGeoidDifference(lat, lon);
LOG.info("Computed ellipsoid/geoid offset at (" + lat + ", " + lon + ") as " + graph.ellipsoidToGeoidDifference);
} catch (Exception e) {
LOG.error("Error computing ellipsoid/geoid difference");
}
}
Aggregations