Skip to content

Commit

Permalink
Merge pull request #225 from OneBusAway/OTD-530-include-alternate_sto…
Browse files Browse the repository at this point in the history
…p_names_exc

Included alternate_stop_names_exceptions.txt in GTFS
  • Loading branch information
sheldonabrown authored Oct 10, 2023
2 parents 19ab954 + d891ab6 commit 99c493b
Show file tree
Hide file tree
Showing 7 changed files with 120 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,7 @@ public Level getLevelForId(AgencyAndId id) {
public FacilityPropertyDefinition getFacilityPropertiesDefinitionsForId(AgencyAndId id) { return getEntityForId(FacilityPropertyDefinition.class, id);}
public RouteNameException getRouteNameExceptionForId(AgencyAndId id) { return getEntityForId(RouteNameException.class, id);}
public DirectionNameException getDirectionNameExceptionForId(AgencyAndId id) { return getEntityForId(DirectionNameException.class, id);}
public AlternateStopNameException getAlternateStopNameExceptionForId(AgencyAndId id) { return getEntityForId(AlternateStopNameException.class, id);}

public Collection<DirectionEntry> getAllDirectionEntries() {
return getAllEntitiesForType(DirectionEntry.class);
Expand All @@ -279,6 +280,9 @@ public Collection<RouteNameException> getAllRouteNameExceptions() {
public Collection<DirectionNameException> getAllDirectionNameExceptions() {
return getAllEntitiesForType(DirectionNameException.class);
}
public Collection<AlternateStopNameException> getAllAlternateStopNameExceptions(){
return getAllEntitiesForType(AlternateStopNameException.class);
}

public Collection<WrongWayConcurrency> getAllWrongWayConcurrencies() {
return getAllEntitiesForType(WrongWayConcurrency.class);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -513,7 +513,7 @@ public void setData(CalendarServiceData data) {
public FacilityPropertyDefinition getFacilityPropertiesDefinitionsForId(AgencyAndId id) { return getEntityForId(FacilityPropertyDefinition.class, id);}
public RouteNameException getRouteNameExceptionForId(AgencyAndId id) { return getEntityForId(RouteNameException.class, id);}
public DirectionNameException getDirectionNameExceptionForId(AgencyAndId id) { return getEntityForId(DirectionNameException.class, id);}

public AlternateStopNameException getAlternateStopNameExceptionForId(AgencyAndId id) { return getEntityForId(AlternateStopNameException.class, id);}
public Collection<Facility> getAllFacilities() {
return getAllEntitiesForType(Facility.class);
}
Expand All @@ -529,6 +529,9 @@ public Collection<RouteNameException> getAllRouteNameExceptions() {
public Collection<DirectionNameException> getAllDirectionNameExceptions() {
return getAllEntitiesForType(DirectionNameException.class);
}
public Collection<AlternateStopNameException> getAllAlternateStopNameExceptions(){
return getAllEntitiesForType(AlternateStopNameException.class);
}
public Collection<DirectionEntry> getAllDirectionEntries() {
return _dao.getAllDirectionEntries();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,8 @@ public class TranslationServiceDataFactoryImpl implements TranslationServiceData

private static final String DIRECTION_ENTRY_TABLE_NAME = "direction_entry";

private static final String ALTERNATE_STOP_NAME_EXCEPTION_TABLE_NAME = "alternate_stop_name_exception";

private GtfsRelationalDao _dao;

public static TranslationService getTranslationService(GtfsRelationalDao dao) {
Expand Down Expand Up @@ -136,6 +138,8 @@ private Class<?> getEntityTypeForTableName(String name) {
return WrongWayConcurrency.class;
case DIRECTION_ENTRY_TABLE_NAME:
return DirectionEntry.class;
case ALTERNATE_STOP_NAME_EXCEPTION_TABLE_NAME:
return AlternateStopNameException.class;
}
return null;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
/**
* Copyright (C) 2022 Cambridge Systematics <[email protected]>
*
* 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.onebusaway.gtfs.model;

import org.onebusaway.csv_entities.schema.annotations.CsvField;
import org.onebusaway.csv_entities.schema.annotations.CsvFields;

@CsvFields(filename = "alternate_stop_names_exceptions.txt", required = false)
public class AlternateStopNameException extends IdentityBean<Integer> {

@CsvField(ignore = true)
private int id;

@CsvField(optional = true)
int routeId;

@CsvField(optional = true)
int directionId;

@CsvField(optional = true)
int stopId;

@CsvField(optional = true)
String alternateStopName;

public AlternateStopNameException() {
}

public AlternateStopNameException(AlternateStopNameException asne) {
this.routeId = asne.routeId;
this.directionId = asne.directionId;
this.stopId = asne.stopId;
this.alternateStopName = asne.alternateStopName;
}


@Override
public Integer getId() {
return id;
}

@Override
public void setId(Integer id) {
this.id = id;
}

public int getRouteId() {
return routeId;
}

public void setRouteId(int routeId) {
this.routeId = routeId;
}

public int getDirectionId() {
return directionId;
}

public void setDirectionId(int directionId) {
this.directionId = directionId;
}

public int getStopId() {
return stopId;
}

public void setStopId(int stopId) {
this.stopId = stopId;
}

public String getAlternateStopName() {
return alternateStopName;
}

public void setAlternateStopName(String alternateStopName) {
this.alternateStopName = alternateStopName;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package org.onebusaway.gtfs.model;

import org.onebusaway.csv_entities.schema.annotations.CsvField;
import org.onebusaway.csv_entities.schema.annotations.CsvFields;

@CsvFields(filename = "alternate_stop_names_exceptions.txt", required = false)
public class Alternate_stop_names_exceptions {

@CsvField(ignore = true)
private int id;

@CsvField(optional = true)
int routeId;
}
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ public static List<Class<?>> getEntityClasses() {
entityClasses.add(DirectionNameException.class);
entityClasses.add(WrongWayConcurrency.class);
entityClasses.add(DirectionEntry.class);
entityClasses.add(AlternateStopNameException.class);
return entityClasses;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ public GtfsReader() {
_entityClasses.add(DirectionNameException.class);
_entityClasses.add(WrongWayConcurrency.class);
_entityClasses.add(DirectionEntry.class);
_entityClasses.add(AlternateStopNameException.class);

CsvTokenizerStrategy tokenizerStrategy = new CsvTokenizerStrategy();
tokenizerStrategy.getCsvParser().setTrimInitialWhitespace(true);
Expand Down

0 comments on commit 99c493b

Please sign in to comment.