Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Truncate route desc string #42

Merged
merged 1 commit into from
Sep 24, 2024
Merged
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
12 changes: 10 additions & 2 deletions core/src/main/java/org/transitclock/gtfs/model/GtfsRoute.java
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,9 @@ public class GtfsRoute extends CsvBase {
private final Integer breakTime;
private final Double maxDistance;

/** For creating a GtfsStop object from scratch. */
/**
* For creating a GtfsStop object from scratch.
*/
public GtfsRoute(
String routeId,
String agencyId,
Expand Down Expand Up @@ -86,7 +88,9 @@ public GtfsRoute(CSVRecord record, boolean supplementalFile, String fileName) {
agencyId = getOptionalValue(record, "agency_id");
routeShortName = getOptionalValue(record, "route_short_name");
routeLongName = getOptionalValue(record, "route_long_name");
routeDesc = getOptionalValue(record, "route_desc");
routeDesc = getOptionalValue(record, "route_desc").length() < 1024
? getOptionalValue(record, "route_desc")
: truncateToLimitSize(getOptionalValue(record, "route_desc"), 1024);
routeType = getRequiredUnlessSupplementalValue(record, "route_type");
routeURL = getOptionalValue(record, "route_url");
routeColor = getOptionalValue(record, "route_color");
Expand Down Expand Up @@ -176,4 +180,8 @@ public boolean getHidden() {
public boolean shouldCreateUnscheduledBlock() {
return unscheduledBlockSuffix != null;
}

private String truncateToLimitSize(String toTruncate, int maxSize) {
return toTruncate.substring(0, maxSize);
}
}
Loading