use of org.n52.shetland.ogc.filter.Filter in project arctic-sea by 52North.
the class AbstractCapabilitiesBaseTypeDecoder method parseAddress.
private OwsAddress parseAddress(AddressType address) {
if (address == null) {
return null;
}
List<String> deliveryPoint = Optional.ofNullable(address.getDeliveryPointArray()).map(Arrays::stream).orElseGet(Stream::empty).map(Strings::emptyToNull).filter(Objects::nonNull).collect(toList());
List<String> electronicMailAddress = Optional.ofNullable(address.getElectronicMailAddressArray()).map(Arrays::stream).orElseGet(Stream::empty).map(Strings::emptyToNull).filter(Objects::nonNull).collect(toList());
String city = address.getCity();
String administrativeArea = address.getAdministrativeArea();
String postalCode = address.getPostalCode();
String country = address.getCountry();
return new OwsAddress(deliveryPoint, city, administrativeArea, postalCode, country, electronicMailAddress);
}
use of org.n52.shetland.ogc.filter.Filter in project arctic-sea by 52North.
the class SosDecoderv100 method parseGetObservation.
/**
* parses the XmlBean representing the getObservation request and creates a
* SoSGetObservation request
*
* @param getObsDoc
* XmlBean created from the incoming request stream
* @return Returns SosGetObservationRequest representing the request
*
* @throws DecodingException
* * If parsing the XmlBean failed
*/
private OwsServiceRequest parseGetObservation(GetObservationDocument getObsDoc) throws DecodingException {
GetObservationRequest getObsRequest = new GetObservationRequest();
GetObservation getObs = getObsDoc.getGetObservation();
getObsRequest.setService(getObs.getService());
getObsRequest.setVersion(getObs.getVersion());
getObsRequest.setOfferings(Arrays.asList(getObs.getOffering()));
getObsRequest.setObservedProperties(Arrays.asList(getObs.getObservedPropertyArray()));
getObsRequest.setProcedures(Arrays.asList(getObs.getProcedureArray()));
getObsRequest.setTemporalFilters(parseTemporalFilters4GetObservation(getObs.getEventTimeArray()));
getObsRequest.setSrsName(getObs.getSrsName());
if (getObs.isSetFeatureOfInterest()) {
FeatureOfInterest featureOfInterest = getObs.getFeatureOfInterest();
if (featureOfInterest.isSetSpatialOps()) {
Object filter = decodeXmlElement(featureOfInterest.getSpatialOps());
if (filter instanceof SpatialFilter) {
getObsRequest.setSpatialFilter((SpatialFilter) filter);
}
} else if (featureOfInterest.getObjectIDArray() != null) {
Set<String> featureIdentifiers = Sets.newHashSet();
for (String string : featureOfInterest.getObjectIDArray()) {
featureIdentifiers.add(string);
}
getObsRequest.setFeatureIdentifiers(Lists.newArrayList(featureIdentifiers));
}
}
// TODO implement result filtering
if (getObs.isSetResult()) {
throw new NotYetSupportedDecodingException("Result filtering");
}
// return error message
if (getObs.isSetResponseFormat()) {
getObsRequest.setResponseFormat(decodeResponseFormat(getObs.getResponseFormat()));
} else {
getObsRequest.setResponseFormat(OmConstants.CONTENT_TYPE_OM.toString());
}
if (getObs.isSetResultModel()) {
getObsRequest.setResultModel(OMHelper.getObservationTypeFor(getObs.getResultModel()));
}
return getObsRequest;
}
use of org.n52.shetland.ogc.filter.Filter in project arctic-sea by 52North.
the class FesDecoderv20 method parsePropertyIsBetweenFilter.
/**
* Parse XML propertyIsBetween element
*
* @param comparisonOpsType
* XML propertyIsBetween element
* @return SOS comparison filter
* @throws DecodingException
* If an error occurs of the filter is not supported
*/
private ComparisonFilter parsePropertyIsBetweenFilter(PropertyIsBetweenType comparisonOpsType) throws DecodingException {
ComparisonFilter comparisonFilter = new ComparisonFilter();
comparisonFilter.setOperator(ComparisonOperator.PropertyIsBetween);
try {
comparisonFilter.setValueReference(parseValueReference(comparisonOpsType.getExpression()));
} catch (XmlException xmle) {
throw valueReferenceParsingException(xmle);
}
if (comparisonOpsType.getLowerBoundary().getExpression() instanceof LiteralType) {
comparisonFilter.setValue(parseLiteralValue((LiteralType) comparisonOpsType.getLowerBoundary().getExpression()));
}
if (comparisonOpsType.getUpperBoundary().getExpression() instanceof LiteralType) {
comparisonFilter.setValueUpper(parseLiteralValue((LiteralType) comparisonOpsType.getUpperBoundary().getExpression()));
}
return comparisonFilter;
}
use of org.n52.shetland.ogc.filter.Filter in project arctic-sea by 52North.
the class FesDecoderv20 method parseSpatialFilterType.
/**
* Parses the spatial filter of a request.
*
* @param xbSpatialOpsType
* XmlBean representing the feature of interest parameter of the
* request
* @return Returns SpatialFilter created from the passed foi request
* parameter
*
* @throws DecodingException
* * if creation of the SpatialFilter failed
*/
private SpatialFilter parseSpatialFilterType(SpatialOpsType xbSpatialOpsType) throws DecodingException {
SpatialFilter spatialFilter = new SpatialFilter();
try {
if (xbSpatialOpsType instanceof BBOXType) {
spatialFilter.setOperator(FilterConstants.SpatialOperator.BBOX);
BBOXType xbBBOX = (BBOXType) xbSpatialOpsType;
if (isValueReferenceExpression(xbBBOX.getExpression())) {
spatialFilter.setValueReference(parseValueReference(xbBBOX.getExpression()));
}
XmlCursor geometryCursor = xbSpatialOpsType.newCursor();
if (geometryCursor.toChild(GmlConstants.QN_ENVELOPE_32)) {
Object sosGeometry = decodeXmlObject(Factory.parse(geometryCursor.getDomNode()));
if (sosGeometry instanceof Geometry) {
spatialFilter.setGeometry((Geometry) sosGeometry);
} else if (sosGeometry instanceof ReferencedEnvelope) {
spatialFilter.setGeometry((ReferencedEnvelope) sosGeometry);
} else {
throw new UnsupportedDecoderXmlInputException(this, xbSpatialOpsType);
}
} else {
throw new DecodingException(Sos2Constants.GetObservationParams.spatialFilter, "The requested spatial filter operand is not supported by this SOS!");
}
geometryCursor.dispose();
} else {
throw new DecodingException(Sos2Constants.GetObservationParams.spatialFilter, "The requested spatial filter is not supported by this SOS!");
}
} catch (XmlException xmle) {
throw new DecodingException("Error while parsing spatial filter!", xmle);
}
return spatialFilter;
}
use of org.n52.shetland.ogc.filter.Filter in project arctic-sea by 52North.
the class OgcDecoderv100 method parseTemporalOperatorType.
/**
* parses a single temporal filter of the requests and returns SOS temporal filter
*
* @param xbBinaryTemporalOp XmlObject representing the temporal filter
*
* @return Returns SOS representation of temporal filter
*
* @throws DecodingException if parsing of the element failed
*/
private Object parseTemporalOperatorType(BinaryTemporalOpType xbBinaryTemporalOp) throws DecodingException {
TemporalFilter temporalFilter = new TemporalFilter();
// FIXME local workaround against SOSHelper check value reference
String valueRef = "phenomenonTime";
try {
NodeList nodes = xbBinaryTemporalOp.getDomNode().getChildNodes();
for (int i = 0; i < nodes.getLength(); i++) {
if (nodes.item(i).getNamespaceURI() != null && !nodes.item(i).getLocalName().equals(FilterConstants.EN_VALUE_REFERENCE)) {
// GML decoder will return TimeInstant or TimePriod
Object timeObject = decodeXmlElement(XmlObject.Factory.parse(nodes.item(i)));
if (timeObject instanceof PropertyNameType) {
PropertyNameType propType = (PropertyNameType) timeObject;
// TODO here apply logic for ogc property
// om:samplingTime etc
// valueRef = propType.getDomNode().getNodeValue();
}
if (timeObject instanceof Time) {
TimeOperator operator;
Time time = (Time) timeObject;
String localName = XmlHelper.getLocalName(xbBinaryTemporalOp);
// change to SOS 1.0. TMDuring kind of
if (localName.equals(TimeOperator.TM_During.name()) && time instanceof TimePeriod) {
operator = TimeOperator.TM_During;
} else if (localName.equals(TimeOperator.TM_Equals.name()) && time instanceof TimeInstant) {
operator = TimeOperator.TM_Equals;
} else if (localName.equals(TimeOperator.TM_After.name()) && time instanceof TimeInstant) {
operator = TimeOperator.TM_After;
} else if (localName.equals(TimeOperator.TM_Before.name()) && time instanceof TimeInstant) {
operator = TimeOperator.TM_Before;
} else {
throw unsupportedTemporalFilterOperand();
}
temporalFilter.setOperator(operator);
temporalFilter.setTime(time);
// actually it should be eg om:samplingTime
temporalFilter.setValueReference(valueRef);
break;
}
}
}
} catch (XmlException xmle) {
throw new DecodingException("Error while parsing temporal filter!", xmle);
}
return temporalFilter;
}
Aggregations