class FeatureTimeseriesStatistics {

	public static void execute(
			FeatureCollection<SimpleFeatureType, SimpleFeature> featureCollection,
			String attributeName,
			TimeseriesDataset timeseriesDataset,
			List<StationTimeseriesVisitor> additionalVisitors,
			Writer writer,
			Delimiter delimiter) {

		List<Object> featureNames = gatherFeatureAttributes(featureCollection, attributeName);
		if (featureNames == null || featureNames.isEmpty()) {
			throw new RuntimeException("No features specified");
		}
		timeseriesDataset.populateMetadata(featureNames.get(0).toString());
		String units = timeseriesDataset.getUnits();
		Statistics1DWriter statisticWriter = new Statistics1DWriter(
				featureNames,
				timeseriesDataset.getObservedProperty(),
				units,
				Lists.newArrayList(VALUE),
				false,
				delimiter.delimiter,
				null,
				false,
				false,
				writer);
		
		List<StationTimeseriesVisitor> visitors = new LinkedList<>();
		FeatureTimeseriesStatiticsVisitor ftsVisitor = new FeatureTimeseriesStatiticsVisitor(featureNames, statisticWriter);
		visitors.add(ftsVisitor);
		visitors.addAll(additionalVisitors);
		TimeseriesTraverser traverser = new TimeseriesTraverser(timeseriesDataset);
		
		traverser.traverse(visitors);
	}

}