use of org.n52.shetland.ogc.om.NamedValue in project arctic-sea by 52North.
the class ParameterHolder method addSpatialFilteringProfileParameter.
/**
* Add sampling geometry to observation
*
* @param samplingGeometry The sampling geometry to set
*
* @return this
*/
public ParameterHolder addSpatialFilteringProfileParameter(Geometry samplingGeometry) {
final NamedValue<Geometry> namedValue = new NamedValue<>();
namedValue.setName(new ReferenceType(OmConstants.PARAM_NAME_SAMPLING_GEOMETRY));
namedValue.setValue(new GeometryValue(samplingGeometry));
addParameter(namedValue);
return this;
}
use of org.n52.shetland.ogc.om.NamedValue in project arctic-sea by 52North.
the class OmObservationTest method should_have_SpatialFilteringProfileParameter.
@Test
public final void should_have_SpatialFilteringProfileParameter() throws OwsExceptionReport, DecodingException {
OmObservation omObservation = new OmObservation();
NamedValue<Geometry> namedValue = new NamedValue<>();
namedValue.setName(new ReferenceType(OmConstants.PARAM_NAME_SAMPLING_GEOMETRY));
GeometryFactory fac = new GeometryFactory(new PrecisionModel(PrecisionModel.FLOATING), 4326);
namedValue.setValue(new GeometryValue(fac.createPoint(new Coordinate(34.5, 76.4))));
// test no parameter is set
assertFalse(omObservation.isSetParameter());
assertFalse(omObservation.isSetSpatialFilteringProfileParameter());
omObservation.addParameter(namedValue);
// test with set SpatialFilteringProfile parameter
assertTrue(omObservation.isSetParameter());
assertTrue(omObservation.isSetSpatialFilteringProfileParameter());
assertThat(omObservation.getSpatialFilteringProfileParameter(), is(equalTo(namedValue)));
}
use of org.n52.shetland.ogc.om.NamedValue in project arctic-sea by 52North.
the class AbstractGmlDecoderv321 method parseNamedValueType.
protected NamedValue<?> parseNamedValueType(NamedValuePropertyType namedValueProperty) throws DecodingException {
if (namedValueProperty.isSetNamedValue()) {
NamedValueType namedValue = namedValueProperty.getNamedValue();
NamedValue<?> sosNamedValue = parseNamedValueValue(namedValue.getValue());
org.n52.shetland.ogc.gml.ReferenceType referenceType = (org.n52.shetland.ogc.gml.ReferenceType) decodeXmlObject(namedValue.getName());
sosNamedValue.setName(referenceType);
return sosNamedValue;
} else if (namedValueProperty.isSetHref()) {
NamedValue<org.n52.shetland.ogc.gml.ReferenceType> sosNamedValue = new NamedValue<>();
org.n52.shetland.ogc.gml.ReferenceType referenceType = new org.n52.shetland.ogc.gml.ReferenceType(namedValueProperty.getHref());
if (namedValueProperty.isSetTitle()) {
referenceType.setTitle(namedValueProperty.getTitle());
}
sosNamedValue.setName(referenceType);
return sosNamedValue;
} else {
throw new UnsupportedDecoderInputException(this, namedValueProperty);
}
}
use of org.n52.shetland.ogc.om.NamedValue in project arctic-sea by 52North.
the class ObservationDecoder method parseParameter.
protected Collection<NamedValue<?>> parseParameter(JsonNode node) throws DecodingException {
Set<NamedValue<?>> parameters = Sets.newTreeSet();
JsonNode parameter = node.path(JSONConstants.PARAMETER);
if (parameter.isArray()) {
for (JsonNode jsonNode : parameter) {
parameters.add(parseNamedValue(jsonNode));
}
} else if (parameter.isObject()) {
parameters.add(parseNamedValue(parameter));
}
return parameters;
}
use of org.n52.shetland.ogc.om.NamedValue in project arctic-sea by 52North.
the class AbstractOmEncoderv20 method encode.
@Override
public XmlObject encode(Object element, EncodingContext additionalValues) throws EncodingException {
XmlObject encodedObject = null;
if (element instanceof OmObservation) {
encodedObject = encodeOmObservation((OmObservation) element, additionalValues);
} else if (element instanceof NamedValue) {
NamedValueType nvt = createNamedValue((NamedValue<?>) element);
if (additionalValues.has(XmlBeansEncodingFlags.DOCUMENT)) {
NamedValueDocument nvd = NamedValueDocument.Factory.newInstance();
nvd.setNamedValue(nvt);
encodedObject = nvd;
} else if (additionalValues.has(XmlBeansEncodingFlags.PROPERTY_TYPE)) {
NamedValuePropertyType nvpt = NamedValuePropertyType.Factory.newInstance();
nvpt.setNamedValue(nvt);
encodedObject = nvpt;
} else {
encodedObject = nvt;
}
} else if (element instanceof AbstractFeature) {
encodedObject = encodeFeatureOfInterest((AbstractFeature) element);
} else if (element instanceof SosProcedureDescription) {
encodedObject = encodeProcedureDescription((SosProcedureDescription<?>) element);
} else {
throw new UnsupportedEncoderInputException(this, element);
}
// XmlHelper.validateDocument(encodedObject));
return encodedObject;
}
Aggregations