Skip to content

Commit

Permalink
Truncate route desc string (#42)
Browse files Browse the repository at this point in the history
  • Loading branch information
TsimurSh authored Sep 24, 2024
1 parent 0eccf5c commit c345299
Showing 1 changed file with 10 additions and 2 deletions.
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);
}
}

0 comments on commit c345299

Please sign in to comment.