use of org.n52.shetland.ogc.gml.ReferenceType in project arctic-sea by 52North.
the class PointObservation method setValue.
@Override
public void setValue(ObservationValue<?> value) {
if (value instanceof StreamingValue<?>) {
super.setValue(value);
} else if (value.getValue() instanceof CvDiscretePointCoverage) {
super.setValue(value);
} else {
CvDiscretePointCoverage cvDiscretePointCoverage = new CvDiscretePointCoverage(getObservationID());
cvDiscretePointCoverage.setRangeType(new ReferenceType(getObservationConstellation().getObservablePropertyIdentifier()));
cvDiscretePointCoverage.setUnit(((AbstractObservationValue<?>) value).getUnit());
Geometry geometry = null;
String domainExtent = "";
if (isSetSpatialFilteringProfileParameter() && getSpatialFilteringProfileParameter().getValue() instanceof GeometryValue) {
GeometryValue geometryValue = (GeometryValue) getSpatialFilteringProfileParameter().getValue();
geometry = getSpatialFilteringProfileParameter().getValue().getValue();
domainExtent = geometryValue.getGmlId();
} else if (checkForFeatureGeometry(this)) {
geometry = getGeometryFromFeature(this);
domainExtent = getObservationConstellation().getFeatureOfInterest().getGmlId();
}
if (geometry != null) {
cvDiscretePointCoverage.setDomainExtent("#" + geometry.getGeometryType() + "_" + domainExtent);
Point point = null;
if (geometry instanceof Point) {
point = (Point) geometry;
} else {
point = geometry.getCentroid();
}
cvDiscretePointCoverage.setValue(new PointValuePair(point, value.getValue()));
}
super.setValue(new SingleObservationValue<>(value.getPhenomenonTime(), cvDiscretePointCoverage));
}
}
use of org.n52.shetland.ogc.gml.ReferenceType in project arctic-sea by 52North.
the class GetDataAvailabilityResponseDecoder method parseDataAvalabilities.
private Collection<DataAvailability> parseDataAvalabilities(net.opengis.sosgda.x20.GetDataAvailabilityResponseType response) throws DecodingException {
List<DataAvailability> availabilities = Lists.newArrayList();
if (CollectionHelper.isNotNullOrEmpty(response.getDataAvailabilityMemberArray())) {
Map<String, TimePeriod> periods = Maps.newHashMap();
for (net.opengis.sosgda.x20.DataAvailabilityMemberType damt : response.getDataAvailabilityMemberArray()) {
ReferenceType procedure = decodeXmlElement(damt.getProcedure());
ReferenceType offering = decodeXmlElement(damt.getOffering());
ReferenceType featureOfInterest = decodeXmlElement(damt.getFeatureOfInterest());
ReferenceType observedProperty = decodeXmlElement(damt.getObservedProperty());
TimePeriod phenomenonTime = getPhenomenonTime(damt.getPhenomenonTime().getAbstractTimeObject(), damt.getPhenomenonTime().getHref(), periods);
DataAvailability dataAvailability = new DataAvailability(procedure, observedProperty, featureOfInterest, offering, phenomenonTime);
FormatDescriptor formatDescriptor = createFormatDescriptor(damt.getFormatDescriptor());
if (formatDescriptor != null) {
dataAvailability.setFormatDescriptor(formatDescriptor);
}
availabilities.add(dataAvailability);
}
}
return availabilities;
}
use of org.n52.shetland.ogc.gml.ReferenceType in project arctic-sea by 52North.
the class GetDataAvailabilityResponseDecoder method parseDataAvalabilities.
private Collection<DataAvailability> parseDataAvalabilities(GetDataAvailabilityResponseType response) throws DecodingException {
List<DataAvailability> availabilities = Lists.newArrayList();
if (CollectionHelper.isNotNullOrEmpty(response.getDataAvailabilityMemberArray())) {
Map<String, TimePeriod> periods = Maps.newHashMap();
for (DataAvailabilityMemberType damt : response.getDataAvailabilityMemberArray()) {
ReferenceType procedure = decodeXmlElement(damt.getProcedure());
ReferenceType featureOfInterest = decodeXmlElement(damt.getFeatureOfInterest());
ReferenceType observedProperty = decodeXmlElement(damt.getObservedProperty());
TimePeriod phenomenonTime = getPhenomenonTime(damt.getPhenomenonTime().getAbstractTimeObject(), damt.getPhenomenonTime().getHref(), periods);
availabilities.add(new DataAvailability(procedure, observedProperty, featureOfInterest, null, phenomenonTime));
}
}
return availabilities;
}
use of org.n52.shetland.ogc.gml.ReferenceType in project arctic-sea by 52North.
the class GetDataAvailabilityXmlEncoderTest method test.
@Test
public void test() throws EncodingException {
GetDataAvailabilityResponse response = new GetDataAvailabilityResponse("SOS", "2.0.0");
response.setNamespace(GetDataAvailabilityConstants.NS_GDA);
DateTime begin = DateTime.now().withZone(DateTimeZone.UTC);
DateTime end = begin.plusHours(1).withZone(DateTimeZone.UTC);
TimePeriod timePeriod = new TimePeriod(begin, end);
ReferenceType procedure = new ReferenceType("procedure");
ReferenceType observedProperty = new ReferenceType("observedProperty");
ReferenceType featureOfInterest = new ReferenceType("featureOfInterest");
ReferenceType offering = new ReferenceType("offering");
int count = 100;
response.addDataAvailability(new DataAvailability(procedure, observedProperty, featureOfInterest, offering, timePeriod, count));
XmlObject encoded = encoder.encode(response);
System.out.println(encoded.xmlText());
errors.checkThat(encoded.xmlText(), is(String.format("<gda:GetDataAvailabilityResponse xsi:schemaLocation=\"http://www.opengis.net/sosgda/1.0 http://waterml2.org/schemas/gda/1.0/gda.xsd\" " + "xmlns:gda=\"http://www.opengis.net/sosgda/1.0\" " + "xmlns:gml=\"http://www.opengis.net/gml/3.2\" " + "xmlns:swe=\"http://www.opengis.net/swe/2.0\" " + "xmlns:xlink=\"http://www.w3.org/1999/xlink\" " + "xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\">\n" + " <gda:dataAvailabilityMember gml:id=\"dam_1\">\n" + " <gda:procedure xlink:href=\"procedure\" xlink:title=\"procedure\"/>\n" + " <gda:observedProperty xlink:href=\"observedProperty\" xlink:title=\"observedProperty\"/>\n" + " <gda:featureOfInterest xlink:href=\"featureOfInterest\" xlink:title=\"featureOfInterest\"/>\n" + " <gda:phenomenonTime>\n" + " <gml:TimePeriod gml:id=\"tp_1\">\n" + " <gml:beginPosition>%s</gml:beginPosition>\n" + " <gml:endPosition>%s</gml:endPosition>\n" + " </gml:TimePeriod>\n" + " </gda:phenomenonTime>\n" + " <gda:count>100</gda:count>\n" + " <gda:extension>\n" + " <swe:Text definition=\"offering\">\n" + " <swe:value>offering</swe:value>\n" + " </swe:Text>\n" + " </gda:extension>\n" + " </gda:dataAvailabilityMember>\n" + "</gda:GetDataAvailabilityResponse>", begin.toString(ISODateTimeFormat.dateTime()), end.toString(ISODateTimeFormat.dateTime()))));
}
Aggregations