Search in sources :

Example 1 with SweTextEncoding

use of org.n52.shetland.ogc.swe.encoding.SweTextEncoding in project arctic-sea by 52North.

the class SweHelper method createTextEncoding.

/**
 * Create a TextEncoding object for token and tuple separators.
 *
 * @param tuple
 *            Token separator
 * @param token
 *            Tuple separator
 * @param decimal
 *            Decimal separator
 *
 * @return TextEncoding
 */
private SweAbstractEncoding createTextEncoding(String tuple, String token, String decimal) {
    SweTextEncoding sosTextEncoding = new SweTextEncoding();
    sosTextEncoding.setBlockSeparator(tuple);
    sosTextEncoding.setTokenSeparator(token);
    if (!Strings.isNullOrEmpty(decimal)) {
        sosTextEncoding.setDecimalSeparator(decimal);
    }
    return sosTextEncoding;
}
Also used : SweTextEncoding(org.n52.shetland.ogc.swe.encoding.SweTextEncoding)

Example 2 with SweTextEncoding

use of org.n52.shetland.ogc.swe.encoding.SweTextEncoding in project arctic-sea by 52North.

the class InsertResultTemplateRequestDecoderTest method resultEncoding.

@Test
public void resultEncoding() throws IOException, DecodingException {
    InsertResultTemplateRequest req = load();
    assertThat(req.getResultEncoding(), is(notNullValue()));
    assertThat(req.getResultEncoding().isDecoded(), is(true));
    assertThat(req.getResultEncoding().isEncoded(), is(false));
    assertThat(req.getResultEncoding().get().get(), is(instanceOf(SweTextEncoding.class)));
    SweTextEncoding encoding = (SweTextEncoding) req.getResultEncoding().get().get();
    errors.checkThat(encoding.getTokenSeparator(), is(","));
    errors.checkThat(encoding.getBlockSeparator(), is("#"));
}
Also used : SweTextEncoding(org.n52.shetland.ogc.swe.encoding.SweTextEncoding) InsertResultTemplateRequest(org.n52.shetland.ogc.sos.request.InsertResultTemplateRequest) Test(org.junit.Test)

Example 3 with SweTextEncoding

use of org.n52.shetland.ogc.swe.encoding.SweTextEncoding in project arctic-sea by 52North.

the class GetResultTemplateResponseEncoder method encodeSweTextEncoding.

private void encodeSweTextEncoding(SweAbstractEncoding encoding, ObjectNode node) {
    SweTextEncoding sweTextEncoding = (SweTextEncoding) encoding;
    String ts = sweTextEncoding.getTokenSeparator();
    if (ts != null && !ts.isEmpty()) {
        node.put(JSONConstants.TOKEN_SEPARATOR, ts);
    }
    String bs = sweTextEncoding.getBlockSeparator();
    if (bs != null && !bs.isEmpty()) {
        node.put(JSONConstants.BLOCK_SEPARATOR, bs);
    }
    String ds = sweTextEncoding.getDecimalSeparator();
    if (ds != null && !ds.isEmpty()) {
        node.put(JSONConstants.DECIMAL_SEPARATOR, ds);
    }
}
Also used : SweTextEncoding(org.n52.shetland.ogc.swe.encoding.SweTextEncoding)

Example 4 with SweTextEncoding

use of org.n52.shetland.ogc.swe.encoding.SweTextEncoding in project arctic-sea by 52North.

the class InsertResultTemplateRequestDecoder method parseResultEncoding.

private SosResultEncoding parseResultEncoding(JsonNode node) {
    SweTextEncoding textEncoding = new SweTextEncoding();
    textEncoding.setTokenSeparator(node.path(JSONConstants.TOKEN_SEPARATOR).textValue());
    textEncoding.setBlockSeparator(node.path(JSONConstants.BLOCK_SEPARATOR).textValue());
    if (!node.path(JSONConstants.DECIMAL_SEPARATOR).isMissingNode()) {
        textEncoding.setDecimalSeparator(node.path(JSONConstants.DECIMAL_SEPARATOR).textValue());
    }
    return new SosResultEncoding(textEncoding);
}
Also used : SweTextEncoding(org.n52.shetland.ogc.swe.encoding.SweTextEncoding) SosResultEncoding(org.n52.shetland.ogc.sos.SosResultEncoding)

Example 5 with SweTextEncoding

use of org.n52.shetland.ogc.swe.encoding.SweTextEncoding in project arctic-sea by 52North.

the class SweCommonDecoderV101 method parseTextEncoding.

private SweTextEncoding parseTextEncoding(TextBlock textEncoding) {
    final SweTextEncoding sosTextEncoding = new SweTextEncoding();
    sosTextEncoding.setBlockSeparator(textEncoding.getBlockSeparator());
    sosTextEncoding.setTokenSeparator(textEncoding.getTokenSeparator());
    sosTextEncoding.setDecimalSeparator(textEncoding.getDecimalSeparator());
    return sosTextEncoding;
}
Also used : SweTextEncoding(org.n52.shetland.ogc.swe.encoding.SweTextEncoding)

Aggregations

SweTextEncoding (org.n52.shetland.ogc.swe.encoding.SweTextEncoding)13 XmlObject (org.apache.xmlbeans.XmlObject)5 ArrayList (java.util.ArrayList)3 List (java.util.List)3 Lists (com.google.common.collect.Lists)2 BigInteger (java.math.BigInteger)2 URI (java.net.URI)2 Collection (java.util.Collection)2 Collections (java.util.Collections)2 Map (java.util.Map)2 Set (java.util.Set)2 Collectors.joining (java.util.stream.Collectors.joining)2 AbstractDataComponentType (net.opengis.swe.x20.AbstractDataComponentType)2 BooleanPropertyType (net.opengis.swe.x20.BooleanPropertyType)2 CategoryPropertyType (net.opengis.swe.x20.CategoryPropertyType)2 CountPropertyType (net.opengis.swe.x20.CountPropertyType)2 DataArrayPropertyType (net.opengis.swe.x20.DataArrayPropertyType)2 DataRecordPropertyType (net.opengis.swe.x20.DataRecordPropertyType)2 QuantityPropertyType (net.opengis.swe.x20.QuantityPropertyType)2 TextEncodingDocument (net.opengis.swe.x20.TextEncodingDocument)2