use of org.geotoolkit.gml.xml.v321.DirectPositionType in project geotoolkit by Geomatys.
the class GmlXMLBindingTest method umarshallingTest.
@Test
public void umarshallingTest() throws Exception {
LineStringSegmentType expResult = new LineStringSegmentType();
DirectPositionListType posList = new DirectPositionListType();
posList.setValue(Arrays.asList(1.0, 1.1, 1.2));
expResult.setPosList(posList);
String xml = "<gml:LineStringSegment xmlns:gml=\"http://www.opengis.net/gml\">" + '\n' + " <gml:posList>1.0 1.1 1.2</gml:posList>" + '\n' + "</gml:LineStringSegment>" + '\n';
Object result = unmarshaller.unmarshal(new StringReader(xml));
if (result instanceof JAXBElement) {
result = ((JAXBElement) result).getValue();
}
assertEquals(expResult, result);
expResult = new LineStringSegmentType();
DirectPositionType pos1 = new DirectPositionType(Arrays.asList(1.1, 1.2));
DirectPositionType pos2 = new DirectPositionType(Arrays.asList(2.3, 48.1));
expResult.getPos().add(pos1);
expResult.getPos().add(pos2);
xml = "<gml:LineStringSegment xmlns:gml=\"http://www.opengis.net/gml\">" + '\n' + " <gml:pos>1.1 1.2</gml:pos>" + '\n' + " <gml:pos>2.3 48.1</gml:pos>" + '\n' + "</gml:LineStringSegment>" + '\n';
result = unmarshaller.unmarshal(new StringReader(xml));
if (result instanceof JAXBElement) {
result = ((JAXBElement) result).getValue();
}
assertEquals(expResult, result);
}
use of org.geotoolkit.gml.xml.v321.DirectPositionType in project geotoolkit by Geomatys.
the class GmlXMLBindingTest method umarshallingTest.
@Test
public void umarshallingTest() throws Exception {
LineStringSegmentType expResult = new LineStringSegmentType();
DirectPositionListType posList = new DirectPositionListType();
posList.setValue(Arrays.asList(1.0, 1.1, 1.2));
expResult.setPosList(posList);
String xml = "<gml:LineStringSegment xmlns:gml=\"http://www.opengis.net/gml/3.2\">" + '\n' + " <gml:posList>1.0 1.1 1.2</gml:posList>" + '\n' + "</gml:LineStringSegment>" + '\n';
Object result = unmarshaller.unmarshal(new StringReader(xml));
if (result instanceof JAXBElement) {
result = ((JAXBElement) result).getValue();
}
assertEquals(expResult, result);
expResult = new LineStringSegmentType();
DirectPositionType pos1 = new DirectPositionType(Arrays.asList(1.1, 1.2));
DirectPositionType pos2 = new DirectPositionType(Arrays.asList(2.3, 48.1));
expResult.getPos().add(pos1);
expResult.getPos().add(pos2);
xml = "<gml:LineStringSegment xmlns:gml=\"http://www.opengis.net/gml/3.2\">" + '\n' + " <gml:pos>1.1 1.2</gml:pos>" + '\n' + " <gml:pos>2.3 48.1</gml:pos>" + '\n' + "</gml:LineStringSegment>" + '\n';
result = unmarshaller.unmarshal(new StringReader(xml));
if (result instanceof JAXBElement) {
result = ((JAXBElement) result).getValue();
}
assertEquals(expResult, result);
}
use of org.geotoolkit.gml.xml.v321.DirectPositionType in project geotoolkit by Geomatys.
the class GmlXMLBindingTest method marshallingTest.
/**
* Test simple Record Marshalling.
*
* @throws JAXBException
*/
@Test
public void marshallingTest() throws Exception {
DirectPositionType lower = new DirectPositionType(-30.711, 134.196);
DirectPositionType upper = new DirectPositionType(-30.702, 134.205);
EnvelopeType env = new EnvelopeType(lower, upper, "urn:ogc:def:crs:EPSG:6.8:4283");
StringWriter sw = new StringWriter();
marshaller.marshal(FACTORY.createEnvelope(env), sw);
String result = sw.toString();
// we remove the first line
result = result.substring(result.indexOf("?>") + 2).trim();
String expResult = "<gml:Envelope xmlns:gml=\"http://www.opengis.net/gml/3.2\" srsName=\"urn:ogc:def:crs:EPSG:6.8:4283\" >" + '\n' + " <gml:lowerCorner>-30.711 134.196</gml:lowerCorner>" + '\n' + " <gml:upperCorner>-30.702 134.205</gml:upperCorner>" + '\n' + "</gml:Envelope>" + '\n';
DocumentComparator comparator = new DocumentComparator(expResult, result) {
@Override
protected strictfp void compareNames(Node expected, Node actual) {
final String[] exArray = expected.getNodeName().split(":");
final String[] acArray = actual.getNodeName().split(":");
assertEquals(exArray.length, acArray.length);
assertEquals(exArray[exArray.length - 1], acArray[acArray.length - 1]);
}
};
comparator.ignoredAttributes.add("http://www.w3.org/2000/xmlns:*");
comparator.compare();
Duration d1 = javax.xml.datatype.DatatypeFactory.newInstance().newDuration("P2D");
TimePeriodType tp = new TimePeriodType(d1);
marshaller.marshal(FACTORY.createTimePeriod(tp), sw);
TimePositionType tpos = new TimePositionType("2002-08-15");
tp = new TimePeriodType(tpos);
marshaller.marshal(FACTORY.createTimePeriod(tp), sw);
// System.out.println(sw.toString());
LineStringSegmentType ls = new LineStringSegmentType();
DirectPositionListType posList = new DirectPositionListType();
posList.setValue(Arrays.asList(1.0, 1.1, 1.2));
ls.setPosList(posList);
sw = new StringWriter();
marshaller.marshal(FACTORY.createLineStringSegment(ls), sw);
result = sw.toString();
// we remove the first line
result = result.substring(result.indexOf("?>") + 2).trim();
expResult = "<gml:LineStringSegment xmlns:gml=\"http://www.opengis.net/gml/3.2\">" + '\n' + " <gml:posList>1.0 1.1 1.2</gml:posList>" + '\n' + "</gml:LineStringSegment>" + '\n';
comparator = new DocumentComparator(expResult, result) {
@Override
protected strictfp void compareNames(Node expected, Node actual) {
final String[] exArray = expected.getNodeName().split(":");
final String[] acArray = actual.getNodeName().split(":");
assertEquals(exArray.length, acArray.length);
assertEquals(exArray[exArray.length - 1], acArray[acArray.length - 1]);
}
};
comparator.ignoredAttributes.add("http://www.w3.org/2000/xmlns:*");
comparator.compare();
ls = new LineStringSegmentType();
DirectPositionType pos1 = new DirectPositionType(Arrays.asList(1.1, 1.2));
DirectPositionType pos2 = new DirectPositionType(Arrays.asList(2.3, 48.1));
ls.getPos().add(pos1);
ls.getPos().add(pos2);
sw = new StringWriter();
marshaller.marshal(FACTORY.createLineStringSegment(ls), sw);
result = sw.toString();
// we remove the first line
result = result.substring(result.indexOf("?>") + 2).trim();
expResult = "<gml:LineStringSegment xmlns:gml=\"http://www.opengis.net/gml/3.2\">" + '\n' + " <gml:pos>1.1 1.2</gml:pos>" + '\n' + " <gml:pos>2.3 48.1</gml:pos>" + '\n' + "</gml:LineStringSegment>" + '\n';
comparator = new DocumentComparator(expResult, result) {
@Override
protected strictfp void compareNames(Node expected, Node actual) {
final String[] exArray = expected.getNodeName().split(":");
final String[] acArray = actual.getNodeName().split(":");
assertEquals(exArray.length, acArray.length);
assertEquals(exArray[exArray.length - 1], acArray[acArray.length - 1]);
}
};
comparator.ignoredAttributes.add("http://www.w3.org/2000/xmlns:*");
comparator.compare();
}
use of org.geotoolkit.gml.xml.v321.DirectPositionType in project ddf by codice.
the class Wfs20JTStoGML321Converter method convertToDirectPositionType.
public static DirectPositionType convertToDirectPositionType(Coordinate coordinate, String srsName) {
DirectPositionType directPositionType = GML320_OBJECT_FACTORY.createDirectPositionType();
directPositionType.getValue().add(Double.valueOf(coordinate.x));
directPositionType.getValue().add(Double.valueOf(coordinate.y));
directPositionType.setSrsName(srsName);
if (!Double.isNaN(coordinate.z)) {
directPositionType.getValue().add(Double.valueOf(coordinate.z));
}
return directPositionType;
}
use of org.geotoolkit.gml.xml.v321.DirectPositionType in project ddf by codice.
the class WfsFilterDelegateTest method testIntersectsAsBoundingBox.
@Test
public void testIntersectsAsBoundingBox() {
WfsFilterDelegate delegate = setupFilterDelegate(SPATIAL_OPERATORS.BBOX.getValue(), new LonLatCoordinateStrategy());
FilterType filter = delegate.intersects(Metacard.ANY_GEO, POLYGON);
assertThat(filter.getSpatialOps().getValue(), is(instanceOf(BBOXType.class)));
assertThat(filter.isSetLogicOps(), is(false));
BBOXType bboxType = (BBOXType) filter.getSpatialOps().getValue();
EnvelopeType envelope = bboxType.getEnvelope().getValue();
DirectPositionType lowerCorner = envelope.getLowerCorner();
assertThat("The bounding box's lower corner was null.", lowerCorner, is(notNullValue()));
assertThat(lowerCorner.getValue(), is(asList(10.0, -10.0)));
DirectPositionType upperCorner = envelope.getUpperCorner();
assertThat("The bounding box's upper corner was null.", upperCorner, is(notNullValue()));
assertThat(upperCorner.getValue(), is(asList(40.0, 30.0)));
}
Aggregations