Improve data
This commit is contained in:
parent
b4d66a28c1
commit
85da1941aa
31 changed files with 901 additions and 319 deletions
|
|
@ -10,7 +10,9 @@ import java.nio.file.DirectoryStream;
|
|||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.nio.file.Paths;
|
||||
import java.time.DayOfWeek;
|
||||
import java.time.LocalDate;
|
||||
import java.time.temporal.TemporalAdjusters;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Comparator;
|
||||
import java.util.HashSet;
|
||||
|
|
@ -124,9 +126,15 @@ public class App {
|
|||
Path outDir = Paths.get(outputDirStr);
|
||||
Files.createDirectories(outDir);
|
||||
|
||||
LocalDate today = LocalDate.now();
|
||||
// Always route on a representative WEEKDAY (Monday), not the day the job
|
||||
// happens to start: a commute search must reflect a typical weekday
|
||||
// service pattern, and the 07:45-08:15 peak window paired with a weekend
|
||||
// calendar (e.g. a Saturday run) understated frequencies and overstated
|
||||
// transit times. --date=YYYY-MM-DD overrides for testing/holidays.
|
||||
LocalDate routingDate = resolveRoutingDate(args);
|
||||
System.err.printf("Routing date: %s (%s)%n", routingDate, routingDate.getDayOfWeek());
|
||||
TransportNetwork network = Router.loadNetwork(requiredEnv("DATA_DIR"), requiredEnv("NETWORK_CACHE_DIR"));
|
||||
Router.validateTransitServices(network, today);
|
||||
Router.validateTransitServices(network, routingDate);
|
||||
|
||||
System.err.println("Loading postcodes (England only)...");
|
||||
Parquet.Postcodes postcodes = Parquet.loadEnglandPostcodes(
|
||||
|
|
@ -224,7 +232,7 @@ public class App {
|
|||
int modeThreads = threadsForMode(mode, threads);
|
||||
processMode(network, postcodeIndex, transitTiles,
|
||||
postcodes.codes(), postcodes.lats(), postcodes.lons(),
|
||||
originNames, originLats, originLons, outDir, mode, today,
|
||||
originNames, originLats, originLons, outDir, mode, routingDate,
|
||||
modeThreads, writeQueue, enablePaths, originIndices, skipCompleted);
|
||||
}
|
||||
} finally {
|
||||
|
|
@ -544,6 +552,28 @@ public class App {
|
|||
return defaultValue;
|
||||
}
|
||||
|
||||
/**
|
||||
* Resolve the date to route on. Defaults to the next-or-same Monday relative
|
||||
* to today (a representative weekday close enough to "now" to stay within the
|
||||
* GTFS calendar window), so transit times reflect a typical weekday commute
|
||||
* rather than whatever day the batch job started. An explicit
|
||||
* {@code --date=YYYY-MM-DD} (or {@code --date YYYY-MM-DD}) overrides this.
|
||||
*/
|
||||
static LocalDate resolveRoutingDate(String[] args) {
|
||||
for (int i = 0; i < args.length; i++) {
|
||||
String value = null;
|
||||
if (args[i].startsWith("--date=")) {
|
||||
value = args[i].substring("--date=".length());
|
||||
} else if (args[i].equals("--date") && i + 1 < args.length) {
|
||||
value = args[i + 1];
|
||||
}
|
||||
if (value != null && !value.isBlank()) {
|
||||
return LocalDate.parse(value.trim());
|
||||
}
|
||||
}
|
||||
return LocalDate.now().with(TemporalAdjusters.nextOrSame(DayOfWeek.MONDAY));
|
||||
}
|
||||
|
||||
/**
|
||||
* Filter place indices to those near at least one England postcode.
|
||||
* Uses a 0.1° grid (~11km cells) built from postcode locations — a place is kept
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue