use of net.opengis.gml.v_3_1_1.PointType in project ddf by codice.
the class TestWfs10JTStoGML200Converter method testPointTypeToJAXB.
@Test
public void testPointTypeToJAXB() throws JAXBException, SAXException, IOException, ParseException, NullPointerException {
String pointGML = Wfs10JTStoGML200Converter.convertGeometryToGML(getGeometryFromWkt(POINT));
PointType pointType = (PointType) Wfs10JTStoGML200Converter.convertGMLToGeometryType(pointGML, Wfs10Constants.POINT);
JAXBElement<PointType> pointTypeJAXBElement = (JAXBElement<PointType>) Wfs10JTStoGML200Converter.convertGeometryTypeToJAXB(pointType);
JAXB.marshal(pointTypeJAXBElement, writer);
String xml = writer.toString();
Diff diff = XMLUnit.compareXML(xml, POINT_GML);
assertTrue(XMLUNIT_SIMILAR, diff.similar());
assertThat(diff.similar(), is(Boolean.TRUE));
assertThat(diff.identical(), is(Boolean.FALSE));
}
use of net.opengis.gml.v_3_1_1.PointType in project ddf by codice.
the class WfsFilterDelegate method createPoint.
private JAXBElement<PointType> createPoint(String wkt) {
Coordinate[] coordinates = getCoordinatesFromWkt(wkt);
if (coordinates != null && coordinates.length > 0) {
StringBuilder coordString = new StringBuilder();
coordString.append(coordinates[0].x).append(",").append(coordinates[0].y);
CoordinatesType coordinatesType = new CoordinatesType();
coordinatesType.setValue(coordString.toString());
PointType point = new PointType();
point.setSrsName(srsName);
point.setCoordinates(coordinatesType);
return gmlObjectFactory.createPoint(point);
} else {
throw new IllegalArgumentException("Unable to parse Point coordinates from WKT String");
}
}
use of net.opengis.gml.v_3_1_1.PointType in project ddf by codice.
the class TestWfs10JTStoGML200Converter method testGMLToGeometryCollectionType.
@Test
public void testGMLToGeometryCollectionType() throws JAXBException, SAXException, IOException, ParseException, NullPointerException {
String geometryCollectionGML = Wfs10JTStoGML200Converter.convertGeometryToGML(getGeometryFromWkt(GEOMETRYCOLLECTION));
GeometryCollectionType geometryCollectionType = (GeometryCollectionType) Wfs10JTStoGML200Converter.convertGMLToGeometryType(geometryCollectionGML, Wfs10Constants.GEOMETRY_COLLECTION);
assertFalse(geometryCollectionType == null);
List<JAXBElement<? extends GeometryAssociationType>> geometryMembers = geometryCollectionType.getGeometryMember();
assertThat(CollectionUtils.isEmpty(geometryMembers), is(Boolean.FALSE));
assertThat(geometryMembers.size() == 2, is(Boolean.TRUE));
GeometryAssociationType geometryAssociationType = geometryMembers.get(0).getValue();
JAXBElement<? extends AbstractGeometryType> jaxbElement = geometryAssociationType.getGeometry();
assertThat(Wfs10Constants.POINT.getLocalPart().equals(jaxbElement.getName().getLocalPart()), is(Boolean.TRUE));
PointType pointType = (PointType) jaxbElement.getValue();
assertThat(pointType == null, is(Boolean.FALSE));
assertThat(GEOMETRYCOLLECTION_POINT_COORD.equals(pointType.getCoordinates().getValue().trim()), is(Boolean.TRUE));
GeometryAssociationType geometryAssociationType2 = geometryMembers.get(1).getValue();
JAXBElement<? extends AbstractGeometryType> jaxbElement2 = geometryAssociationType2.getGeometry();
assertThat(Wfs10Constants.LINESTRING.getLocalPart().equals(jaxbElement2.getName().getLocalPart()), is(Boolean.TRUE));
LineStringType lineStringType = (LineStringType) jaxbElement2.getValue();
assertThat(lineStringType == null, is(Boolean.FALSE));
assertThat(GEOMETRYCOLLECTION_LINESTRING_COORD.equals(lineStringType.getCoordinates().getValue().trim()), is(Boolean.TRUE));
}
use of net.opengis.gml.v_3_1_1.PointType in project ddf by codice.
the class SlotWebConverter method getPointMapFromPointType.
private static Map<String, Object> getPointMapFromPointType(PointType point) {
Map<String, Object> pointMap = new HashMap<>();
if (point.isSetSrsDimension()) {
pointMap.put(SRS_DIMENSION, point.getSrsDimension().intValue());
}
if (point.isSetSrsName()) {
pointMap.put(SRS_NAME, point.getSrsName());
}
if (point.isSetPos()) {
DirectPositionType directPosition = point.getPos();
List<String> pointValues = new ArrayList<>();
pointValues.addAll(directPosition.getValue().stream().map(String::valueOf).collect(Collectors.toList()));
String position = String.join(" ", pointValues);
if (StringUtils.isNotBlank(position)) {
pointMap.put(POSITION, position);
}
}
return pointMap;
}
use of net.opengis.gml.v_3_1_1.PointType in project ddf by codice.
the class SlotWebConverter method getSlotGeoMap.
private Map<String, Object> getSlotGeoMap(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 PointType) {
Map<String, Object> pointMap = getPointMapFromPointType((PointType) jaxbElement.getValue());
if (MapUtils.isNotEmpty(pointMap)) {
Map<String, Object> valueMap = new HashMap<>();
valueMap.put(POINT_KEY, pointMap);
map.put(VALUE, valueMap);
}
}
});
}
return map;
}
Aggregations