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

feat: 1776 add flex features to list #1780

Merged
merged 19 commits into from
Sep 9, 2024
Merged
Show file tree
Hide file tree
Changes from 17 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
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,9 @@ public class FeedMetadata {
new Pair<>("Zone-Based Fares", GtfsArea.FILENAME),
new Pair<>("Transfer Fares", GtfsFareTransferRule.FILENAME),
new Pair<>("Time-Based Fares", GtfsTimeframe.FILENAME),
new Pair<>("Levels", GtfsLevel.FILENAME));
new Pair<>("Levels", GtfsLevel.FILENAME),
new Pair<>("Booking Rules", GtfsBookingRules.FILENAME),
new Pair<>("Fixed-Stops Demand Responsive Transit", GtfsLocationGroups.FILENAME));

protected FeedMetadata() {}

Expand Down Expand Up @@ -156,6 +158,60 @@ private void loadSpecFeaturesBasedOnFieldPresence(GtfsFeedContainer feedContaine
loadPathwayExtraFeature(feedContainer);
loadRouteBasedFaresFeature(feedContainer);
loadContinuousStopsFeature(feedContainer);
loadZoneBasedDemandResponsiveTransitFeature(feedContainer);
loadDeviatedFixedRouteFeature(feedContainer);
}

private void loadDeviatedFixedRouteFeature(GtfsFeedContainer feedContainer) {
specFeatures.put("Deviated Fixed Route", hasAtLeastOneTripWithAllFields(feedContainer));
}

private boolean hasAtLeastOneTripWithAllFields(GtfsFeedContainer feedContainer) {
Optional<GtfsTableContainer<?>> optionalStopTimeTable =
feedContainer.getTableForFilename(GtfsStopTime.FILENAME);
if (optionalStopTimeTable.isPresent()) {
for (GtfsEntity entity : optionalStopTimeTable.get().getEntities()) {
if (entity instanceof GtfsStopTime) {
GtfsStopTime stopTime = (GtfsStopTime) entity;
return stopTime.hasTripId()
&& stopTime.tripId() != null
&& stopTime.hasLocationId()
&& stopTime.locationId() != null
&& stopTime.hasStopId()
&& stopTime.stopId() != null
&& stopTime.hasArrivalTime()
&& stopTime.arrivalTime() != null
&& stopTime.hasDepartureTime()
&& stopTime.departureTime() != null;
}
}
}
return false;
}

private void loadZoneBasedDemandResponsiveTransitFeature(GtfsFeedContainer feedContainer) {
specFeatures.put(
"Zone-Based Demand Responsive Transit", hasAtLeastOneTripWithOnlyLocationId(feedContainer));
}

private boolean hasAtLeastOneTripWithOnlyLocationId(GtfsFeedContainer feedContainer) {
Optional<GtfsTableContainer<?>> optionalStopTimeTable =
feedContainer.getTableForFilename(GtfsStopTime.FILENAME);
if (optionalStopTimeTable.isPresent()) {
for (GtfsEntity entity : optionalStopTimeTable.get().getEntities()) {
if (entity instanceof GtfsStopTime) {
GtfsStopTime stopTime = (GtfsStopTime) entity;
if (stopTime.hasTripId()
&& stopTime.tripId() != null
&& stopTime.hasLocationId()
&& stopTime.locationId() != null
&& (!stopTime.hasStopId() || stopTime.stopId() == null)) {
return true;
}
}
}
}
return false;
}

private void loadContinuousStopsFeature(GtfsFeedContainer feedContainer) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
package org.mobilitydata.gtfsvalidator.table;

import org.mobilitydata.gtfsvalidator.annotation.ConditionallyRequired;
import org.mobilitydata.gtfsvalidator.annotation.FieldType;
import org.mobilitydata.gtfsvalidator.annotation.FieldTypeEnum;
import org.mobilitydata.gtfsvalidator.annotation.GtfsTable;
import org.mobilitydata.gtfsvalidator.annotation.MixedCase;
import org.mobilitydata.gtfsvalidator.annotation.PrimaryKey;
import org.mobilitydata.gtfsvalidator.annotation.Required;
import org.mobilitydata.gtfsvalidator.type.GtfsTime;

@GtfsTable("booking_rules.txt")
public interface GtfsBookingRulesSchema extends GtfsEntity {
@FieldType(FieldTypeEnum.ID)
@PrimaryKey
@Required
String bookingRuleId();

@Required
GtfsBookingType bookingType();

@ConditionallyRequired
int priorNoticeDurationMin();

@ConditionallyRequired
int priorNoticeDurationMax();

@ConditionallyRequired
int priorNoticeStartDay();

@ConditionallyRequired
GtfsTime priorNoticeStartTime();

@ConditionallyRequired
int priorNoticeLastDay();

@ConditionallyRequired
GtfsTime priorNoticeLastTime();

@ConditionallyRequired
String priorNoticeServiceId();

@MixedCase
String message();

@MixedCase
String pickupMessage();

@MixedCase
String dropOffMessage();

@FieldType(FieldTypeEnum.PHONE_NUMBER)
String phoneNumber();

@FieldType(FieldTypeEnum.URL)
String infoUrl();

@FieldType(FieldTypeEnum.URL)
String bookingUrl();
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
/*
* Copyright 2020 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.mobilitydata.gtfsvalidator.table;

import org.mobilitydata.gtfsvalidator.annotation.GtfsEnumValue;

@GtfsEnumValue(name = "REALTIME", value = 0)
@GtfsEnumValue(name = "SAMEDAY", value = 1)
@GtfsEnumValue(name = "PRIORDAY", value = 2)
public interface GtfsBookingTypeEnum {}
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package org.mobilitydata.gtfsvalidator.table;

import org.mobilitydata.gtfsvalidator.annotation.FieldType;
import org.mobilitydata.gtfsvalidator.annotation.FieldTypeEnum;
import org.mobilitydata.gtfsvalidator.annotation.GtfsTable;
import org.mobilitydata.gtfsvalidator.annotation.MixedCase;
import org.mobilitydata.gtfsvalidator.annotation.PrimaryKey;
import org.mobilitydata.gtfsvalidator.annotation.Required;

@GtfsTable("location_groups.txt")
public interface GtfsLocationGroupsSchema extends GtfsEntity {
@FieldType(FieldTypeEnum.ID)
@PrimaryKey
@Required
String locationGroupId();

@MixedCase
String locationGroupName();
}
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,12 @@ public interface GtfsStopTimeSchema extends GtfsEntity {

@FieldType(FieldTypeEnum.ID)
@Index
@Required
@ForeignKey(table = "stops.txt", field = "stop_id")
qcdyx marked this conversation as resolved.
Show resolved Hide resolved
String stopId();

@FieldType(FieldTypeEnum.ID)
String locationId();

@PrimaryKey(isSequenceUsedForSorting = true, translationRecordIdType = RECORD_SUB_ID)
@Required
@NonNegative
Expand Down
1 change: 1 addition & 0 deletions web/client/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,4 @@ vite.config.ts.timestamp-*
rules.json
cypress/screenshots/
cypress/videos/
web/client/static
qcdyx marked this conversation as resolved.
Show resolved Hide resolved
Loading