Search in sources :

Example 11 with IoParameters

use of org.n52.io.request.IoParameters in project series-rest-api by 52North.

the class TimeseriesDataController method getRawData.

@RequestMapping(value = "/{timeseriesId}/getData", method = RequestMethod.GET, params = { RawFormats.RAW_FORMAT })
public void getRawData(HttpServletResponse response, @PathVariable String timeseriesId, @RequestHeader(value = Parameters.HttpHeader.ACCEPT_LANGUAGE) String locale, @RequestParam MultiValueMap<String, String> query) {
    RequestUtils.overrideQueryLocaleWhenSet(locale, query);
    IoParameters map = QueryParameters.createFromQuery(query);
    checkIfUnknownTimeseries(map, timeseriesId);
    RequestSimpleParameterSet parameters = RequestSimpleParameterSet.createForSingleSeries(timeseriesId, map);
    processRawDataRequest(response, parameters);
}
Also used : RequestSimpleParameterSet(org.n52.io.request.RequestSimpleParameterSet) IoParameters(org.n52.io.request.IoParameters) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 12 with IoParameters

use of org.n52.io.request.IoParameters in project series-rest-api by 52North.

the class TimeseriesDataController method getAsCsv.

@RequestMapping(value = "/{timeseriesId}/getData", produces = { "text/csv" }, method = RequestMethod.GET)
public void getAsCsv(HttpServletResponse response, @PathVariable String timeseriesId, @RequestHeader(value = Parameters.HttpHeader.ACCEPT_LANGUAGE) String locale, @RequestParam(required = false) MultiValueMap<String, String> query) throws Exception {
    RequestUtils.overrideQueryLocaleWhenSet(locale, query);
    IoParameters map = QueryParameters.createFromQuery(query);
    getTimeseriesAsCsv(timeseriesId, map, response);
}
Also used : IoParameters(org.n52.io.request.IoParameters) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 13 with IoParameters

use of org.n52.io.request.IoParameters in project series-rest-api by 52North.

the class TimeseriesDataController method getChart.

@RequestMapping(value = "/{timeseriesId}/getData", produces = { "image/png" }, method = RequestMethod.GET)
public void getChart(HttpServletResponse response, @PathVariable String timeseriesId, @RequestHeader(value = Parameters.HttpHeader.ACCEPT_LANGUAGE) String locale, @RequestParam(required = false) MultiValueMap<String, String> query) throws Exception {
    RequestUtils.overrideQueryLocaleWhenSet(locale, query);
    IoParameters map = QueryParameters.createFromQuery(query);
    checkIfUnknownTimeseries(map, timeseriesId);
    RequestSimpleParameterSet parameterSet = RequestSimpleParameterSet.createForSingleSeries(timeseriesId, map);
    RequestStyledParameterSet styledParameters = map.toStyledParameterSet();
    checkAgainstTimespanRestriction(parameterSet.getTimespan());
    parameterSet.setGeneralize(map.isGeneralize());
    parameterSet.setBase64(map.isBase64());
    parameterSet.setExpanded(map.isExpanded());
    response.setContentType(MimeType.IMAGE_PNG.getMimeType());
    createIoFactory(parameterSet).withStyledRequest(styledParameters).createHandler(MimeType.IMAGE_PNG.toString()).writeBinary(response.getOutputStream());
}
Also used : RequestSimpleParameterSet(org.n52.io.request.RequestSimpleParameterSet) RequestStyledParameterSet(org.n52.io.request.RequestStyledParameterSet) IoParameters(org.n52.io.request.IoParameters) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 14 with IoParameters

use of org.n52.io.request.IoParameters in project series-rest-api by 52North.

the class TimeseriesDataController method getData.

@RequestMapping(value = "/{timeseriesId}/getData", produces = { "application/json" }, method = RequestMethod.GET)
public ModelAndView getData(HttpServletResponse response, @PathVariable String timeseriesId, @RequestHeader(value = Parameters.HttpHeader.ACCEPT_LANGUAGE) String locale, @RequestParam(required = false) MultiValueMap<String, String> query) {
    RequestUtils.overrideQueryLocaleWhenSet(locale, query);
    IoParameters map = QueryParameters.createFromQuery(query);
    checkIfUnknownTimeseries(map, timeseriesId);
    IntervalWithTimeZone timespan = map.getTimespan();
    checkAgainstTimespanRestriction(timespan.toString());
    RequestSimpleParameterSet parameters = RequestSimpleParameterSet.createForSingleSeries(timeseriesId, map);
    if (map.getResultTime() != null) {
        parameters.setResultTime(map.getResultTime().toString());
    }
    parameters.setGeneralize(map.isGeneralize());
    parameters.setExpanded(map.isExpanded());
    // TODO add paging
    DataCollection<QuantityData> seriesData = getTimeseriesData(parameters);
    DataCollection<?> formattedDataCollection = format(seriesData, map.getFormat());
    if (map.isExpanded()) {
        return new ModelAndView().addObject(formattedDataCollection.getAllSeries());
    }
    Object formattedTimeseries = formattedDataCollection.getAllSeries().get(timeseriesId);
    return new ModelAndView().addObject(formattedTimeseries);
}
Also used : RequestSimpleParameterSet(org.n52.io.request.RequestSimpleParameterSet) ModelAndView(org.springframework.web.servlet.ModelAndView) IoParameters(org.n52.io.request.IoParameters) IntervalWithTimeZone(org.n52.io.IntervalWithTimeZone) QuantityData(org.n52.io.response.dataset.quantity.QuantityData) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 15 with IoParameters

use of org.n52.io.request.IoParameters in project series-rest-api by 52North.

the class RequestSimpleParameterSet method createForSingleSeries.

public static RequestSimpleParameterSet createForSingleSeries(String seriesId, IoParameters parameters) {
    RequestSimpleParameterSet parameterSet = parameters.toSimpleParameterSet();
    parameterSet.setDatasets(new String[] { seriesId });
    IntervalWithTimeZone timespan = parameters.getTimespan();
    parameterSet.setTimespan(timespan.toString());
    return parameterSet;
}
Also used : IntervalWithTimeZone(org.n52.io.IntervalWithTimeZone)

Aggregations

IoParameters (org.n52.io.request.IoParameters)31 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)20 RequestSimpleParameterSet (org.n52.io.request.RequestSimpleParameterSet)14 ModelAndView (org.springframework.web.servlet.ModelAndView)7 Test (org.junit.Test)5 IntervalWithTimeZone (org.n52.io.IntervalWithTimeZone)4 Stopwatch (org.n52.web.common.Stopwatch)4 IoStyleContext (org.n52.io.IoStyleContext)3 RequestStyledParameterSet (org.n52.io.request.RequestStyledParameterSet)3 ResourceNotFoundException (org.n52.web.exception.ResourceNotFoundException)3 IOException (java.io.IOException)2 HashMap (java.util.HashMap)2 Geometry (com.vividsolutions.jts.geom.Geometry)1 WKTReader (com.vividsolutions.jts.io.WKTReader)1 FileOutputStream (java.io.FileOutputStream)1 InputStream (java.io.InputStream)1 ArrayList (java.util.ArrayList)1 DateTime (org.joda.time.DateTime)1 DateTimeFormatter (org.joda.time.format.DateTimeFormatter)1 I18N (org.n52.io.I18N)1