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);
}
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);
}
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());
}
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);
}
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;
}
Aggregations