use of org.n52.oxf.DocumentStructureType.TimeSeries in project series-rest-api by 52North.
the class GeneralizingQuantityService method logGeneralizationAmount.
private void logGeneralizationAmount(DataCollection<QuantityData> ungeneralizedData, DataCollection<QuantityData> generalizedData) {
for (String timeseriesId : ungeneralizedData.getAllSeries().keySet()) {
QuantityData originalTimeseries = ungeneralizedData.getSeries(timeseriesId);
QuantityData generalizedTimeseries = generalizedData.getSeries(timeseriesId);
int originalAmount = originalTimeseries.getValues().size();
int generalizedAmount = generalizedTimeseries.getValues().size();
LOGGER.debug("Generalized timeseries: {} (#{} --> #{}).", timeseriesId, originalAmount, generalizedAmount);
}
}
use of org.n52.oxf.DocumentStructureType.TimeSeries in project series-rest-api by 52North.
the class ChartIoHandler method getTitleForSingle.
private String getTitleForSingle(RequestStyledParameterSet config, String template) {
String[] timeseries = config.getDatasets();
if (timeseries != null && timeseries.length > 0) {
String timeseriesId = timeseries[0];
DatasetOutput metadata = getTimeseriesMetadataOutput(timeseriesId);
if (metadata != null) {
return formatTitle(metadata, template);
}
}
return template;
}
use of org.n52.oxf.DocumentStructureType.TimeSeries in project series-rest-api by 52North.
the class LargestTriangleThreeBucketsGeneralizer method generalize.
@Override
public DataCollection<QuantityData> generalize(DataCollection<QuantityData> data) throws GeneralizerException {
TvpDataCollection<QuantityData> generalizedDataCollection = new TvpDataCollection<>();
for (String timeseriesId : data.getAllSeries().keySet()) {
QuantityData timeseries = data.getSeries(timeseriesId);
QuantityData generalizedTimeseries = generalize(timeseries);
generalizedTimeseries.setMetadata(timeseries.getMetadata());
generalizedDataCollection.addNewSeries(timeseriesId, generalizedTimeseries);
}
return generalizedDataCollection;
}
use of org.n52.oxf.DocumentStructureType.TimeSeries in project series-rest-api by 52North.
the class ResourcesController method createResources.
protected List<ResourceCollection> createResources(IoParameters params) {
IoParameters parameters = IoParameters.ensureBackwardsCompatibility(params);
I18N i18n = I18N.getMessageLocalizer(parameters.getLocale());
ResourceCollection services = add("services", "Service Provider", i18n.get("msg.web.resources.services"));
ResourceCollection stations = add("stations", "Station", i18n.get("msg.web.resources.stations"));
ResourceCollection timeseries = add("timeseries", "Timeseries", i18n.get("msg.web.resources.timeseries"));
ResourceCollection categories = add("categories", "Category", i18n.get("msg.web.resources.categories"));
ResourceCollection offerings = add("offerings", "Offering", i18n.get("msg.web.resources.offerings"));
ResourceCollection features = add("features", "Feature", i18n.get("msg.web.resources.features"));
ResourceCollection procedures = add("procedures", "Procedure", i18n.get("msg.web.resources.procedures"));
ResourceCollection phenomena = add("phenomena", "Phenomenon", i18n.get("msg.web.resources.phenomena"));
if (parameters.isExpanded()) {
services.setSize(getMetadataService().getServiceCount(parameters));
if (new FilterResolver(parameters).shallBehaveBackwardsCompatible()) {
// ensure backwards compatibility
stations.setSize(getMetadataService().getStationCount());
timeseries.setSize(getMetadataService().getTimeseriesCount());
}
categories.setSize(getMetadataService().getCategoryCount(parameters));
offerings.setSize(getMetadataService().getOfferingCount(parameters));
features.setSize(getMetadataService().getFeatureCount(parameters));
procedures.setSize(getMetadataService().getProcedureCount(parameters));
phenomena.setSize(getMetadataService().getPhenomenaCount(parameters));
}
List<ResourceCollection> resources = new ArrayList<>();
resources.add(services);
resources.add(stations);
resources.add(timeseries);
resources.add(categories);
resources.add(offerings);
resources.add(features);
resources.add(procedures);
resources.add(phenomena);
// since 2.0.0
ResourceCollection platforms = add("platforms", "Platforms", i18n.get("msg.web.resources.platforms"));
ResourceCollection datasets = add("datasets", "Datasets", i18n.get("msg.web.resources.datasets"));
ResourceCollection geometries = add("geometries", "Geometries", i18n.get("msg.web.resources.geometries"));
resources.add(platforms);
resources.add(datasets);
resources.add(geometries);
if (parameters.isExpanded()) {
platforms.setSize(getMetadataService().getPlatformCount(parameters));
datasets.setSize(getMetadataService().getDatasetCount(parameters));
}
return resources;
}
use of org.n52.oxf.DocumentStructureType.TimeSeries in project series-rest-api by 52North.
the class DataController method writeRawData.
private void writeRawData(RequestSimpleParameterSet parameters, HttpServletResponse response) throws InternalServerException, ResourceNotFoundException, BadRequestException {
if (!dataService.supportsRawData()) {
throw new BadRequestException("Querying of raw timeseries data is not supported " + "by the underlying service!");
}
final RawDataService rawDataService = dataService.getRawDataService();
try (InputStream inputStream = rawDataService.getRawData(parameters)) {
if (inputStream == null) {
throw new ResourceNotFoundException("No raw data found.");
}
response.setContentType(parameters.getRawFormat());
IOUtils.copyLarge(inputStream, response.getOutputStream());
} catch (IOException e) {
throw new InternalServerException("Error while querying raw data", e);
}
}
Aggregations