use of org.geotoolkit.gml.xml.v321.EnvelopeType in project geotoolkit by Geomatys.
the class FilterToOGC200Converter method visit.
public JAXBElement visit(Filter filter) {
if (filter.equals(Filter.include()) || filter.equals(Filter.exclude())) {
return null;
}
final CodeList<?> type = filter.getOperatorType();
if (filter instanceof BetweenComparisonOperator) {
final BetweenComparisonOperator pib = (BetweenComparisonOperator) filter;
final LowerBoundaryType lbt = ogc_factory.createLowerBoundaryType();
lbt.setExpression(extract(pib.getLowerBoundary()));
final UpperBoundaryType ubt = ogc_factory.createUpperBoundaryType();
ubt.setExpression(extract(pib.getUpperBoundary()));
final PropertyIsBetweenType bot = new PropertyIsBetweenType();
bot.setExpression(extract(pib.getExpression()));
bot.setLowerBoundary(lbt);
bot.setUpperBoundary(ubt);
return ogc_factory.createPropertyIsBetween(bot);
} else if (type == ComparisonOperatorName.PROPERTY_IS_EQUAL_TO) {
final BinaryComparisonOperator pit = (BinaryComparisonOperator) filter;
final PropertyIsEqualToType bot = new PropertyIsEqualToType();
bot.getExpression().add(extract(pit.getOperand1()));
bot.getExpression().add(extract(pit.getOperand2()));
return ogc_factory.createPropertyIsEqualTo(bot);
} else if (type == ComparisonOperatorName.PROPERTY_IS_GREATER_THAN) {
final BinaryComparisonOperator pit = (BinaryComparisonOperator) filter;
final PropertyIsGreaterThanType bot = new PropertyIsGreaterThanType();
bot.getExpression().add(extract(pit.getOperand1()));
bot.getExpression().add(extract(pit.getOperand2()));
return ogc_factory.createPropertyIsGreaterThan(bot);
} else if (type == ComparisonOperatorName.PROPERTY_IS_GREATER_THAN_OR_EQUAL_TO) {
final BinaryComparisonOperator pit = (BinaryComparisonOperator) filter;
final PropertyIsGreaterThanOrEqualToType bot = new PropertyIsGreaterThanOrEqualToType();
bot.getExpression().add(extract(pit.getOperand1()));
bot.getExpression().add(extract(pit.getOperand2()));
return ogc_factory.createPropertyIsGreaterThanOrEqualTo(bot);
} else if (type == ComparisonOperatorName.PROPERTY_IS_LESS_THAN) {
final BinaryComparisonOperator pit = (BinaryComparisonOperator) filter;
final PropertyIsLessThanType bot = new PropertyIsLessThanType();
bot.getExpression().add(extract(pit.getOperand1()));
bot.getExpression().add(extract(pit.getOperand2()));
return ogc_factory.createPropertyIsLessThan(bot);
} else if (type == ComparisonOperatorName.PROPERTY_IS_LESS_THAN_OR_EQUAL_TO) {
final BinaryComparisonOperator pit = (BinaryComparisonOperator) filter;
final PropertyIsLessThanOrEqualToType bot = new PropertyIsLessThanOrEqualToType();
bot.getExpression().add(extract(pit.getOperand1()));
bot.getExpression().add(extract(pit.getOperand2()));
return ogc_factory.createPropertyIsLessThanOrEqualTo(bot);
} else if (filter instanceof LikeOperator) {
final LikeOperator pis = (LikeOperator) filter;
final List<Expression> expressions = filter.getExpressions();
final PropertyIsLikeType bot = ogc_factory.createPropertyIsLikeType();
bot.setEscape(String.valueOf(pis.getEscapeChar()));
final LiteralType lt = ogc_factory.createLiteralType();
lt.setContent(((Literal) expressions.get(1)).getValue());
bot.getElements().add(ogc_factory.createLiteral(lt));
final Expression expression = expressions.get(0);
if (!(expression instanceof ValueReference)) {
throw new IllegalArgumentException("LikeOperator can support ValueReference only, but was a " + expression);
}
bot.getElements().add(0, extract(expression));
bot.setSingleChar(String.valueOf(pis.getSingleChar()));
bot.setWildCard(String.valueOf(pis.getWildCard()));
return ogc_factory.createPropertyIsLike(bot);
} else if (type == ComparisonOperatorName.PROPERTY_IS_NOT_EQUAL_TO) {
final BinaryComparisonOperator pit = (BinaryComparisonOperator) filter;
final PropertyIsNotEqualToType bot = new PropertyIsNotEqualToType();
bot.getExpression().add(extract(pit.getOperand1()));
bot.getExpression().add(extract(pit.getOperand2()));
return ogc_factory.createPropertyIsNotEqualTo(bot);
} else if (filter instanceof NullOperator) {
final NullOperator pis = (NullOperator) filter;
final PropertyIsNullType bot = ogc_factory.createPropertyIsNullType();
bot.setExpression(extract((Expression) pis.getExpressions().get(0)));
return ogc_factory.createPropertyIsNull(bot);
} else if (type == LogicalOperatorName.AND) {
final LogicalOperator and = (LogicalOperator) filter;
final List<JAXBElement> lot = new ArrayList<>();
for (final Filter f : (List<Filter>) and.getOperands()) {
final JAXBElement<?> ele = visit(f);
if (ele != null && ele.getValue() instanceof LogicOpsType) {
lot.add(ele);
}
}
return ogc_factory.createAnd(new AndType(lot.toArray()));
} else if (type == LogicalOperatorName.OR) {
final LogicalOperator or = (LogicalOperator) filter;
final List<JAXBElement> lot = new ArrayList<>();
for (final Filter f : (List<Filter>) or.getOperands()) {
final JAXBElement subFilter = visit(f);
if (subFilter != null) {
lot.add(subFilter);
}
}
return ogc_factory.createOr(new OrType(lot.toArray()));
} else if (type == LogicalOperatorName.NOT) {
final LogicalOperator not = (LogicalOperator) filter;
final JAXBElement<?> sf = visit((Filter) not.getOperands().get(0));
// should not happen
return ogc_factory.createNot(new NotType(sf));
} else if (filter instanceof ResourceId) {
throw new IllegalArgumentException("Not parsed yet : " + filter);
} else if (type == SpatialOperatorName.BBOX) {
final BBOX bbox = BBOX.wrap((BinarySpatialOperator) filter);
final Expression left = bbox.getOperand1();
final Expression right = bbox.getOperand2();
final String property;
final double minx;
final double maxx;
final double miny;
final double maxy;
String srs;
if (left instanceof ValueReference) {
property = ((ValueReference) left).getXPath();
final Object objGeom = ((Literal) right).getValue();
if (objGeom instanceof org.opengis.geometry.Envelope) {
final org.opengis.geometry.Envelope env = (org.opengis.geometry.Envelope) objGeom;
minx = env.getMinimum(0);
maxx = env.getMaximum(0);
miny = env.getMinimum(1);
maxy = env.getMaximum(1);
try {
srs = IdentifiedObjects.lookupURN(env.getCoordinateReferenceSystem(), null);
if (srs == null) {
srs = ReferencingUtilities.lookupIdentifier(env.getCoordinateReferenceSystem(), true);
}
} catch (FactoryException ex) {
throw new IllegalArgumentException("invalid bbox element : " + filter + " " + ex.getMessage(), ex);
}
} else if (objGeom instanceof Geometry) {
final Geometry geom = (Geometry) objGeom;
final Envelope env = geom.getEnvelopeInternal();
minx = env.getMinX();
maxx = env.getMaxX();
miny = env.getMinY();
maxy = env.getMaxY();
srs = SRIDGenerator.toSRS(geom.getSRID(), SRIDGenerator.Version.V1);
} else {
throw new IllegalArgumentException("invalid bbox element : " + filter);
}
} else if (right instanceof ValueReference) {
property = ((ValueReference) right).getXPath();
final Object objGeom = ((Literal) left).getValue();
if (objGeom instanceof org.opengis.geometry.Envelope) {
final org.opengis.geometry.Envelope env = (org.opengis.geometry.Envelope) objGeom;
minx = env.getMinimum(0);
maxx = env.getMaximum(0);
miny = env.getMinimum(1);
maxy = env.getMaximum(1);
try {
srs = IdentifiedObjects.lookupURN(env.getCoordinateReferenceSystem(), null);
if (srs == null) {
srs = ReferencingUtilities.lookupIdentifier(env.getCoordinateReferenceSystem(), true);
}
} catch (FactoryException ex) {
throw new IllegalArgumentException("invalid bbox element : " + filter + " " + ex.getMessage(), ex);
}
} else if (objGeom instanceof Geometry) {
final Geometry geom = (Geometry) objGeom;
final Envelope env = geom.getEnvelopeInternal();
minx = env.getMinX();
maxx = env.getMaxX();
miny = env.getMinY();
maxy = env.getMaxY();
srs = SRIDGenerator.toSRS(geom.getSRID(), SRIDGenerator.Version.V1);
} else {
throw new IllegalArgumentException("invalid bbox element : " + filter);
}
} else {
throw new IllegalArgumentException("invalid bbox element : " + filter);
}
final BBOXType bbtype = new BBOXType(property, minx, miny, maxx, maxy, srs);
return ogc_factory.createBBOX(bbtype);
} else if (filter instanceof ResourceId) {
final ValueReference n = FF.property(AttributeConvention.IDENTIFIER);
ResourceId idFilter = (ResourceId) filter;
final String id = idFilter.getIdentifier();
final ResourceIdType rId = ogc_factory.createResourceIdType();
rId.setRid(id);
return ogc_factory.createResourceId(rId);
} else if (filter instanceof BinarySpatialOperator) {
final BinarySpatialOperator spatialOp = (BinarySpatialOperator) filter;
Expression exp1 = spatialOp.getOperand1();
Expression exp2 = spatialOp.getOperand2();
if (!(exp1 instanceof ValueReference)) {
// flip order
final Expression ex = exp1;
exp1 = exp2;
exp2 = ex;
}
if (!(exp1 instanceof ValueReference)) {
throw new IllegalArgumentException("Filter can not be transformed in xml filter, " + "expression are not of the required type ");
} else if (!(exp2 instanceof Literal)) {
throw new IllegalArgumentException("Spatial operator should use a literal object containing the filtering geometry.");
}
final JAXBElement pnt = extract(exp1);
final String pName;
if (pnt.getValue() instanceof String) {
pName = (String) pnt.getValue();
} else {
throw new IllegalArgumentException("Property name cannot be cast to string.");
}
final JAXBElement<?> geometryExpression;
final Object geom = ((Literal) exp2).getValue();
if (geom instanceof Geometry) {
final Geometry jts = (Geometry) geom;
final String srid = SRIDGenerator.toSRS(jts.getSRID(), SRIDGenerator.Version.V1);
CoordinateReferenceSystem crs;
try {
crs = CRS.forCode(srid);
} catch (Exception ex) {
Logger.getLogger("org.geotoolkit.sld.xml").log(Level.WARNING, null, ex);
crs = null;
}
final AbstractGeometry gmlGeom;
try {
gmlGeom = JTStoGeometry.toGML("3.2.1", jts);
} catch (FactoryException ex) {
throw new IllegalArgumentException(ex);
}
// TODO use gml method to return any JAXBElement
if (gmlGeom instanceof PointType) {
geometryExpression = gml_factory.createPoint((PointType) gmlGeom);
} else if (gmlGeom instanceof CurveType) {
geometryExpression = gml_factory.createCurve((CurveType) gmlGeom);
} else if (gmlGeom instanceof LineStringType) {
geometryExpression = gml_factory.createLineString((LineStringType) gmlGeom);
} else if (gmlGeom instanceof PolygonType) {
geometryExpression = gml_factory.createPolygon((PolygonType) gmlGeom);
} else if (gmlGeom instanceof MultiSurfaceType) {
geometryExpression = gml_factory.createMultiSurface((MultiSurfaceType) gmlGeom);
} else if (gmlGeom instanceof MultiCurveType) {
geometryExpression = gml_factory.createMultiCurve((MultiCurveType) gmlGeom);
} else if (gmlGeom instanceof MultiPointType) {
geometryExpression = gml_factory.createMultiPoint((MultiPointType) gmlGeom);
} else if (gmlGeom instanceof MultiGeometryType) {
geometryExpression = gml_factory.createMultiGeometry((MultiGeometryType) gmlGeom);
} else if (gmlGeom instanceof SurfaceType) {
geometryExpression = gml_factory.createPolyhedralSurface((SurfaceType) gmlGeom);
} else {
throw new IllegalArgumentException("Unexpected Geometry type:" + gmlGeom.getClass().getName());
}
} else if (geom instanceof org.opengis.geometry.Geometry) {
throw new UnsupportedOperationException("No valid ISO implementation avaiable for now.");
} else if (geom instanceof org.opengis.geometry.Envelope) {
final org.opengis.geometry.Envelope genv = (org.opengis.geometry.Envelope) geom;
EnvelopeType ee = gml_factory.createEnvelopeType();
ee.setSrsDimension(genv.getDimension());
if (genv.getCoordinateReferenceSystem() != null) {
String urn;
try {
urn = IdentifiedObjects.lookupURN(genv.getCoordinateReferenceSystem(), null);
} catch (FactoryException ex) {
Logger.getLogger("org.geotoolkit.sld.xml").log(Level.WARNING, null, ex);
urn = null;
}
if (urn == null) {
urn = IdentifiedObjects.getIdentifierOrName(genv.getCoordinateReferenceSystem());
}
if (urn != null) {
ee.setSrsName(urn);
}
}
ee.setLowerCorner(new DirectPositionType(genv.getLowerCorner(), false));
ee.setUpperCorner(new DirectPositionType(genv.getUpperCorner(), false));
geometryExpression = gml_factory.createEnvelope(ee);
} else {
throw new IllegalArgumentException("Type is neither geometric nor envelope.");
}
if (type == DistanceOperatorName.BEYOND) {
throw new UnsupportedOperationException();
} else if (type == SpatialOperatorName.CONTAINS) {
return ogc_factory.createContains(new ContainsType(pName, geometryExpression));
} else if (type == SpatialOperatorName.CROSSES) {
ogc_factory.createCrosses(new CrossesType(pName, geometryExpression));
} else if (type == DistanceOperatorName.WITHIN) {
Quantity q = ((DistanceOperator) filter).getDistance();
return ogc_factory.createDWithin(new DWithinType(pName, geometryExpression, q.getValue().doubleValue(), q.getUnit().toString()));
} else if (type == SpatialOperatorName.DISJOINT) {
return ogc_factory.createDisjoint(new DisjointType(pName, geometryExpression));
} else if (type == SpatialOperatorName.EQUALS) {
return ogc_factory.createEquals(new EqualsType(pName, geometryExpression));
} else if (type == SpatialOperatorName.INTERSECTS) {
return ogc_factory.createIntersects(new IntersectsType(pName, geometryExpression));
} else if (type == SpatialOperatorName.OVERLAPS) {
return ogc_factory.createOverlaps(new OverlapsType(pName, geometryExpression));
} else if (type == SpatialOperatorName.TOUCHES) {
return ogc_factory.createTouches(new TouchesType(pName, geometryExpression));
} else if (type == SpatialOperatorName.WITHIN) {
return ogc_factory.createWithin(new WithinType(pName, geometryExpression));
}
throw new IllegalArgumentException("Unknown filter element : " + filter + " class :" + filter.getClass());
}
throw new IllegalArgumentException("Unknown filter element : " + filter + " class :" + filter.getClass());
}
use of org.geotoolkit.gml.xml.v321.EnvelopeType in project geotoolkit by Geomatys.
the class OGC110toGTTransformer method visitSpatialOp.
/**
* Transform a SLD spatial Filter v1.1 in GT filter.
*/
public Filter visitSpatialOp(final JAXBElement<? extends org.geotoolkit.ogc.xml.v110.SpatialOpsType> jax) throws NoSuchAuthorityCodeException, FactoryException {
final org.geotoolkit.ogc.xml.v110.SpatialOpsType ops = jax.getValue();
final String OpName = jax.getName().getLocalPart();
if (ops instanceof org.geotoolkit.ogc.xml.v110.BinarySpatialOpType) {
final org.geotoolkit.ogc.xml.v110.BinarySpatialOpType binary = (org.geotoolkit.ogc.xml.v110.BinarySpatialOpType) ops;
final JAXBElement<? extends AbstractGeometryType> geom = binary.getAbstractGeometry();
final JAXBElement<EnvelopeType> env = binary.getEnvelope();
final org.geotoolkit.ogc.xml.v110.PropertyNameType pnt = binary.getPropertyName().getValue();
final Expression left = visitPropertyName(pnt);
final Expression right;
if (env != null && env.getValue() != null) {
try {
right = visitEnv(env);
} catch (FactoryException ex) {
throw new IllegalArgumentException("SRS name is unknowned : " + ex.getLocalizedMessage(), ex);
}
} else {
right = visit(geom);
}
if (OGCJAXBStatics.FILTER_SPATIAL_CONTAINS.equalsIgnoreCase(OpName)) {
return filterFactory.contains(left, right);
} else if (OGCJAXBStatics.FILTER_SPATIAL_CROSSES.equalsIgnoreCase(OpName)) {
return filterFactory.crosses(left, right);
} else if (OGCJAXBStatics.FILTER_SPATIAL_DISJOINT.equalsIgnoreCase(OpName)) {
return filterFactory.disjoint(left, right);
} else if (OGCJAXBStatics.FILTER_SPATIAL_EQUALS.equalsIgnoreCase(OpName)) {
return filterFactory.equals(left, right);
} else if (OGCJAXBStatics.FILTER_SPATIAL_INTERSECTS.equalsIgnoreCase(OpName)) {
return filterFactory.intersects(left, right);
} else if (OGCJAXBStatics.FILTER_SPATIAL_OVERLAPS.equalsIgnoreCase(OpName)) {
return filterFactory.overlaps(left, right);
} else if (OGCJAXBStatics.FILTER_SPATIAL_TOUCHES.equalsIgnoreCase(OpName)) {
return filterFactory.touches(left, right);
} else if (OGCJAXBStatics.FILTER_SPATIAL_WITHIN.equalsIgnoreCase(OpName)) {
return filterFactory.within(left, right);
}
throw new IllegalArgumentException("Illegal filter element" + OpName + " : " + ops);
} else if (ops instanceof org.geotoolkit.ogc.xml.v110.DistanceBufferType) {
final org.geotoolkit.ogc.xml.v110.DistanceBufferType dstOp = (org.geotoolkit.ogc.xml.v110.DistanceBufferType) ops;
final org.geotoolkit.ogc.xml.v110.DistanceType dt = dstOp.getDistanceType();
final JAXBElement<? extends AbstractGeometryType> geom = dstOp.getAbstractGeometry();
final org.geotoolkit.ogc.xml.v110.PropertyNameType pnt = dstOp.getPropertyName();
final Expression geom1 = visitPropertyName(pnt);
final Expression geom2 = visit(geom);
// TODO marche pas ? ou est la distance ? Double.valueOf(dt.getContent());
final double distance = 0;
final String units = dt.getUnits();
if (OGCJAXBStatics.FILTER_SPATIAL_DWITHIN.equalsIgnoreCase(OpName)) {
return filterFactory.dwithin(geom1, geom2, distance, units);
} else if (OGCJAXBStatics.FILTER_SPATIAL_BEYOND.equalsIgnoreCase(OpName)) {
return filterFactory.beyond(geom1, geom2, distance, units);
}
throw new IllegalArgumentException("Illegal filter element" + OpName + " : " + ops);
} else if (ops instanceof org.geotoolkit.ogc.xml.v110.BBOXType) {
final org.geotoolkit.ogc.xml.v110.BBOXType binary = (org.geotoolkit.ogc.xml.v110.BBOXType) ops;
final EnvelopeType box = binary.getEnvelope();
final String pnt = binary.getPropertyName();
final Expression geom;
if (pnt != null) {
geom = visitPropertyName(pnt);
} else {
geom = null;
}
final double minx = box.getLowerCorner().getOrdinate(0);
final double maxx = box.getUpperCorner().getOrdinate(0);
final double miny = box.getLowerCorner().getOrdinate(1);
final double maxy = box.getUpperCorner().getOrdinate(1);
// final double minx = box.getPos().get(0).getOrdinate(0);
// final double maxx = box.getPos().get(0).getOrdinate(1);
// final double miny = box.getPos().get(1).getOrdinate(0);
// final double maxy = box.getPos().get(1).getOrdinate(1);
final String srs = box.getSrsName();
if (OGCJAXBStatics.FILTER_SPATIAL_BBOX.equalsIgnoreCase(OpName)) {
return filterFactory.bbox(geom, minx, miny, maxx, maxy, srs);
}
throw new IllegalArgumentException("Illegal filter element" + OpName + " : " + ops);
}
throw new IllegalArgumentException("Unknowed filter element" + jax);
}
use of org.geotoolkit.gml.xml.v321.EnvelopeType in project geotoolkit by Geomatys.
the class OGC200toGTTransformer method visitSpatialOp.
/**
* Transform a SLD spatial Filter v1.1 in GT filter.
*/
public Filter visitSpatialOp(final JAXBElement<? extends org.geotoolkit.ogc.xml.v200.SpatialOpsType> jax) throws NoSuchAuthorityCodeException, FactoryException {
final org.geotoolkit.ogc.xml.v200.SpatialOpsType ops = jax.getValue();
final String OpName = jax.getName().getLocalPart();
if (ops instanceof org.geotoolkit.ogc.xml.v200.BinarySpatialOpType) {
final org.geotoolkit.ogc.xml.v200.BinarySpatialOpType binary = (org.geotoolkit.ogc.xml.v200.BinarySpatialOpType) ops;
Object geom = binary.getAny();
if (geom instanceof JAXBElement) {
geom = ((JAXBElement) geom).getValue();
}
final Expression left = visitPropertyName(binary.getValueReference());
final Expression right;
if (geom instanceof EnvelopeType) {
try {
right = visitEnv((EnvelopeType) geom);
} catch (FactoryException ex) {
throw new IllegalArgumentException("SRS name is unknowned : " + ex.getLocalizedMessage(), ex);
}
} else if (geom instanceof AbstractGeometryType) {
right = visit((AbstractGeometryType) geom);
} else {
throw new IllegalArgumentException("Unexpected geometry type:" + geom);
}
if (OGCJAXBStatics.FILTER_SPATIAL_CONTAINS.equalsIgnoreCase(OpName)) {
return filterFactory.contains(left, right);
} else if (OGCJAXBStatics.FILTER_SPATIAL_CROSSES.equalsIgnoreCase(OpName)) {
return filterFactory.crosses(left, right);
} else if (OGCJAXBStatics.FILTER_SPATIAL_DISJOINT.equalsIgnoreCase(OpName)) {
return filterFactory.disjoint(left, right);
} else if (OGCJAXBStatics.FILTER_SPATIAL_EQUALS.equalsIgnoreCase(OpName)) {
return filterFactory.equals(left, right);
} else if (OGCJAXBStatics.FILTER_SPATIAL_INTERSECTS.equalsIgnoreCase(OpName)) {
return filterFactory.intersects(left, right);
} else if (OGCJAXBStatics.FILTER_SPATIAL_OVERLAPS.equalsIgnoreCase(OpName)) {
return filterFactory.overlaps(left, right);
} else if (OGCJAXBStatics.FILTER_SPATIAL_TOUCHES.equalsIgnoreCase(OpName)) {
return filterFactory.touches(left, right);
} else if (OGCJAXBStatics.FILTER_SPATIAL_WITHIN.equalsIgnoreCase(OpName)) {
return filterFactory.within(left, right);
}
throw new IllegalArgumentException("Illegal filter element" + OpName + " : " + ops);
} else if (ops instanceof org.geotoolkit.ogc.xml.v200.DistanceBufferType) {
final org.geotoolkit.ogc.xml.v200.DistanceBufferType dstOp = (org.geotoolkit.ogc.xml.v200.DistanceBufferType) ops;
final org.geotoolkit.ogc.xml.v200.MeasureType dt = dstOp.getDistanceType();
Object opAny = dstOp.getAny();
if (opAny instanceof JAXBElement) {
opAny = ((JAXBElement) opAny).getValue();
}
if (!(opAny instanceof AbstractGeometryType)) {
throw new IllegalArgumentException("geometry type is unexpected:" + opAny);
}
final AbstractGeometryType geom = (AbstractGeometryType) opAny;
final String pnt = dstOp.getPropertyName();
final Expression geom1 = visitPropertyName(pnt);
final Expression geom2 = visit(geom);
// TODO marche pas ? ou est la distance ? Double.valueOf(dt.getContent());
final double distance = 0;
final String units = dt.getUom();
if (OGCJAXBStatics.FILTER_SPATIAL_DWITHIN.equalsIgnoreCase(OpName)) {
return filterFactory.dwithin(geom1, geom2, distance, units);
} else if (OGCJAXBStatics.FILTER_SPATIAL_BEYOND.equalsIgnoreCase(OpName)) {
return filterFactory.beyond(geom1, geom2, distance, units);
}
throw new IllegalArgumentException("Illegal filter element" + OpName + " : " + ops);
} else if (ops instanceof org.geotoolkit.ogc.xml.v200.BBOXType) {
final org.geotoolkit.ogc.xml.v200.BBOXType binary = (org.geotoolkit.ogc.xml.v200.BBOXType) ops;
Object binAny = binary.getAny();
if (binAny instanceof JAXBElement) {
binAny = ((JAXBElement) binAny).getValue();
}
if (!(binAny instanceof EnvelopeType)) {
throw new IllegalArgumentException("geometry type is unexpected:" + binAny);
}
final EnvelopeType box = (EnvelopeType) binAny;
final String pnt = binary.getPropertyName();
final Expression geom;
if (pnt != null) {
geom = visitPropertyName(pnt);
} else {
geom = null;
}
final double minx = box.getLowerCorner().getOrdinate(0);
final double maxx = box.getUpperCorner().getOrdinate(0);
final double miny = box.getLowerCorner().getOrdinate(1);
final double maxy = box.getUpperCorner().getOrdinate(1);
final String srs = box.getSrsName();
if (OGCJAXBStatics.FILTER_SPATIAL_BBOX.equalsIgnoreCase(OpName)) {
return filterFactory.bbox(geom, minx, miny, maxx, maxy, srs);
}
throw new IllegalArgumentException("Illegal filter element" + OpName + " : " + ops);
}
throw new IllegalArgumentException("Unknowed filter element" + jax);
}
use of org.geotoolkit.gml.xml.v321.EnvelopeType in project geotoolkit by Geomatys.
the class OGC200toGTTransformer method visitEnv.
public Expression visitEnv(final EnvelopeType entry) throws FactoryException {
final String srs = entry.getSrsName();
final DirectPositionType lower = entry.getLowerCorner();
final DirectPositionType upper = entry.getUpperCorner();
GeneralEnvelope genv = new GeneralEnvelope(CRS.forCode(srs));
genv.setRange(0, lower.getOrdinate(0), upper.getOrdinate(0));
genv.setRange(1, lower.getOrdinate(1), upper.getOrdinate(1));
return filterFactory.literal(genv);
}
use of org.geotoolkit.gml.xml.v321.EnvelopeType in project geotoolkit by Geomatys.
the class OwcXmlIO method read.
private static MapLayers read(final FeedType feed) throws JAXBException, FactoryException, DataStoreException {
final MapLayers context = MapBuilder.createContext();
for (Object o : feed.getAuthorOrCategoryOrContributor()) {
if (o instanceof JAXBElement) {
o = ((JAXBElement) o).getValue();
}
if (o instanceof TextType) {
final TextType title = (TextType) o;
title.getContent();
} else if (o instanceof WhereType) {
final WhereType where = (WhereType) o;
final EnvelopeType envelopeType = where.getEnvelope();
context.setAreaOfInterest(envelopeType);
} else if (o instanceof EntryType) {
final EntryType entry = (EntryType) o;
final MapItem item = readEntry(entry);
// find insert parent
final String[] path = item.getIdentifier().split("/");
MapLayers parent = context;
for (int i = 0; i < path.length - 1; i++) {
parent = (MapLayers) findItem(parent, path[i]);
}
item.setIdentifier(path[path.length - 1]);
parent.getComponents().add(item);
}
}
return context;
}
Aggregations