use of org.n52.shetland.ogc.om.values.Value 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.shetland.ogc.om.values.Value 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.shetland.ogc.om.values.Value in project series-rest-api by 52North.
the class IoParameters method createBbox.
/**
* @return a {@link BBox} instance or <code>null</code> if no {@link #BBOX} parameter is present.
* @throws IoParseException
* if parsing parameter fails.
* @throws IoParseException
* if a requested {@value #CRS} object could not be created
*/
private BBox createBbox() {
if (!containsParameter(BBOX)) {
return null;
}
String bboxValue = getAsString(BBOX);
BBox bbox = parseJson(bboxValue, BBox.class);
bbox.setLl(convertToCrs84(bbox.getLl()));
bbox.setUr(convertToCrs84(bbox.getUr()));
return bbox;
}
use of org.n52.shetland.ogc.om.values.Value in project series-rest-api by 52North.
the class IoParameters method getSpatialFilter.
/**
* Creates a {@link BoundingBox} instance from given spatial request parameters. The resulting bounding
* box is the merged extent of all spatial filters given. For example if {@value #NEAR} and {@value #BBOX}
* exist, the returned bounding box includes both extents.
*
* @return a spatial filter created from given spatial parameters.
* @throws IoParseException
* if parsing parameters fails, or if a requested {@value #CRS} object could not be created.
*/
public BoundingBox getSpatialFilter() {
if (!containsParameter(NEAR) && !containsParameter(BBOX)) {
return null;
}
BBox bboxBounds = createBbox();
BoundingBox bounds = parseBoundsFromVicinity();
return mergeBounds(bounds, bboxBounds);
}
use of org.n52.shetland.ogc.om.values.Value in project arctic-sea by 52North.
the class SettingValueFactory method decodeMultiLingualStringValue.
static MultilingualString decodeMultiLingualStringValue(String stringValue) {
MultilingualString ms = new MultilingualString();
if (!nullOrEmpty(stringValue)) {
JsonNode json = Json.loadString(stringValue);
Iterator<String> it = json.fieldNames();
while (it.hasNext()) {
String lang = it.next();
String value = json.path(lang).asText();
ms.addLocalization(LocaleHelper.decode(lang), value);
}
}
return ms;
}
Aggregations