use of org.geotoolkit.gml.xml.v321.CoordinatesType in project ddf by codice.
the class WfsFilterDelegate method createCoordinates.
private CoordinatesType createCoordinates(Geometry geometry) {
CoordinatesType coords = gml320ObjectFactory.createCoordinatesType();
Coordinate[] coordinates = geometry.getCoordinates();
if (coordinates != null && coordinates.length > 0) {
StringBuffer coordString = new StringBuffer();
for (Coordinate coordinate : coordinates) {
coordString.append(coordinate.x).append(",").append(coordinate.y).append(" ");
}
coords.setValue(coordString.toString());
coords.setDecimal(".");
coords.setCs(",");
coords.setTs(" ");
coords.setValue(coordString.toString());
return coords;
} else {
throw new IllegalArgumentException("Unable to parse Geometry coordinates from WKT String");
}
}
use of org.geotoolkit.gml.xml.v321.CoordinatesType in project arctic-sea by 52North.
the class AbstractCoverageEncoder method encodeValueList.
/**
* Encode value list of {@link RangeSetType} from {@link DiscreteCoverage}
*
* @param rst
* The {@link RangeSetType} to encode value list for
* @param discreteCoverage
* The {@link DiscreteCoverage} with the value list
* @throws EncodingException
* If an error occurs
*/
protected void encodeValueList(RangeSetType rst, DiscreteCoverage<?> discreteCoverage) throws EncodingException {
List<?> list = getList(discreteCoverage);
Value<?> value = discreteCoverage.getRangeSet().iterator().next();
if (value instanceof BooleanValue) {
BooleanListDocument bld = BooleanListDocument.Factory.newInstance(getXmlOptions());
bld.setBooleanList(list);
rst.set(bld);
} else if (value instanceof CategoryValue || value instanceof TextValue) {
DataBlockType dbt = rst.addNewDataBlock();
dbt.addNewRangeParameters().setHref(discreteCoverage.getRangeParameters());
CoordinatesType ct = dbt.addNewTupleList();
ct.setCs(",");
ct.setStringValue(Joiner.on(",").join(list));
} else if (value instanceof CountValue) {
CountListDocument cld = CountListDocument.Factory.newInstance(getXmlOptions());
cld.setCountList(list);
rst.set(cld);
} else if (value instanceof QuantityValue) {
QuantityListDocument qld = QuantityListDocument.Factory.newInstance(getXmlOptions());
MeasureOrNilReasonListType monrlt = qld.addNewQuantityList();
if (discreteCoverage.isSetUnit()) {
monrlt.setUom(discreteCoverage.getUnit());
} else if (value.isSetUnit()) {
monrlt.setUom(value.getUnit());
}
monrlt.setListValue(list);
rst.set(qld);
}
}
use of org.geotoolkit.gml.xml.v321.CoordinatesType in project geotoolkit by Geomatys.
the class JsonBindingTest method testMarshallingExecuteV2.
@Test
public void testMarshallingExecuteV2() throws JAXBException, IOException, URISyntaxException {
PointType pt = new PointType(new CoordinatesType());
Format format = new Format().encoding("UTF8").mimeType("text/xml").schema("http://kk.com");
final Execute executeRoot = new Execute();
ComplexInput ci = new ComplexInput(format, new ValueType("not a point", null));
Input dataInput = new Input("input1", ci);
executeRoot.addInputsItem(dataInput);
Output output = new Output();
output.setId("out-1");
output.setTransmissionMode(DataTransmissionMode.REFERENCE);
executeRoot.setOutputs(Arrays.asList(output));
executeRoot.setMode(org.geotoolkit.wps.xml.v200.Execute.Mode.async);
executeRoot.setResponse(org.geotoolkit.wps.xml.v200.Execute.Response.document);
ObjectMapper m = getMapper();
StringWriter sw = new StringWriter();
m.writeValue(sw, executeRoot);
String expResult = IOUtilities.toString(IOUtilities.getResourceAsPath("json/executeRequest6.json"));
expResult = expResult.replace(" ", "");
expResult = expResult.replace("\n", "");
String result = sw.toString().replace(" ", "");
assertEquals(expResult, result);
}
use of org.geotoolkit.gml.xml.v321.CoordinatesType in project ddf by codice.
the class WfsFilterDelegate method createPoint.
private JAXBElement<PointType> createPoint(Geometry geometry) {
Coordinate[] coordinates = geometry.getCoordinates();
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 gml320ObjectFactory.createPoint(point);
} else {
throw new IllegalArgumentException("Unable to parse Point coordinates from WKT String");
}
}
use of org.geotoolkit.gml.xml.v321.CoordinatesType in project ddf by codice.
the class WfsFilterDelegate method createPoint.
private JAXBElement<AbstractGeometryType> createPoint(String wkt) {
Coordinate[] coordinates = getCoordinatesFromWkt(wkt);
if (coordinates != null && coordinates.length > 0) {
CoordinatesType coordinatesType = new CoordinatesType();
String coordinateString = coordinateStrategy.toString(coordinates[0]);
coordinatesType.setValue(coordinateString);
PointType point = new PointType();
point.setCoordinates(coordinatesType);
return gmlObjectFactory.createGeometry(point);
} else {
throw new IllegalArgumentException("Unable to parse Point coordinates from WKT String");
}
}
Aggregations