Search in sources :

Example 11 with TimeSeries

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);
    }
}
Also used : QuantityData(org.n52.io.response.dataset.quantity.QuantityData)

Example 12 with TimeSeries

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;
}
Also used : DatasetOutput(org.n52.io.response.dataset.DatasetOutput)

Example 13 with TimeSeries

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;
}
Also used : TvpDataCollection(org.n52.io.series.TvpDataCollection) QuantityData(org.n52.io.response.dataset.quantity.QuantityData)

Example 14 with TimeSeries

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;
}
Also used : FilterResolver(org.n52.io.request.FilterResolver) ArrayList(java.util.ArrayList) IoParameters(org.n52.io.request.IoParameters) I18N(org.n52.io.I18N)

Example 15 with TimeSeries

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);
    }
}
Also used : RawDataService(org.n52.series.spi.srv.RawDataService) InputStream(java.io.InputStream) InternalServerException(org.n52.web.exception.InternalServerException) BadRequestException(org.n52.web.exception.BadRequestException) IOException(java.io.IOException) ResourceNotFoundException(org.n52.web.exception.ResourceNotFoundException)

Aggregations

QuantityData (org.n52.io.response.dataset.quantity.QuantityData)7 QuantityValue (org.n52.io.response.dataset.quantity.QuantityValue)5 ArrayList (java.util.ArrayList)3 DatasetOutput (org.n52.io.response.dataset.DatasetOutput)3 Coordinate (com.vividsolutions.jts.geom.Coordinate)2 IoParameters (org.n52.io.request.IoParameters)2 SeriesParameters (org.n52.io.response.dataset.SeriesParameters)2 TvpDataCollection (org.n52.io.series.TvpDataCollection)2 TimeSeries (org.n52.oxf.DocumentStructureType.TimeSeries)2 Line2D (java.awt.geom.Line2D)1 IOException (java.io.IOException)1 InputStream (java.io.InputStream)1 DateTime (org.joda.time.DateTime)1 Test (org.junit.Test)1 I18N (org.n52.io.I18N)1 IoStyleContext (org.n52.io.IoStyleContext)1 FilterResolver (org.n52.io.request.FilterResolver)1 StyleProperties (org.n52.io.request.StyleProperties)1 CategoryOutput (org.n52.io.response.CategoryOutput)1 FeatureOutput (org.n52.io.response.FeatureOutput)1