use of org.geotoolkit.kml.xml.v220.PointType in project geotoolkit by Geomatys.
the class WmtsXmlBindingTest method marshallingTest.
/**
* Test simple Record Marshalling.
*
* @throws java.lang.Exception
*/
@Test
public void marshallingTest() throws Exception {
PointType pt = new PointType("p1", new DirectPositionType(-90.080000, 29.982000));
TileMatrix matrix = new TileMatrix(new CodeType("16d"), 55218.001386, 256, 256, 3, 3);
StringWriter sw = new StringWriter();
marshaller.marshal(matrix, sw);
String result = sw.toString();
// System.out.println("RESULT:" + result);
String expResult = "<TileMatrix xmlns=\"http://www.opengis.net/wmts/1.0\" xmlns:ows=\"http://www.opengis.net/ows/1.1\">" + '\n' + " <ows:Identifier>16d</ows:Identifier>" + '\n' + " <ScaleDenominator>55218.001386</ScaleDenominator>" + '\n' + " <TileWidth>256</TileWidth>" + '\n' + " <TileHeight>256</TileHeight>" + '\n' + " <MatrixWidth>3</MatrixWidth>" + '\n' + " <MatrixHeight>3</MatrixHeight>" + '\n' + "</TileMatrix>" + '\n';
assertXmlEquals(expResult, result, "xmlns:*");
}
use of org.geotoolkit.kml.xml.v220.PointType in project geotoolkit by Geomatys.
the class GeometrytoJTSTest method gmlPointToJTSTest3D.
@Test
public void gmlPointToJTSTest3D() throws Exception {
Point expected = GF.createPoint(new Coordinate(0, 1, 1));
expected.setSRID(2154);
PointType gml = new PointType(new DirectPositionType(0.0, 1.0, 1.0));
final Geometry result = GeometrytoJTS.toJTS(gml);
Assert.assertEquals(expected, result);
}
use of org.geotoolkit.kml.xml.v220.PointType in project geotoolkit by Geomatys.
the class KMLStore method convert.
private static Geometry convert(Object geomType) throws DataStoreException {
if (geomType instanceof JAXBElement)
geomType = ((JAXBElement) geomType).getValue();
Geometry geom = null;
if (geomType instanceof ModelType) {
final ModelType modelType = (ModelType) geomType;
final LocationType location = modelType.getLocation();
geom = GF.createPoint(new Coordinate(location.getLongitude(), location.getLatitude()));
} else if (geomType instanceof PointType) {
final PointType pointType = (PointType) geomType;
final List<String> coordinates = pointType.getCoordinates();
geom = GF.createPoint(toCoordinates(coordinates, 1, false));
} else if (geomType instanceof PolygonType) {
final PolygonType polygonType = (PolygonType) geomType;
final CoordinateSequence outter = toCoordinates(polygonType.getOuterBoundaryIs().getLinearRing().getCoordinates(), 3, true);
final List<BoundaryType> inners = polygonType.getInnerBoundaryIs();
final LinearRing[] holes = new LinearRing[inners.size()];
for (int i = 0; i < holes.length; i++) {
holes[i] = GF.createLinearRing(toCoordinates(inners.get(i).getLinearRing().getCoordinates(), 3, true));
}
geom = GF.createPolygon(GF.createLinearRing(outter), holes);
} else if (geomType instanceof LinearRingType) {
final LinearRingType linearRingType = (LinearRingType) geomType;
geom = GF.createLineString(toCoordinates(linearRingType.getCoordinates(), 3, true));
} else if (geomType instanceof MultiGeometryType) {
final MultiGeometryType multigeometryType = (MultiGeometryType) geomType;
final List<JAXBElement<? extends AbstractGeometryType>> children = multigeometryType.getAbstractGeometryGroup();
final Geometry[] childs = new Geometry[children.size()];
for (int i = 0; i < childs.length; i++) {
childs[i] = convert(children.get(i));
}
geom = GF.createGeometryCollection(childs);
} else if (geomType instanceof LineStringType) {
final LineStringType lineStringType = (LineStringType) geomType;
geom = GF.createLineString(toCoordinates(lineStringType.getCoordinates(), 2, false));
}
if (geom != null) {
JTS.setCRS(geom, CRS);
}
return geom;
}
use of org.geotoolkit.kml.xml.v220.PointType in project geotoolkit by Geomatys.
the class ExecuteTest method testRequestAndMarshall.
@Test
public void testRequestAndMarshall() throws Exception {
final WebProcessingClient client = new WebProcessingClient(new URL("http://test.com"), null, WPSVersion.v100);
final ExecuteRequest request = client.createExecute();
final Execute execute = request.getContent();
final GeographicCRS epsg4326 = CommonCRS.WGS84.geographic();
final GeneralEnvelope env = new GeneralEnvelope(epsg4326);
env.setRange(0, 10, 10);
env.setRange(1, 10, 10);
execute.setIdentifier("identifier");
final List<DataInput> inputs = execute.getInput();
inputs.add(new DataInput("literal", new Data(new LiteralValue("10", null, null))));
inputs.add(new DataInput("bbox", new Data(new BoundingBoxType(env))));
inputs.add(new DataInput("complex", new Data(new Format("UTF-8", WPSMimeType.APP_GML.val(), WPSSchema.OGC_GML_3_1_1.getValue(), null), new PointType(new DirectPosition2D(epsg4326, 0, 0)))));
inputs.add(new DataInput("reference", new Reference("http://link.to/reference/", null, null)));
execute.getOutput().add(new OutputDefinition("output", false));
assertEquals("WPS", execute.getService());
assertEquals("1.0.0", execute.getVersion().toString());
assertEquals(execute.getIdentifier().getValue(), "identifier");
final StringWriter stringWriter = new StringWriter();
final Marshaller marshaller = WPSMarshallerPool.getInstance().acquireMarshaller();
marshaller.marshal(execute, stringWriter);
String result = stringWriter.toString();
try (final InputStream expected = expectedRequest()) {
assertXmlEquals(expected, result, "xmlns:*", "crs", "srsName");
}
WPSMarshallerPool.getInstance().recycle(marshaller);
}
Aggregations