use of org.geotoolkit.gml.xml.v321.AbstractGeometryType in project ddf by codice.
the class RegistryPackageConverter method setSlotGeoAttribute.
private static void setSlotGeoAttribute(SlotType1 slot, String metacardAttributeName, MetacardImpl metacard) throws RegistryConversionException {
if (slot.isSetValueList()) {
net.opengis.cat.wrs.v_1_0_2.ValueListType valueList = (net.opengis.cat.wrs.v_1_0_2.ValueListType) slot.getValueList().getValue();
List<AnyValueType> anyValues = valueList.getAnyValue();
for (AnyValueType anyValue : anyValues) {
if (anyValue.isSetContent()) {
for (Object content : anyValue.getContent()) {
if (content instanceof JAXBElement) {
JAXBElement jaxbElement = (JAXBElement) content;
AbstractGeometryType geometry = (AbstractGeometryType) jaxbElement.getValue();
String convertedGeometry = getWKTFromGeometry(geometry, jaxbElement);
if (StringUtils.isNotBlank(convertedGeometry)) {
metacard.setAttribute(metacardAttributeName, convertedGeometry);
}
}
}
}
}
}
}
use of org.geotoolkit.gml.xml.v321.AbstractGeometryType in project ddf by codice.
the class CswQueryFactoryTest method createPolygon.
private JAXBElement<AbstractGeometryType> createPolygon() {
PolygonType localPolygon = new PolygonType();
LinearRingType ring = new LinearRingType();
for (Coordinate coordinate : polygon.getCoordinates()) {
CoordType coord = new CoordType();
coord.setX(BigDecimal.valueOf(coordinate.x));
coord.setY(BigDecimal.valueOf(coordinate.y));
if (!Double.isNaN(coordinate.z)) {
coord.setZ(BigDecimal.valueOf(coordinate.z));
}
ring.getCoord().add(coord);
}
AbstractRingPropertyType abstractRing = new AbstractRingPropertyType();
abstractRing.setRing(gmlObjectFactory.createLinearRing(ring));
localPolygon.setExterior(gmlObjectFactory.createExterior(abstractRing));
JAXBElement<AbstractGeometryType> agt = new JAXBElement<>(new QName("http://www.opengis.net/gml", "Polygon"), AbstractGeometryType.class, null, localPolygon);
return agt;
}
use of org.geotoolkit.gml.xml.v321.AbstractGeometryType in project ddf by codice.
the class CswFilterFactory method createDistanceBufferType.
@SuppressWarnings("unchecked")
private DistanceBufferType createDistanceBufferType(PropertyNameType propertyName, JAXBElement<? extends AbstractGeometryType> geometry, DistanceType distance) {
DistanceBufferType distanceBuffer = new DistanceBufferType();
distanceBuffer.setDistance(distance);
distanceBuffer.setGeometry((JAXBElement<AbstractGeometryType>) geometry);
distanceBuffer.setPropertyName(propertyName);
return distanceBuffer;
}
use of org.geotoolkit.gml.xml.v321.AbstractGeometryType in project ddf by codice.
the class WfsFilterDelegate method buildDistanceBufferType.
@SuppressWarnings("unchecked")
private JAXBElement<DistanceBufferType> buildDistanceBufferType(JAXBElement<DistanceBufferType> dbt, String propertyName, String wkt, double distance) {
DistanceType distanceType = new DistanceType();
distanceType.setValue(distance);
// the filter adapter normalizes all distances to meters
distanceType.setUnits(WfsConstants.METERS);
dbt.getValue().setDistance(distanceType);
dbt.getValue().setGeometry((JAXBElement<AbstractGeometryType>) createGeometryOperand(wkt));
dbt.getValue().setPropertyName(createPropertyNameType(propertyName).getValue());
return dbt;
}
use of org.geotoolkit.gml.xml.v321.AbstractGeometryType in project ddf by codice.
the class GeometryAdapter method marshalFrom.
public static GeometryElement marshalFrom(Attribute attribute) throws CatalogTransformerException {
GeometryElement element = new GeometryElement();
element.setName(attribute.getName());
if (attribute.getValue() != null) {
for (Serializable value : attribute.getValues()) {
if (!(value instanceof String)) {
continue;
}
String wkt = (String) value;
WKTReader wktReader = new WKTReader(geometryFactory);
Geometry jtsGeometry = null;
try {
jtsGeometry = wktReader.read(wkt);
} catch (ParseException e) {
throw new CatalogTransformerException("Could not transform Metacard to XML. Invalid WKT.", e);
}
JTSToGML311GeometryConverter converter = new JTSToGML311GeometryConverter();
@SuppressWarnings("unchecked") JAXBElement<AbstractGeometryType> gmlElement = (JAXBElement<AbstractGeometryType>) converter.createElement(jtsGeometry);
GeometryElement.Value geoValue = new GeometryElement.Value();
geoValue.setGeometry(gmlElement);
element.getValue().add(geoValue);
}
}
return element;
}
Aggregations