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

GtfsWriter not ignoring FareAttribute's optional columns #72

Open
russellhoff opened this issue May 19, 2016 · 6 comments
Open

GtfsWriter not ignoring FareAttribute's optional columns #72

russellhoff opened this issue May 19, 2016 · 6 comments

Comments

@russellhoff
Copy link

I've been able to ignore extra columns for Agency, for instance, as follows:

`
private Agency agency;

// ...

List<Object> agenciesObjects = new ArrayList<Object>();

agenciesObjects.add(agency);

writer.excludeOptionalAndMissingFields(Agency.class, agenciesObjects);

writer.handleEntity(agency);

`

But, when it comes to ignore optional columns for FareAttributes, there are two columns which aren't ignored when generating TXTs. This is the piece of code regarding Fares:

`
private List fares;
// ...
// Fares
logHelper.logMessage("\t[11.5] Construyendo fare_attributes.txt y fare_rules.txt...");

    List<Object> faresObjects = new ArrayList<Object>();
    List<Object> faresAttributesObjects = new ArrayList<Object>();
    for(FareRule fr : fares){
        faresObjects.add(fr);
        faresAttributesObjects.add(fr.getFare());
    }
    writer.excludeOptionalAndMissingFields(FareAttribute.class, faresAttributesObjects);
    writer.excludeOptionalAndMissingFields(FareRule.class, faresObjects);

    fares.forEach((fare)->{
        writer.handleEntity(fare.getFare());
        writer.handleEntity(fare);
    });
    `

Is that a bug or not?

@russellhoff
Copy link
Author

Anybody?

@russellhoff
Copy link
Author

Still undergoing that issue.

@russellhoff
Copy link
Author

New attribute eligibilityRestricted is not being ignored.

@sheldonabrown
Copy link
Member

Hi Russell,

can you attach a sample GTFS that demonstrates the issue, and tell us a bit more about your use case? Are you using the GTFS Transformer CLI?

And sorry for the delay in responding ...

Sheldon

@russellhoff
Copy link
Author

Hi @sheldonabrown,

No worries, I understand the delay. In the latest version of onebusaway-gtfs-modules, 1.3.48, attribute eligibilityRestricted isn't only being ignored, but I never set it to any value.

For instance, when it comes to the creation of Routes, I create them that way:

public class GtfsDataBuilderWS extends GTFSDataBuilder {
	// ...
	private List<Route> routes;
	// ...
@Override
	public void buildAll(String pCodigoOperador) throws Throwable {
		// ...
		routesBuilder();
		// ...
		buildFile();
	}
	// ...
	@Override
	protected void routesBuilder() throws Exception {
		logHelper.logMessage("\t[4] Construyendo Route...");
		
		LineasDTO lineas = imp.importarLineas(codigoOperador);
		routes = new ArrayList<Route>();
		shapes = new HashMap<String, ShapePointArray>();
		
		Route aRoute = null;
		AgencyAndId theId = null;
		for(LineaDTO linea : lineas.getListaLineas()){
			aRoute = new Route();
			theId = new AgencyAndId(codigoOperador, linea.getCodigoLinea());
			aRoute.setAgency(agency);
			aRoute.setId(theId);
			aRoute.setShortName(linea.getDescripcionCorta());
			aRoute.setLongName(linea.getDescripcionLarga());
			aRoute.setType(3); 
			tripsBuilder(linea.getCodigoLinea(), aRoute);
			aRoute = maestrosSobrescribir.sobrescribirRoute(codigoOperador, aRoute);
			routes.add(aRoute);
		}
		
		logHelper.logMessage("\t[4] Route construido.");
	}

	private void buildFile() throws SecurityException, IOException {
		GtfsWriter writer = new GtfsWriter();
		PropertiesConfiguration config = GenerarGtfs.getPropConfig();
		String path = config.getRoot_export_dir() + File.separator + config.getFolder(codigoOperador);
		File outputDir = new File(path);
		if(outputDir.exists()){
			if(outputDir.isDirectory()){
				FileUtils.deleteDirectory(outputDir);
			}
		}else{
			outputDir.mkdirs();
		}
		writer.setOutputLocation(outputDir);
		// ...
		// Routes
		List<Object> routesObjects = new ArrayList<Object>();
		routesObjects.addAll(routes);
		writer.excludeOptionalAndMissingFields(Route.class, routesObjects);
		routes.forEach((route)->{
			writer.handleEntity(route);
		});
		// ...
		writer.close();

		// Comprimimos
		ZipHelper.compressAgencyGtfsFiles(codigoOperador);
	}

Finally, the routes.txt file contains rows with the column eligibilityRestricted valued -999.

@russellhoff
Copy link
Author

Anything on this issue?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants