"routeColor:String," +
"routeTextColor:String," +
"agency:String"
);
SimpleFeatureCollection collection = FeatureCollections.newCollection();
SimpleFeatureBuilder featureBuilder = null;
if(gisExport.type.equals(GisUploadType.STOPS))
{
dataStore.createSchema(STOP_TYPE);
featureBuilder = new SimpleFeatureBuilder(STOP_TYPE);
List<Stop> stops = Stop.find("agency in (:ids)").bind("ids", gisExport.agencies).fetch();
for(Stop s : stops)
{
featureBuilder.add(s.locationPoint());
featureBuilder.add(s.stopName);
featureBuilder.add(s.stopCode);
featureBuilder.add(s.stopDesc);
featureBuilder.add(s.gtfsStopId);
featureBuilder.add(s.agency.name);
SimpleFeature feature = featureBuilder.buildFeature(null);
collection.add(feature);
}
}
else if(gisExport.type.equals(GisUploadType.ROUTES))
{
dataStore.createSchema(ROUTE_TYPE);
featureBuilder = new SimpleFeatureBuilder(ROUTE_TYPE);
List<Route> routes = Route.find("agency in (:ids)").bind("ids", gisExport.agencies).fetch();
// check for duplicates
// HashMap<String, Boolean> existingRoutes = new HashMap<String,Boolean>();
for(Route r : routes)
{
// String routeId = r.routeLongName + "_" + r.routeDesc + "_ " + r.phone.id;
//
// if(existingRoutes.containsKey(routeId))
// continue;
// else
// existingRoutes.put(routeId, true);
List<TripPattern> patterns = TripPattern.find("route = ?", r).fetch();
for(TripPattern tp : patterns)
{
if(tp.shape == null)
continue;
featureBuilder.add(tp.shape.shape);
featureBuilder.add(tp.name);
featureBuilder.add(r.routeShortName);
featureBuilder.add(r.routeLongName);
featureBuilder.add(r.routeDesc);
if(r.routeType != null)
featureBuilder.add(r.routeType.toString());
else
featureBuilder.add("");
featureBuilder.add(r.routeUrl);
featureBuilder.add(r.routeColor);
featureBuilder.add(r.routeTextColor);
featureBuilder.add(r.agency.name);
SimpleFeature feature = featureBuilder.buildFeature(null);
collection.add(feature);
}
}
}
else
throw new Exception("Unknown export type.");