Skip to content
Open
Show file tree
Hide file tree
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
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,14 @@

package fr.certu.chouette.exchange.gtfs.exporter;

import java.util.HashSet;
import java.util.Iterator;
import java.util.Set;
import java.util.TimeZone;

import org.apache.log4j.Logger;

import lombok.Setter;

import org.apache.log4j.Logger;

import fr.certu.chouette.exchange.gtfs.exporter.producer.IGtfsProducer;
import fr.certu.chouette.exchange.gtfs.exporter.report.GtfsReport;
Expand Down Expand Up @@ -98,6 +99,29 @@ public GtfsData produce(NeptuneData neptuneData,TimeZone timeZone, GtfsReport re
throw new GtfsExportException(GtfsExportExceptionCode.ERROR, "missing data");
// check if no data for one or more types
boolean error = false;

// Trim references to non-existing or non-exported parent stations
Set<String> stationIds = new HashSet<String>();
for (GtfsStop station : gtfsData.getStops())
{
if (station.getLocationType() == GtfsStop.STATION)
{
stationIds.add(station.getStopId());
}
}
for (GtfsStop stop : gtfsData.getStops())
{
if (stop.getLocationType() == GtfsStop.STOP)
{
if (!stationIds.contains(stop.getParentStation()))
{
stop.setParentStation(null);
GtfsReportItem item = new GtfsReportItem(GtfsReportItem.KEY.MISSING_DATA, STATE.WARNING, "Stop", stop.getStopId(), "parentStation");
report.addItem(item);
}
}
}

if (gtfsData.getAgencies().isEmpty())
{
logger.error("no company for agencies.txt");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

import java.sql.Time;
import java.text.MessageFormat;
import java.util.Calendar;

import lombok.Getter;
import lombok.Setter;
Expand Down Expand Up @@ -59,15 +60,15 @@ public GtfsTime(Time time,boolean tomorrow)

public String toString()
{

long h = time.getTime()/1000;
long s = h%60;
h=h/60;
long m = h % 60;
h=h/60;
if (tomorrow) h+= 24;
// This will use default JVM timezone
Calendar cal = Calendar.getInstance();
cal.setTime(time);
long h = cal.get(Calendar.HOUR_OF_DAY);
long m = cal.get(Calendar.MINUTE);
long s = cal.get(Calendar.SECOND);
if (tomorrow)
h+=24;
return MessageFormat.format(mfHoraireHMS,h,m,s);

}

public String toSeconds()
Expand Down