Search in sources :

Example 11 with Value

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());
}
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 12 with Value

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);
}
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 13 with Value

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

Example 14 with Value

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

Example 15 with Value

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;
}
Also used : JsonNode(com.fasterxml.jackson.databind.JsonNode) MultilingualString(org.n52.janmayen.i18n.MultilingualString) MultilingualString(org.n52.janmayen.i18n.MultilingualString)

Aggregations

XmlObject (org.apache.xmlbeans.XmlObject)28 Test (org.junit.Test)27 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)20 IoParameters (org.n52.io.request.IoParameters)19 SweField (org.n52.shetland.ogc.swe.SweField)16 TimeInstant (org.n52.shetland.ogc.gml.time.TimeInstant)13 QuantityValue (org.n52.shetland.ogc.om.values.QuantityValue)13 RequestSimpleParameterSet (org.n52.io.request.RequestSimpleParameterSet)12 List (java.util.List)9 SimpleDataRecordType (net.opengis.swe.x101.SimpleDataRecordType)9 AnyScalarPropertyType (net.opengis.swe.x101.AnyScalarPropertyType)7 CategoryValue (org.n52.shetland.ogc.om.values.CategoryValue)7 CountValue (org.n52.shetland.ogc.om.values.CountValue)7 SweBoolean (org.n52.shetland.ogc.swe.simpleType.SweBoolean)7 SweText (org.n52.shetland.ogc.swe.simpleType.SweText)7 DecodingException (org.n52.svalbard.decode.exception.DecodingException)7 DateTime (org.joda.time.DateTime)6 ModelAndView (org.springframework.web.servlet.ModelAndView)6 ObjectNode (com.fasterxml.jackson.databind.node.ObjectNode)5 ArrayList (java.util.ArrayList)5