use of org.opengis.filter.Expression in project geotoolkit by Geomatys.
the class CapabilitiesFilterSplitter method visitBinaryComparisonOperator.
private void visitBinaryComparisonOperator(final BinaryComparisonOperator<Object> filter) {
if (original == null) {
original = filter;
}
// supports it as a group -- no need to check the type
if (!fcs.supports(filter)) {
postStack.addFirst(filter);
return;
}
final int i = postStack.size();
final Expression leftValue = filter.getOperand1();
final Expression rightValue = filter.getOperand2();
if (leftValue == null || rightValue == null) {
postStack.addFirst(filter);
return;
}
visit(leftValue, null);
if (i < postStack.size()) {
postStack.removeFirst();
postStack.addFirst(filter);
return;
}
visit(rightValue, null);
if (i < postStack.size()) {
// left
preStack.removeFirst();
postStack.removeFirst();
postStack.addFirst(filter);
return;
}
// left side
preStack.removeFirst();
// right side
preStack.removeFirst();
preStack.addFirst(filter);
}
use of org.opengis.filter.Expression in project geotoolkit by Geomatys.
the class LuceneOGCWeight method scorer.
@Override
public Scorer scorer(LeafReaderContext context) throws IOException {
// final SortedDocValues values = context.reader().getSortedDocValues(IDENTIFIER_FIELD_NAME);
final LeafReader reader = context.reader();
boolean treeSearch = false;
boolean reverse = false;
boolean distanceFilter = false;
final Set<String> treeMatching = new HashSet<>();
if (tree != null) {
/*
* For distance buffer filter no envelope only mode
*/
List<Expression<Object, ?>> expressions = filter.getExpressions();
Expression e2 = (expressions.size() >= 2) ? expressions.get(1) : null;
if (filter instanceof DistanceOperator) {
distanceFilter = true;
reverse = filter.getOperatorType() == DistanceOperatorName.BEYOND;
final DistanceOperator sp = (DistanceOperator) filter;
if (e2 instanceof Literal) {
try {
final Literal lit = (Literal) e2;
Quantity distance = sp.getDistance();
final GeneralEnvelope bound = getExtendedReprojectedEnvelope(lit.getValue(), tree.getCrs(), distance.getUnit().toString(), distance.getValue().doubleValue());
final int[] resultID = tree.searchID(bound);
Arrays.sort(resultID);
treeMatching.clear();
TreeElementMapper<NamedEnvelope> tem = tree.getTreeElementMapper();
for (int id : resultID) {
final NamedEnvelope env = tem.getObjectFromTreeIdentifier(id);
if (env != null) {
treeMatching.add(env.getId());
}
}
treeSearch = true;
} catch (FactoryException ex) {
throw new IOException(ex);
} catch (StoreIndexException ex) {
Throwable cause = ex.getCause();
if (cause instanceof IOException) {
throw (IOException) cause;
} else {
throw new IOException(ex);
}
}
} else {
LOGGER.log(Level.WARNING, "Not a literal for spatial filter:{0}", e2);
}
} else if (filter instanceof BinarySpatialOperator) {
final BinarySpatialOperator sp = (BinarySpatialOperator) filter;
if (e2 instanceof Literal) {
final Literal lit = (Literal) e2;
final Envelope boundFilter = getReprojectedEnvelope(lit.getValue(), tree.getCrs());
try {
if (filterType == SpatialFilterType.CROSSES || !envelopeOnly) {
if (filterType == SpatialFilterType.DISJOINT) {
reverse = true;
}
final int[] resultID = tree.searchID(boundFilter);
Arrays.sort(resultID);
final TreeElementMapper<NamedEnvelope> tem = tree.getTreeElementMapper();
treeMatching.clear();
for (int id : resultID) {
final NamedEnvelope env = tem.getObjectFromTreeIdentifier(id);
if (env != null) {
treeMatching.add(env.getId());
}
}
treeSearch = true;
envelopeOnly = false;
} else {
final int[] resultID = TreeX.search(tree, boundFilter, filterType);
Arrays.sort(resultID);
final TreeElementMapper<NamedEnvelope> tem = tree.getTreeElementMapper();
treeMatching.clear();
for (int id : resultID) {
final NamedEnvelope env = tem.getObjectFromTreeIdentifier(id);
if (env != null) {
treeMatching.add(env.getId());
}
}
treeSearch = true;
}
} catch (StoreIndexException ex) {
Throwable cause = ex.getCause();
if (cause instanceof IOException) {
throw (IOException) cause;
} else {
throw new IOException(ex);
}
}
} else {
LOGGER.log(Level.WARNING, "Not a literal for spatial filter:{0}", e2);
}
} else {
LOGGER.log(Level.WARNING, "not a spatial operator:{0}", filter.getClass().getName());
}
} else {
LOGGER.finer("Null R-tree in spatial search");
}
final BitSet set = new FixedBitSet(reader.maxDoc());
Bits b = reader.getLiveDocs();
if (b == null) {
b = new Bits.MatchAllBits(reader.maxDoc());
}
for (int i = 0; i < b.length(); i++) {
if (b.get(i)) {
final int docId = i;
final Document doc = reader.document(docId, ID_FIELDS);
final String id = doc.get(IDENTIFIER_FIELD_NAME);
final boolean match = treeMatching.contains(id);
if (treeSearch && reverse && !match) {
set.set(docId);
} else if (!treeSearch || match) {
if (envelopeOnly && !distanceFilter) {
set.set(docId);
} else {
final Document geoDoc = reader.document(docId, GEOMETRY_FIELDS);
if (filter.test(geoDoc)) {
set.set(docId);
}
}
}
}
}
return new ConstantScoreScorer(this, boost, scoreMode, new BitSetIterator(set, 5));
}
use of org.opengis.filter.Expression in project geotoolkit by Geomatys.
the class DefaultStyleVisitor method visit.
@Override
public Object visit(final AnchorPoint anchorPoint, Object data) {
final Expression x = anchorPoint.getAnchorPointX();
if (x != null) {
visit(x, data);
}
final Expression y = anchorPoint.getAnchorPointY();
if (y != null) {
visit(y, data);
}
return data;
}
use of org.opengis.filter.Expression in project geotoolkit by Geomatys.
the class DefaultStyleVisitor method visit.
@Override
public Object visit(final Stroke stroke, Object data) {
final Expression color = stroke.getColor();
if (color != null) {
visit(color, data);
}
final Expression offset = stroke.getDashOffset();
if (offset != null) {
visit(offset, data);
}
final GraphicFill gf = stroke.getGraphicFill();
if (gf != null) {
data = visit(gf, data);
}
final GraphicStroke gs = stroke.getGraphicStroke();
if (gs != null) {
data = visit(gs, data);
}
final Expression lc = stroke.getLineCap();
if (lc != null) {
visit(lc, data);
}
final Expression lj = stroke.getLineJoin();
if (lj != null) {
visit(lj, data);
}
final Expression opa = stroke.getOpacity();
if (opa != null) {
visit(opa, data);
}
final Expression width = stroke.getWidth();
if (width != null) {
visit(width, data);
}
return data;
}
use of org.opengis.filter.Expression in project geotoolkit by Geomatys.
the class DefaultStyleVisitor method visit.
@Override
public Object visit(final Font font, Object data) {
final List<Expression> families = font.getFamily();
if (families != null) {
for (Expression family : families) {
visit(family, data);
}
}
final Expression size = font.getSize();
if (size != null) {
visit(size, data);
}
final Expression style = font.getStyle();
if (style != null) {
visit(style, data);
}
final Expression weight = font.getWeight();
if (weight != null) {
visit(weight, data);
}
return data;
}
Aggregations