use of net.opengis.gml.v_3_1_1.DirectPositionListType in project arctic-sea by 52North.
the class GmlEncoderv321 method createPolygonFromJtsGeometry.
/**
* Creates a XML Polygon from a SOS Polygon.
*
* @param jtsPolygon
* SOS Polygon
* @param xbPolType
* XML Polygon
*/
private void createPolygonFromJtsGeometry(Polygon jtsPolygon, PolygonType xbPolType) {
List<?> jtsPolygons = PolygonExtracter.getPolygons(jtsPolygon);
String srsName = getSrsName(jtsPolygon);
for (int i = 0; i < jtsPolygons.size(); i++) {
Polygon pol = (Polygon) jtsPolygons.get(i);
AbstractRingPropertyType xbArpt = xbPolType.addNewExterior();
AbstractRingType xbArt = xbArpt.addNewAbstractRing();
LinearRingType xbLrt = LinearRingType.Factory.newInstance();
// Exterior ring
LineString ring = pol.getExteriorRing();
DirectPositionListType xbPosList = xbLrt.addNewPosList();
xbPosList.setSrsName(srsName);
xbPosList.setStringValue(JTSHelper.getCoordinatesString(ring));
xbArt.set(xbLrt);
// Rename element name for output
XmlCursor cursor = xbArpt.newCursor();
if (cursor.toChild(GmlConstants.QN_ABSTRACT_RING_32)) {
cursor.setName(GmlConstants.QN_LINEAR_RING_32);
}
// Interior ring
int numberOfInteriorRings = pol.getNumInteriorRing();
for (int ringNumber = 0; ringNumber < numberOfInteriorRings; ringNumber++) {
xbArpt = xbPolType.addNewInterior();
xbArt = xbArpt.addNewAbstractRing();
xbLrt = LinearRingType.Factory.newInstance();
ring = pol.getInteriorRingN(ringNumber);
xbPosList = xbLrt.addNewPosList();
xbPosList.setSrsName(srsName);
xbPosList.setStringValue(JTSHelper.getCoordinatesString(ring));
xbArt.set(xbLrt);
// Rename element name for output
cursor = xbArpt.newCursor();
if (cursor.toChild(GmlConstants.QN_ABSTRACT_RING_32)) {
cursor.setName(GmlConstants.QN_LINEAR_RING_32);
}
}
}
}
use of net.opengis.gml.v_3_1_1.DirectPositionListType in project arctic-sea by 52North.
the class GmlEncoderv321 method createLineStringFromJtsGeometry.
/**
* Creates a XML LineString from a SOS LineString.
*
* @param jtsLineString
* SOS LineString
* @param xbLst
* XML LinetSring
*/
private void createLineStringFromJtsGeometry(LineString jtsLineString, LineStringType xbLst) {
String srsName = getSrsName(jtsLineString);
xbLst.setSrsName(srsName);
DirectPositionListType xbPosList = xbLst.addNewPosList();
xbPosList.setSrsName(srsName);
xbPosList.setStringValue(JTSHelper.getCoordinatesString(jtsLineString));
}
use of net.opengis.gml.v_3_1_1.DirectPositionListType in project ddf by codice.
the class CswJTSToGML311LinearRingConverter method doCreateGeometryType.
/**
* @see {@code JTSToGML311LinearRingConverter#doCreateGeometryType}
*/
@Override
protected LinearRingType doCreateGeometryType(LinearRing linearRing) {
final LinearRingType resultLinearRing;
if (usePosList) {
resultLinearRing = getObjectFactory().createLinearRingType();
List<Double> posDoubleList = new ArrayList<Double>();
for (Coordinate coordinate : linearRing.getCoordinates()) {
posDoubleList.add(coordinate.x);
posDoubleList.add(coordinate.y);
}
DirectPositionListType directPosListType = new DirectPositionListType();
directPosListType.setValue(posDoubleList);
resultLinearRing.setPosList(directPosListType);
} else {
resultLinearRing = super.doCreateGeometryType(linearRing);
}
return resultLinearRing;
}
use of net.opengis.gml.v_3_1_1.DirectPositionListType 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.v_3_1_1.DirectPositionListType in project arctic-sea by 52North.
the class GmlDecoderv321 method getCoordString4LinearRing.
/**
* method parses the passed linearRing(generated thru XmlBEans) and returns a string containing the coordinate
* values of the passed ring
*
* @param xbLinearRing linearRing(generated thru XmlBEans)
*
* @return Returns a string containing the coordinate values of the passed ring
*
* @throws DecodingException * if parsing the linear Ring failed
*/
private String getCoordString4LinearRing(LinearRingType xbLinearRing) throws DecodingException {
String result = "";
DirectPositionListType xbPosList = xbLinearRing.getPosList();
CoordinatesType xbCoordinates = xbLinearRing.getCoordinates();
DirectPositionType[] xbPosArray = xbLinearRing.getPosArray();
if (xbPosList != null && !(xbPosList.getStringValue().isEmpty())) {
result = getString4PosList(xbPosList);
} else if (xbCoordinates != null && !(xbCoordinates.getStringValue().isEmpty())) {
result = getString4Coordinates(xbCoordinates);
} else if (xbPosArray != null && xbPosArray.length > 0) {
result = getString4PosArray(xbPosArray, true);
} else {
throw new DecodingException("The Polygon must contain the following elements " + "<gml:exterior><gml:LinearRing><gml:posList>, " + "<gml:exterior><gml:LinearRing><gml:coordinates> " + "or <gml:exterior><gml:LinearRing><gml:pos>{<gml:pos>}!");
}
return result;
}
Aggregations