Skip to content

Commit

Permalink
Merge pull request #203 from HSLdevcom/DT-2551
Browse files Browse the repository at this point in the history
DT-2551
  • Loading branch information
pailakka authored May 16, 2018
2 parents 441b00e + f7007c6 commit ef750b8
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 14 deletions.
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@

/* This program is free software: you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public License
as published by the Free Software Foundation, either version 3 of
Expand All @@ -15,7 +16,6 @@ the License, or (at your option) any later version.

import java.awt.*;
import java.io.File;
import java.io.IOException;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.Collection;
Expand Down Expand Up @@ -95,9 +95,8 @@ public void buildGraph(Graph graph, HashMap<Class<?>, Object> extra) {

MultiCalendarServiceImpl service = new MultiCalendarServiceImpl();
GtfsStopContext stopContext = new GtfsStopContext();

try {
for (GtfsBundle gtfsBundle : gtfsBundles) {

for (GtfsBundle gtfsBundle : gtfsBundles) {
// apply global defaults to individual GTFSBundles (if globals have been set)
if (cacheDirectory != null && gtfsBundle.cacheDirectory == null)
gtfsBundle.cacheDirectory = cacheDirectory;
Expand Down Expand Up @@ -126,13 +125,10 @@ public void buildGraph(Graph graph, HashMap<Class<?>, Object> extra) {
}
if (gtfsBundle.linkStopsToParentStations) {
hf.linkStopsToParentStations(graph);
}
}
if (gtfsBundle.parentStationTransfers) {
hf.createParentStationTransfers();
}
}
} catch (IOException e) {
throw new RuntimeException(e);
}

// We need to save the calendar service data so we can use it later
Expand All @@ -149,9 +145,8 @@ public void buildGraph(Graph graph, HashMap<Class<?>, Object> extra) {
* Private Methods
****/

private void loadBundle(GtfsBundle gtfsBundle, Graph graph, GtfsMutableRelationalDao dao)
throws IOException {

private void loadBundle(GtfsBundle gtfsBundle, Graph graph, GtfsMutableRelationalDao dao) {
try {
StoreImpl store = new StoreImpl(dao);
store.open();
LOG.info("reading {}", gtfsBundle.toString());
Expand Down Expand Up @@ -225,8 +220,12 @@ private void loadBundle(GtfsBundle gtfsBundle, Graph graph, GtfsMutableRelationa
for (Pathway pathway : store.getAllEntitiesForType(Pathway.class)) {
pathway.getId().setAgencyId(reader.getDefaultAgencyId());
}

store.close();
} catch(Exception e) {
String msg=e.getMessage();
System.out.println(msg);
throw new RuntimeException(e);
}

}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,13 @@ public BikeRentalStation makeStation(JsonNode node) {
try {
station.y = Double.parseDouble(node.path("coordinates").asText().split(",")[0].trim());
station.x = Double.parseDouble(node.path("coordinates").asText().split(",")[1].trim());
station.bikesAvailable = node.path("avl_bikes").asInt();
station.spacesAvailable = node.path("free_slots").asInt();
if (station.state.equals("Station on")) {
station.bikesAvailable = node.path("avl_bikes").asInt();
station.spacesAvailable = node.path("free_slots").asInt();
} else {
station.bikesAvailable = 0;
station.spacesAvailable = 0;
}
return station;
} catch (NumberFormatException e) {
// E.g. coordinates is empty
Expand Down

0 comments on commit ef750b8

Please sign in to comment.