use of org.geotoolkit.ogc.xml.v110.LiteralType in project geotoolkit by Geomatys.
the class FilterFactoryImpl method greaterOrEqual.
@Override
public BinaryComparisonOperator<Object> greaterOrEqual(final Expression<Object, ?> expr1, final Expression<Object, ?> expr2) {
LiteralType lit = null;
PropertyNameType propName = null;
if (expr1 instanceof PropertyNameType) {
propName = (PropertyNameType) expr1;
} else if (expr2 instanceof PropertyNameType) {
propName = (PropertyNameType) expr2;
}
if (expr1 instanceof LiteralType) {
lit = (LiteralType) expr1;
} else if (expr2 instanceof LiteralType) {
lit = (LiteralType) expr2;
}
return new PropertyIsGreaterThanOrEqualToType(lit, propName, null);
}
use of org.geotoolkit.ogc.xml.v110.LiteralType in project geotoolkit by Geomatys.
the class FilterFactoryImpl method touches.
@Override
public BinarySpatialOperator<Object> touches(final Expression<Object, ?> propertyName1, final Expression<Object, ?> geometry2) {
PropertyNameType propertyName = null;
if (propertyName1 instanceof PropertyNameType) {
propertyName = (PropertyNameType) propertyName1;
} else {
throw new IllegalArgumentException("unexpected type instead of propertyNameType: " + propertyName1.getClass().getSimpleName());
}
// we transform the JTS geometry into a GML geometry
Object geom = null;
if (geometry2 instanceof LiteralType) {
geom = ((LiteralType) geometry2).getValue();
geom = GeometryToGML(geom);
}
return new TouchesType(propertyName, geom);
}
use of org.geotoolkit.ogc.xml.v110.LiteralType in project geotoolkit by Geomatys.
the class FilterFactoryImpl method contains.
@Override
public BinarySpatialOperator<Object> contains(final Expression<Object, ?> geometry1, final Expression<Object, ?> geometry2) {
// we get the propertyName
PropertyNameType propertyName = null;
if (geometry1 instanceof PropertyNameType) {
propertyName = (PropertyNameType) geometry1;
} else {
throw new IllegalArgumentException("unexpected type instead of propertyNameType: " + geometry1.getClass().getSimpleName());
}
// we transform the JTS geometry into a GML geometry
Object geom = null;
if (geometry2 instanceof LiteralType) {
geom = ((LiteralType) geometry2).getValue();
geom = GeometryToGML(geom);
}
return new ContainsType(propertyName, geom);
}
use of org.geotoolkit.ogc.xml.v110.LiteralType in project geotoolkit by Geomatys.
the class FilterFactoryImpl method within.
@Override
public BinarySpatialOperator<Object> within(final Expression<Object, ?> geometry1, final Expression<Object, ?> geometry2) {
PropertyNameType propertyName = null;
if (geometry1 instanceof PropertyNameType) {
propertyName = (PropertyNameType) geometry1;
} else {
throw new IllegalArgumentException("unexpected type instead of propertyNameType: " + geometry1.getClass().getSimpleName());
}
// we transform the JTS geometry into a GML geometry
Object geom = null;
if (geometry2 instanceof LiteralType) {
geom = ((LiteralType) geometry2).getValue();
geom = GeometryToGML(geom);
}
return new WithinType(propertyName, geom);
}
use of org.geotoolkit.ogc.xml.v110.LiteralType in project geotoolkit by Geomatys.
the class FilterXMLBindingTest method filterMarshalingTest.
/**
* Test simple Record Marshalling.
*
* @throws JAXBException
*/
@Test
public void filterMarshalingTest() throws JAXBException, IOException, ParserConfigurationException, SAXException {
/*
* Test marshalling spatial filter
*/
DirectPositionType lowerCorner = new DirectPositionType(10.0, 11.0);
DirectPositionType upperCorner = new DirectPositionType(10.0, 11.0);
EnvelopeType envelope = new EnvelopeType(lowerCorner, upperCorner, "EPSG:4326");
OverlapsType filterElement = new OverlapsType(new PropertyNameType("boundingBox"), envelope);
FilterType filter = new FilterType(filterElement);
StringWriter sw = new StringWriter();
marshaller.marshal(filter, sw);
String result = sw.toString();
String expResult = "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>" + '\n' + "<ogc:Filter xmlns:ogc=\"http://www.opengis.net/ogc\" xmlns:gml=\"http://www.opengis.net/gml\">" + '\n' + " <ogc:Overlaps>" + '\n' + " <ogc:PropertyName>boundingBox</ogc:PropertyName>" + '\n' + " <gml:Envelope srsName=\"EPSG:4326\">" + '\n' + " <gml:lowerCorner>10.0 11.0</gml:lowerCorner>" + '\n' + " <gml:upperCorner>10.0 11.0</gml:upperCorner>" + '\n' + " </gml:Envelope>" + '\n' + " </ogc:Overlaps>" + '\n' + "</ogc:Filter>" + '\n';
LOGGER.log(Level.FINER, "result: {0}", result);
LOGGER.log(Level.FINER, "expected: {0}", expResult);
assertXmlEquals(expResult, result, "xmlns:*");
ObjectFactory factory = new ObjectFactory();
final BBOXType bbox = new BBOXType("propName", envelope);
org.geotoolkit.ogc.xml.v200.FilterType filter2 = new org.geotoolkit.ogc.xml.v200.FilterType(bbox);
sw = new StringWriter();
marshaller.marshal(filter2, sw);
result = sw.toString();
expResult = "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n" + "<fes:Filter xmlns:fes=\"http://www.opengis.net/fes/2.0\" xmlns:ns8=\"http://www.opengis.net/gml\">\n" + " <fes:BBOX>\n" + " <fes:ValueReference>propName</fes:ValueReference>\n" + " <ns8:Envelope srsName=\"EPSG:4326\">\n" + " <ns8:lowerCorner>10.0 11.0</ns8:lowerCorner>\n" + " <ns8:upperCorner>10.0 11.0</ns8:upperCorner>\n" + " </ns8:Envelope>\n" + " </fes:BBOX>\n" + "</fes:Filter>";
assertXmlEquals(expResult, result, "xmlns:*");
/*--------------------------------------------*/
/*- --------------- DEBUG --------------------*/
/*--------------------------------------------*/
String[] arr = new String[2];
arr[0] = "boby";
arr[1] = "DESC";
SortPropertyType sp = new SortPropertyType(arr[0], SortOrderType.valueOf(arr[1]));
SortByType sort = new SortByType(Arrays.asList(sp));
JAXBElement<SortByType> jbSort = factory.createSortBy(sort);
// marshaller.marshal(jbSort, System.out);
sp = new SortPropertyType(arr[0], FilterUtilities.sortOrder(arr[1]));
sort = new SortByType(Arrays.asList(sp));
jbSort = factory.createSortBy(sort);
// marshaller.marshal(jbSort, System.out);
BBOXType filterBox = new BBOXType("boundingBox", "$test");
org.geotoolkit.ogc.xml.v200.FilterType filter3 = new org.geotoolkit.ogc.xml.v200.FilterType(filterBox);
sw = new StringWriter();
marshaller.marshal(filter3, sw);
result = sw.toString();
expResult = "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n" + "<fes:Filter xmlns:fes=\"http://www.opengis.net/fes/2.0\">\n" + " <fes:BBOX>\n" + " <fes:ValueReference>boundingBox</fes:ValueReference>$test</fes:BBOX>\n" + "</fes:Filter>";
assertXmlEquals(expResult, result, "xmlns:*");
TimeAfterType filterAfter = new TimeAfterType("boundingBox", "$test");
org.geotoolkit.ogc.xml.v200.FilterType filter4 = new org.geotoolkit.ogc.xml.v200.FilterType(filterAfter);
sw = new StringWriter();
marshaller.marshal(filter4, sw);
result = sw.toString();
expResult = "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n" + "<fes:Filter xmlns:fes=\"http://www.opengis.net/fes/2.0\">\n" + " <fes:After>\n" + " <fes:ValueReference>boundingBox</fes:ValueReference>$test</fes:After>\n" + "</fes:Filter>";
assertXmlEquals(expResult, result, "xmlns:*");
final org.geotoolkit.gml.xml.v321.ObjectFactory gmlFactory = new org.geotoolkit.gml.xml.v321.ObjectFactory();
final org.geotoolkit.ogc.xml.v200.ObjectFactory fesFactory = new org.geotoolkit.ogc.xml.v200.ObjectFactory();
PropertyIsBetweenType pes = new PropertyIsBetweenType();
pes.setExpression(fesFactory.createValueReference((String) "prop"));
final LowerBoundaryType lower = new LowerBoundaryType();
final TimeInstantType ti = new TimeInstantType("2002");
final LiteralType lowlit = new LiteralType(gmlFactory.createTimeInstant(ti));
lower.setExpression(fesFactory.createLiteral(lowlit));
pes.setLowerBoundary(lower);
final UpperBoundaryType upper = new UpperBoundaryType();
final TimeInstantType ti2 = new TimeInstantType("2004");
final LiteralType upplit = new LiteralType(gmlFactory.createTimeInstant(ti2));
upper.setExpression(fesFactory.createLiteral(upplit));
pes.setUpperBoundary(upper);
org.geotoolkit.ogc.xml.v200.FilterType filter5 = new org.geotoolkit.ogc.xml.v200.FilterType(pes);
sw = new StringWriter();
marshaller.marshal(filter5, sw);
result = sw.toString();
expResult = "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n" + "<fes:Filter xmlns:gml=\"http://www.opengis.net/gml/3.2\" xmlns:fes=\"http://www.opengis.net/fes/2.0\">\n" + " <fes:PropertyIsBetween>\n" + " <fes:ValueReference>prop</fes:ValueReference>\n" + " <fes:LowerBoundary>\n" + " <fes:Literal>\n" + " <gml:TimeInstant>\n" + " <gml:timePosition>2002</gml:timePosition>\n" + " </gml:TimeInstant>\n" + " </fes:Literal>\n" + " </fes:LowerBoundary>\n" + " <fes:UpperBoundary>\n" + " <fes:Literal>\n" + " <gml:TimeInstant>\n" + " <gml:timePosition>2004</gml:timePosition>\n" + " </gml:TimeInstant>\n" + " </fes:Literal>\n" + " </fes:UpperBoundary>\n" + " </fes:PropertyIsBetween>\n" + "</fes:Filter>";
assertXmlEquals(expResult, result, "xmlns:*");
}
Aggregations