diff --git a/GO_Sync/src/main/java/edu/usf/cutr/go_sync/object/RouteVariant.java b/GO_Sync/src/main/java/edu/usf/cutr/go_sync/object/RouteVariant.java index d75f75c7..557c6613 100644 --- a/GO_Sync/src/main/java/edu/usf/cutr/go_sync/object/RouteVariant.java +++ b/GO_Sync/src/main/java/edu/usf/cutr/go_sync/object/RouteVariant.java @@ -159,10 +159,19 @@ private Duration getDurationAsDuration() { String tripDepartureTime = stops.get(firstStopIndex).getDeparture_time(); Integer lastStopIndex = Collections.max(stops.keySet()); String tripArrivalTime = stops.get(lastStopIndex).getArrival_time(); + try { + LocalTime tripDepartureTimeLT = LocalTime.parse(tripDepartureTime, DateTimeFormatter.ofPattern("HH:mm:ss")); + LocalTime tripArrivalTimeLT = LocalTime.parse(tripArrivalTime, DateTimeFormatter.ofPattern("HH:mm:ss")); + return Duration.between(tripDepartureTimeLT, tripArrivalTimeLT); + }catch(Exception e) + { + //TODO handle overnight values properly + System.out.println(e); + System.out.println(e.getStackTrace()); + e.printStackTrace(); + return Duration.ZERO; + } - LocalTime tripDepartureTimeLT = LocalTime.parse(tripDepartureTime, DateTimeFormatter.ofPattern("HH:mm:ss")); - LocalTime tripArrivalTimeLT = LocalTime.parse(tripArrivalTime, DateTimeFormatter.ofPattern("HH:mm:ss")); - return Duration.between(tripDepartureTimeLT, tripArrivalTimeLT); } public String getDuration() { diff --git a/GO_Sync/src/main/java/edu/usf/cutr/go_sync/task/CompareData.java b/GO_Sync/src/main/java/edu/usf/cutr/go_sync/task/CompareData.java index b1f5147f..f50a86fc 100644 --- a/GO_Sync/src/main/java/edu/usf/cutr/go_sync/task/CompareData.java +++ b/GO_Sync/src/main/java/edu/usf/cutr/go_sync/task/CompareData.java @@ -37,6 +37,8 @@ import java.util.TreeMap; import java.util.TreeSet; import java.util.Map; +import java.util.concurrent.ConcurrentHashMap; +import java.util.concurrent.atomic.AtomicInteger; import javax.swing.JTextArea; import javax.swing.ProgressMonitor; @@ -93,10 +95,16 @@ public class CompareData extends OsmTask{ // key is gtfs, value is container of potential osm matches, sorted by distance from gtfs stop private Hashtable> report = new Hashtable>(); - private HashSet noUpload = new HashSet(); - private HashSet upload = new HashSet(); - private HashSet modify = new HashSet(); - private HashSet delete = new HashSet(); + + + private ConcurrentHashMap.KeySetView noUpload = ConcurrentHashMap.newKeySet(); + private ConcurrentHashMap.KeySetView upload = ConcurrentHashMap.newKeySet(); + private ConcurrentHashMap.KeySetView modify = ConcurrentHashMap.newKeySet(); + private ConcurrentHashMap.KeySetView delete = ConcurrentHashMap.newKeySet(); +// private HashSet noUpload = new HashSet(); +// private HashSet upload = new HashSet(); +// private HashSet modify = new HashSet(); +// private HashSet delete = new HashSet(); private Hashtable routes = new Hashtable(); private Hashtable agencyRoutes = new Hashtable(); private Hashtable existingRoutes = new Hashtable(); @@ -107,8 +115,8 @@ public class CompareData extends OsmTask{ private double minLat=0, minLon=0, maxLat=0, maxLon=0; private HttpRequest osmRequest; private HashSet osmActiveUsers = new HashSet(); - private Hashtable osmIdToGtfsId = new Hashtable(); - private HashMap osmIdToOSMNodexIndex = new HashMap<>(); + private ConcurrentHashMap osmIdToGtfsId = new ConcurrentHashMap(); + private ConcurrentHashMap osmIdToOSMNodexIndex = new ConcurrentHashMap<>(); private HashMap osmRouteVariantScoreByGtfsRoute = new HashMap<>();; // OsmIndex - List of GtfsMatches @@ -603,7 +611,7 @@ public void compareRouteData() throws InterruptedException{ osmStopTypeByGtfsStopId.put(gtfs_id.toString(), OSMNodes.get(i).geOsmPrimitiveType()); } } - + System.out.println(" for (HashMap.Entry rv_entry : allRouteVariants.entrySet())"); for (HashMap.Entry rv_entry : allRouteVariants.entrySet()) { RouteVariant rv = rv_entry.getValue(); //Route r = new Route(rv.getOsmValue("gtfs:route_id"), rv.getOsmValue("ref"), OperatorInfo.getFullName()); @@ -708,7 +716,8 @@ public void compareRouteData() throws InterruptedException{ routesByShortName.put(ri.getRouteRef(),ri);} catch (Exception e) { - System.out.println(e); + System.out.println("exception\t" + e); + System.out.println(e.getStackTrace()); e.printStackTrace(); } // routesByShortName.put(ri.getTag("route_short_name"),ri); @@ -755,7 +764,7 @@ public void compareRouteData() throws InterruptedException{ if (network != null) ostring = network; else ostring = operator; - + Route er; er = new Route(tripId, routeShortName, ostring); @@ -1002,16 +1011,19 @@ public void compareBusStopData() throws InterruptedException { progressToUpdate = 50/totalOsmNode; } int currentTotalProgress=0; - for (int osmindex=0; osmindex { + int osmindex = OSMTags.indexOf(osmtag); if(this.flagIsDone) return; - if((osmindex%timeToUpdate)==0) { - currentTotalProgress += progressToUpdate; + osmprog.getAndIncrement(); + if((osmprog.get()%timeToUpdate)==0) { +// currentTotalProgress += progressToUpdate; updateProgress(progressToUpdate); - this.setMessage("Comparing "+osmindex+"/"+totalOsmNode+" ..."); + this.setMessage("Comparing "+osmprog.get()+"/"+totalOsmNode+" ..."); } - Hashtable osmtag = new Hashtable(); - osmtag.putAll(OSMTags.get(osmindex)); +// Hashtable osmtag = new Hashtable(OSMTags.get(osmindex)); String osmOperator = (String)osmtag.get(tag_defs.OSM_NETWORK_KEY); String osmStopID = (String)osmtag.get("gtfs_id"); String osmPlatformType = (String)osmtag.get(tag_defs.OSM_STOP_TYPE_KEY); @@ -1235,7 +1247,7 @@ public void compareBusStopData() throws InterruptedException { } } } - } + }); // set OSM value to all stops in modify category setStopWithOsmDataDefault(); //make sure is 50% overall @@ -1335,6 +1347,9 @@ public void startCompare() throws InterruptedException{ ArrayList tempOSMRelations = osmRequest.getExistingBusRelations(Double.toString(minLon), Double.toString(minLat), Double.toString(maxLon), Double.toString(maxLat)); if(this.flagIsDone) return; + long tDelta = System.currentTimeMillis() - tStart; + System.out.println("OSM Downloads Completed in "+ tDelta /1000.0 + "seconds"); + tStart = System.currentTimeMillis(); progressMonitor.setNote(""); if (tempOSMNodes!=null) { OSMNodes.addAll(tempOSMNodes); @@ -1460,7 +1475,13 @@ public void generateReport(){ arr.addAll(entry.getValue()); reportArrays.put(key, arr); } - ReportViewer rv = new ReportViewer(GTFSstops, reportArrays, upload, modify, delete, reportRoute, routes, agencyRoutes, existingRoutes, taskOutput); + + ReportViewer rv = new ReportViewer(GTFSstops, reportArrays, + new HashSet(upload), + new HashSet(modify), + new HashSet(delete), + reportRoute, routes, agencyRoutes, existingRoutes, taskOutput); +// ReportViewer rv = new ReportViewer(GTFSstops, reportArrays, upload, modify, delete, routes, agencyRoutes, existingRoutes, taskOutput); String info = "Active OSM bus stop mappers:\n"+osmActiveUsers.toString()+"\n\n"; info += "There are currently "+OSMNodes.size()+" OSM stops in the region\n\n"; info += "Transit agency GTFS dataset has "+GTFSstops.size()+" stops";