use of net.opengis.gml.x32.LineStringType in project ddf by codice.
the class WfsFilterDelegate method createLineString.
private JAXBElement<LineStringType> createLineString(Geometry geometry) {
LineStringType lineStringType = gmlObjectFactory.createLineStringType();
String coordinatesValue = coordinateStrategy.toString(geometry.getCoordinates());
CoordinatesType coordinatesType = gmlObjectFactory.createCoordinatesType();
coordinatesType.setValue(coordinatesValue);
coordinatesType.setDecimal(".");
coordinatesType.setCs(",");
coordinatesType.setTs(" ");
lineStringType.setCoordinates(coordinatesType);
return gmlObjectFactory.createLineString(lineStringType);
}
use of net.opengis.gml.x32.LineStringType in project ddf by codice.
the class TestWfs10JTStoGML200Converter method testLineStringTypeToJAXB.
@Test
public void testLineStringTypeToJAXB() throws JAXBException, SAXException, IOException, ParseException, NullPointerException {
LineString lineString = (LineString) getGeometryFromWkt(LINESTRING);
assertThat(lineString == null, is(Boolean.FALSE));
String lineStringGML = Wfs10JTStoGML200Converter.convertGeometryToGML(lineString);
LineStringType lineStringType = (LineStringType) Wfs10JTStoGML200Converter.convertGMLToGeometryType(lineStringGML, Wfs10Constants.LINESTRING);
JAXBElement<LineStringType> lineStringTypeJAXBElement = (JAXBElement<LineStringType>) Wfs10JTStoGML200Converter.convertGeometryTypeToJAXB(lineStringType);
XMLUnit.setNormalizeWhitespace(Boolean.TRUE);
JAXB.marshal(lineStringTypeJAXBElement, writer);
String xml = writer.toString();
Diff diff = XMLUnit.compareXML(xml, LINESTRING_GML);
assertTrue(XMLUNIT_SIMILAR, diff.similar());
assertThat(diff.similar(), is(Boolean.TRUE));
assertThat(diff.identical(), is(Boolean.FALSE));
}
use of net.opengis.gml.x32.LineStringType 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.x32.LineStringType in project arctic-sea by 52North.
the class AbstractRectifiedGridCoverageTypeEncoder method encodeDomainSet.
private XmlObject encodeDomainSet(RectifiedGridCoverage rectifiedGridCoverage) {
List<ComparableValue<?, ?>> domainSet = rectifiedGridCoverage.getDomainSet();
if (!checkForRange(domainSet)) {
SimpleMultiPointDocument smpd = SimpleMultiPointDocument.Factory.newInstance();
SimpleMultiPointType smpt = smpd.addNewSimpleMultiPoint();
smpt.setId("smp_" + rectifiedGridCoverage.getGmlId());
DirectPositionListType dplt = smpt.addNewPosList();
List<String> uoms = getUoms(domainSet);
if (!uoms.isEmpty()) {
dplt.setUomLabels(Lists.newArrayList(uoms));
}
dplt.setListValue(getList(rectifiedGridCoverage.getDomainSet()));
return smpd;
} else {
LineStringDocument lsd = LineStringDocument.Factory.newInstance();
LineStringType lst = lsd.addNewLineString();
lst.setId("ls_" + rectifiedGridCoverage.getGmlId());
lst.setUomLabels(getUoms(domainSet));
for (ComparableValue<?, ?> quantityValued : domainSet) {
Object value = quantityValued.getValue();
if (value instanceof Double) {
lst.addNewPos().setListValue(Lists.newArrayList((Double) value));
} else if (value instanceof RangeValue) {
lst.addNewPos().setListValue(((RangeValue) value).getRangeAsList());
}
}
return lsd;
}
}
use of net.opengis.gml.x32.LineStringType in project arctic-sea by 52North.
the class GmlDecoderv321 method parseLineStringType.
private Geometry parseLineStringType(LineStringType xbLineStringType) throws DecodingException {
int srid = -1;
if (xbLineStringType.getSrsName() != null) {
srid = CRSHelper.parseSrsName(xbLineStringType.getSrsName());
}
DirectPositionType[] xbPositions = xbLineStringType.getPosArray();
String geomWKT;
if (xbPositions != null && xbPositions.length > 0) {
if (srid == -1 && xbPositions[0].getSrsName() != null && !(xbPositions[0].getSrsName().isEmpty())) {
srid = CRSHelper.parseSrsName(xbPositions[0].getSrsName());
}
geomWKT = "LINESTRING" + getString4PosArray(xbLineStringType.getPosArray(), false) + "";
} else if (xbLineStringType.getPosList() != null) {
StringBuilder builder = new StringBuilder();
builder.append("LINESTRING(");
DirectPositionListType posList = xbLineStringType.getPosList();
int dim;
if (posList.getSrsDimension() == null) {
dim = 2;
} else {
dim = posList.getSrsDimension().intValue();
}
if (posList.getListValue().size() % dim != 0) {
throw new DecodingException("posList does not contain a multiple of %d coordinates", dim);
}
@SuppressWarnings("unchecked") Iterator<Double> iterator = posList.getListValue().iterator();
if (iterator.hasNext()) {
builder.append(iterator.next());
for (int i = 1; i < dim; ++i) {
builder.append(' ').append(iterator.next());
}
while (iterator.hasNext()) {
builder.append(", ");
builder.append(iterator.next());
for (int i = 1; i < dim; ++i) {
builder.append(' ').append(iterator.next());
}
}
}
builder.append(")");
geomWKT = builder.toString();
} else {
geomWKT = null;
}
srid = setDefaultForUnsetSrid(srid);
if (geomWKT != null) {
try {
return JTSHelper.createGeometryFromWKT(geomWKT, srid);
} catch (ParseException ex) {
throw new DecodingException(ex);
}
} else {
return JTSHelper.getGeometryFactoryForSRID(srid).createGeometryCollection(null);
}
}
Aggregations