use of org.onebusaway.gtfs.model.Stop in project onebusaway-application-modules by camsys.
the class GenerateNarrativesTask method generateStopNarratives.
public void generateStopNarratives(NarrativeProviderImpl provider) {
Map<AgencyAndId, List<ProjectedPoint>> shapePointCache = new HashMap<AgencyAndId, List<ProjectedPoint>>();
int index = 0;
Collection<Stop> allStops = _gtfsDao.getAllStops();
Map<AgencyAndId, Stop> stopsById = MappingLibrary.mapToValue(allStops, "id");
int logInterval = LoggingIntervalUtil.getAppropriateLoggingInterval(allStops.size());
for (StopEntry stopEntry : _transitGraphDao.getAllStops()) {
if (index % logInterval == 0)
_log.info("stops=" + index);
index++;
Stop stop = stopsById.get(stopEntry.getId());
StopNarrative.Builder narrative = StopNarrative.builder();
narrative.setCode(deduplicate(stop.getCode()));
narrative.setDescription(deduplicate(stop.getDesc()));
narrative.setName(deduplicate(stop.getName()));
narrative.setUrl(deduplicate(stop.getUrl()));
String direction = computeStopDirection(provider, shapePointCache, stop, stopEntry);
narrative.setDirection(deduplicate(direction));
provider.setNarrativeForStop(stopEntry.getId(), narrative.create());
}
}
use of org.onebusaway.gtfs.model.Stop in project onebusaway-application-modules by camsys.
the class StopVerificationDistanceTask method verifyStops.
protected void verifyStops(String rootStopId, List<String> consolidatedStops) {
AgencyAndId agencyAndId = AgencyAndIdLibrary.convertFromString(rootStopId);
Stop expectedStop = _dao.getStopForId(agencyAndId);
for (String consolidatedStop : consolidatedStops) {
Stop unexpectedStop = _dao.getStopForId(AgencyAndIdLibrary.convertFromString(consolidatedStop));
if (unexpectedStop != null) {
if (expectedStop != null) {
double distance = SphericalGeometryLibrary.distanceFaster(expectedStop.getLat(), expectedStop.getLon(), unexpectedStop.getLat(), unexpectedStop.getLon());
if (distance > STOP_DISTANCE_THRESHOLD) {
_logger.log("stop_verification_distance.csv", rootStopId, consolidatedStop, distance, toOrd(expectedStop.getLat(), expectedStop.getLon()), toOrd(unexpectedStop.getLat(), unexpectedStop.getLon()));
}
}
}
}
}
use of org.onebusaway.gtfs.model.Stop in project onebusaway-application-modules by camsys.
the class StopVerificationTask method verifyStops.
protected void verifyStops(String rootStopId, List<String> consolidatedStops) {
AgencyAndId agencyAndId = AgencyAndIdLibrary.convertFromString(rootStopId);
Stop expectedStop = _dao.getStopForId(agencyAndId);
boolean pass = expectedStop != null;
String missingStopId = (pass ? "" : rootStopId);
String unexpectedStopIds = "";
for (String consolidatedStop : consolidatedStops) {
Stop unexpectedStop = _dao.getStopForId(AgencyAndIdLibrary.convertFromString(consolidatedStop));
if (unexpectedStop != null) {
pass = false;
unexpectedStopIds += consolidatedStop + " ";
}
}
if (!pass) {
_logger.log("stop_verification.csv", rootStopId, String.valueOf(pass), missingStopId, unexpectedStopIds);
}
}
use of org.onebusaway.gtfs.model.Stop in project onebusaway-application-modules by camsys.
the class EntityReplacementLoggerImpl method updateStore.
// we've been called (potentially again). see if there is anything
// worth updating.
private void updateStore(Serializable id, Serializable replacementId, Double originLat, Double originLon, Double replacementLat, Double replacementLon) {
Serializable key = hash(id, replacementId);
EntityStore store = _replacements.get(key);
if (store == null) {
if (originLat == null && _rejectionDao != null) {
Stop stop = _rejectionDao.getEntityForId(Stop.class, id);
if (stop != null) {
originLat = stop.getLat();
originLon = stop.getLon();
}
}
store = new EntityStore(id, replacementId, originLat, originLon, replacementLat, replacementLon);
_replacements.put(key, store);
} else {
store.update(originLat, originLon, replacementLat, replacementLon);
}
}
use of org.onebusaway.gtfs.model.Stop in project onebusaway-application-modules by camsys.
the class HastusGtfsFactory method processStops.
private void processStops() throws Exception {
File stopsShapeFile = new File(_gisInputPath, "CTBusStops.shp");
FeatureCollection<SimpleFeatureType, SimpleFeature> features = ShapefileLibrary.loadShapeFile(stopsShapeFile);
FeatureIterator<SimpleFeature> it = features.features();
logger.header(csv("stops"), "stop_id,primary_name,cross_name,computed_name,lat,lon");
while (it.hasNext()) {
SimpleFeature feature = it.next();
Long stopId = (Long) feature.getProperty("STOP_ID").getValue();
String primaryName = (String) feature.getProperty("PRIMARY").getValue();
String crossName = (String) feature.getProperty("CROSS").getValue();
Point point = (Point) feature.getDefaultGeometry();
String stopName = computeStopName(primaryName, crossName);
Stop stop = new Stop();
stop.setId(id(stopId.toString()));
stop.setName(stopName);
stop.setLat(point.getY());
stop.setLon(point.getX());
logger.log(csv("stops"), stopId, primaryName, crossName, stopName, point.getY(), point.getX());
_dao.saveEntity(stop);
}
try {
it.close();
} catch (Exception e) {
_log.error("issue closing feature. Exception will be ignored.", e);
}
}
Aggregations