use of net.opengis.gml.x32.AbstractGeometryType in project ddf by codice.
the class CswFilterFactory method createBinarySpatialOpTypeUsingGeometry.
@SuppressWarnings("unchecked")
private BinarySpatialOpType createBinarySpatialOpTypeUsingGeometry(PropertyNameType propertyName, JAXBElement<? extends AbstractGeometryType> geometry) {
BinarySpatialOpType binarySpatialOpType = new BinarySpatialOpType();
binarySpatialOpType.setPropertyName(propertyName);
binarySpatialOpType.setGeometry((JAXBElement<AbstractGeometryType>) geometry);
return binarySpatialOpType;
}
use of net.opengis.gml.x32.AbstractGeometryType in project ddf by codice.
the class GeometryAdapter method unmarshalFrom.
public static Attribute unmarshalFrom(GeometryElement element) throws ConversionFailedException {
AttributeImpl attribute = null;
GML311ToJTSGeometryConverter converter = new GML311ToJTSGeometryConverter();
WKTWriter wktWriter = new WKTWriter();
for (Value xmlValue : element.getValue()) {
JAXBElement<AbstractGeometryType> xmlGeometry = xmlValue.getGeometry();
Geometry geometry = converter.createGeometry(new DefaultRootObjectLocator(xmlValue), xmlGeometry.getValue());
String wkt = wktWriter.write(geometry);
if (attribute == null) {
attribute = new AttributeImpl(element.getName(), wkt);
} else {
attribute.addValue(wkt);
}
}
return attribute;
}
use of net.opengis.gml.x32.AbstractGeometryType in project ddf by codice.
the class Gml3ToWktImpl method convert.
@SuppressWarnings("unchecked")
public String convert(InputStream xml) throws ValidationExceptionImpl {
AbstractGeometryType geometry = null;
try {
JAXBElement<AbstractGeometryType> jaxbElement = parser.unmarshal(configurator, JAXBElement.class, xml);
geometry = jaxbElement.getValue();
GML311ToJTSGeometryConverter geometryConverter = new GML311ToJTSGeometryConverter();
Geometry jtsGeo = geometryConverter.createGeometry(new DefaultRootObjectLocator(jaxbElement), geometry);
WKTWriter wktWriter = new WKTWriter();
return wktWriter.write(jtsGeo);
} catch (ParserException e) {
LOGGER.debug("Cannot parse gml", e);
throw new ValidationExceptionImpl(e, Collections.singletonList("Cannot parse gml"), new ArrayList<String>());
} catch (ConversionFailedException e) {
LOGGER.debug("Cannot convert gml311 geo object {} to jts", geometry, e);
throw new ValidationExceptionImpl(e, Collections.singletonList("Cannot convert geo object"), new ArrayList<String>());
}
}
use of net.opengis.gml.x32.AbstractGeometryType in project arctic-sea by 52North.
the class GmlEncoderv321 method createAbstractGeometry.
private AbstractGeometryType createAbstractGeometry(AbstractGeometry element, EncodingContext ctx) throws EncodingException {
XmlObject xbGeometry = createPosition(element.getGeometry(), ctx);
AbstractGeometryType abstractGeometryType = null;
if (xbGeometry instanceof AbstractGeometryType) {
abstractGeometryType = (AbstractGeometryType) xbGeometry;
} else if (xbGeometry instanceof GeometryPropertyType) {
abstractGeometryType = ((GeometryPropertyType) xbGeometry).getAbstractGeometry();
} else {
throw new UnsupportedEncoderInputException(this, element);
}
if (element.isSetIdentifier()) {
abstractGeometryType.setIdentifier(createCodeWithAuthorityType(element.getIdentifierCodeWithAuthority()));
}
if (element.isSetName()) {
for (org.n52.shetland.ogc.gml.CodeType codeType : element.getName()) {
abstractGeometryType.addNewName().set(createCodeType(codeType));
}
}
if (element.isSetDescription()) {
abstractGeometryType.addNewDescription().setStringValue(element.getDescription());
}
return abstractGeometryType;
}
Aggregations