use of org.geotoolkit.gml.xml.v321.EnvelopeType in project ddf by codice.
the class CswFilterFactory method createEnvelopeType.
private JAXBElement<EnvelopeType> createEnvelopeType(String wkt) {
EnvelopeType envelopeType = new EnvelopeType();
wkt = convertWktToLatLonOrdering(wkt);
Envelope envelope = getEnvelopeFromWkt(wkt);
if (envelope != null) {
envelopeType.setLowerCorner(createDirectPositionType(envelope.getMinX(), envelope.getMinY()));
envelopeType.setUpperCorner(createDirectPositionType(envelope.getMaxX(), envelope.getMaxY()));
}
return gmlObjectFactory.createEnvelope(envelopeType);
}
use of org.geotoolkit.gml.xml.v321.EnvelopeType in project ddf by codice.
the class WfsFilterDelegateTest method testIntersectsAsBoundingBox.
@Test
public void testIntersectsAsBoundingBox() {
WfsFilterDelegate delegate = setupFilterDelegate(SPATIAL_OPERATORS.BBOX.getValue(), new LonLatCoordinateStrategy());
FilterType filter = delegate.intersects(Metacard.ANY_GEO, POLYGON);
assertThat(filter.getSpatialOps().getValue(), is(instanceOf(BBOXType.class)));
assertThat(filter.isSetLogicOps(), is(false));
BBOXType bboxType = (BBOXType) filter.getSpatialOps().getValue();
EnvelopeType envelope = bboxType.getEnvelope().getValue();
DirectPositionType lowerCorner = envelope.getLowerCorner();
assertThat("The bounding box's lower corner was null.", lowerCorner, is(notNullValue()));
assertThat(lowerCorner.getValue(), is(asList(10.0, -10.0)));
DirectPositionType upperCorner = envelope.getUpperCorner();
assertThat("The bounding box's upper corner was null.", upperCorner, is(notNullValue()));
assertThat(upperCorner.getValue(), is(asList(40.0, 30.0)));
}
use of org.geotoolkit.gml.xml.v321.EnvelopeType in project ddf by codice.
the class SlotTypeConverter method getEnvelope.
private Optional<EnvelopeType> getEnvelope(Map<String, Object> envelopeMap) {
Optional<EnvelopeType> optionalEnvelope = Optional.empty();
if (MapUtils.isEmpty(envelopeMap)) {
return optionalEnvelope;
}
optionalEnvelope = Optional.of(GML_FACTORY.createEnvelopeType());
String valueToPopulate = MapUtils.getString(envelopeMap, SRS_NAME);
if (StringUtils.isNotBlank(valueToPopulate)) {
optionalEnvelope.get().setSrsName(valueToPopulate);
}
String upperCorner = MapUtils.getString(envelopeMap, UPPER_CORNER);
String lowerCorner = MapUtils.getString(envelopeMap, LOWER_CORNER);
if (StringUtils.isNotBlank(upperCorner)) {
List<Double> values = Arrays.stream(StringUtils.split(upperCorner)).map(e -> new Double(e)).collect(Collectors.toList());
DirectPositionType directPosition = GML_FACTORY.createDirectPositionType();
directPosition.setValue(values);
optionalEnvelope.get().setUpperCorner(directPosition);
}
if (StringUtils.isNotBlank(lowerCorner)) {
List<Double> values = Arrays.stream(StringUtils.split(lowerCorner)).map(e -> new Double(e)).collect(Collectors.toList());
DirectPositionType directPosition = GML_FACTORY.createDirectPositionType();
directPosition.setValue(values);
optionalEnvelope.get().setLowerCorner(directPosition);
}
return optionalEnvelope;
}
use of org.geotoolkit.gml.xml.v321.EnvelopeType in project ddf by codice.
the class SlotWebConverter method getSlotBoundsMap.
private Map<String, Object> getSlotBoundsMap(SlotType1 slot) {
Map<String, Object> map = new HashMap<>();
if (!slot.isSetValueList()) {
return map;
}
ValueListType valueList = (ValueListType) slot.getValueList().getValue();
for (AnyValueType anyValue : valueList.getAnyValue()) {
anyValue.getContent().stream().filter(content -> content instanceof JAXBElement).forEach(content -> {
JAXBElement jaxbElement = (JAXBElement) content;
if (jaxbElement.getValue() instanceof EnvelopeType) {
Map<String, Object> boundsMap = getBoundsMapFromEnvelopeType((EnvelopeType) jaxbElement.getValue());
if (MapUtils.isNotEmpty(boundsMap)) {
Map<String, Object> valueMap = new HashMap<>();
valueMap.put(ENVELOPE_KEY, boundsMap);
map.put(VALUE, valueMap);
}
}
});
}
return map;
}
use of org.geotoolkit.gml.xml.v321.EnvelopeType in project arctic-sea by 52North.
the class SweCommonEncoderv101 method createField.
private DataComponentPropertyType createField(SweField sweField) throws EncodingException {
SweAbstractDataComponent element = sweField.getElement();
DataComponentPropertyType xbField = DataComponentPropertyType.Factory.newInstance(getXmlOptions());
if (sweField.isSetName()) {
xbField.setName(sweField.getName().getValue());
}
if (element instanceof SweBoolean) {
xbField.addNewBoolean().set(createSimpleType((SweBoolean) element));
} else if (element instanceof SweCategory) {
xbField.addNewCategory().set(createSimpleType((SweCategory) element));
} else if (element instanceof SweCount) {
xbField.addNewCount().set(createSimpleType((SweCount) element));
} else if (element instanceof SweCountRange) {
xbField.addNewCount().set(createSimpleType((SweCountRange) element));
} else if (element instanceof SweQuantity) {
xbField.addNewQuantity().set(createSimpleType((SweQuantity) element));
} else if (element instanceof SweQuantityRange) {
xbField.addNewQuantity().set(createSimpleType((SweQuantityRange) element));
} else if (element instanceof SweText) {
xbField.addNewText().set(createSimpleType((SweText) element));
} else if (element instanceof SweTimeRange) {
xbField.addNewTimeRange().set(createSimpleType((SweTimeRange) element));
} else if (element instanceof SweTime) {
xbField.addNewTime().set(createSimpleType((SweTime) element));
} else if (element instanceof SweEnvelope) {
EnvelopeType xbEnvelope = (EnvelopeType) xbField.addNewAbstractDataRecord().substitute(SweConstants.QN_ENVELOPE_SWE_101, EnvelopeType.type);
xbEnvelope.set(createEnvelope((SweEnvelope) element));
} else if (element instanceof SweDataRecord) {
DataRecordType xbEnvelope = (DataRecordType) xbField.addNewAbstractDataRecord().substitute(SweConstants.QN_DATA_RECORD_SWE_101, DataRecordType.type);
xbEnvelope.set(createDataRecord((SweDataRecord) element));
} else if (element instanceof SweDataArray) {
DataArrayType xbEnvelope = (DataArrayType) xbField.addNewAbstractDataRecord().substitute(SweConstants.QN_DATA_RECORD_SWE_101, DataArrayType.type);
xbEnvelope.set(createDataArray((SweDataArray) element).getDataArray1());
} else {
throw new EncodingException("The element type '%s' of the received '%s' is not supported by this encoder '%s'.", new Object[] { element != null ? element.getClass().getName() : null, sweField.getClass().getName(), getClass().getName() });
}
return xbField;
}
Aggregations