DefaultFilterVisitor filterVisitor = new DefaultFilterVisitor() {
@Override
public Object visit(BBOX filter, Object data) {
Envelope2D envelope = (Envelope2D) data;
filter.getBounds();
envelope.setBounds(filter.getBounds());
return super.visit(filter, data);
}
@Override
public Object visit(Intersects filter, Object data) {
Envelope2D envelope = (Envelope2D) data;
Geometry polygon= ((Geometry)((Literal)filter.getExpression2()).getValue());
org.opengis.geometry.Geometry polygon2 = JTSUtils.jtsToGo1(polygon, envelope.getCoordinateReferenceSystem());
envelope.setBounds(new Envelope2D(polygon2.getEnvelope()));
return super.visit(filter, data);
}
/**
* Used by WCS 2.0 to select a time range
*/
@Override
public Object visit(PropertyIsGreaterThanOrEqualTo filter, Object data) {
PropertyName prop;
Literal lit;
if (filter.getExpression1() instanceof PropertyName && filter.getExpression2() instanceof Literal) {
prop = (PropertyName) filter.getExpression1();
lit = (Literal) filter.getExpression2();
} else if (filter.getExpression2() instanceof PropertyName
&& filter.getExpression1() instanceof Literal) {
prop = (PropertyName) filter.getExpression1();
lit = (Literal) filter.getExpression2();
} else {
return super.visit(filter, data);
}
if (prop.getPropertyName().equals(TIME_ATTRIBUTE)) {
if(lit.getValue()!=null){
beginDate.setTime(((Date) lit.getValue()).getTime());
}
}
return super.visit(filter, data);
}
/**
* Used by WCS 2.0 to select a time range
*/
@Override
public Object visit(PropertyIsLessThanOrEqualTo filter, Object data) {
PropertyName prop;
Literal lit;
if (filter.getExpression1() instanceof PropertyName && filter.getExpression2() instanceof Literal) {
prop = (PropertyName) filter.getExpression1();
lit = (Literal) filter.getExpression2();
} else if (filter.getExpression2() instanceof PropertyName
&& filter.getExpression1() instanceof Literal) {
prop = (PropertyName) filter.getExpression1();
lit = (Literal) filter.getExpression2();
} else {
return super.visit(filter, data);
}
if (prop.getPropertyName().equals(TIME_ATTRIBUTE)) {
if(lit.getValue()!=null){
endDate.setTime(((Date) lit.getValue()).getTime());
}
}
return super.visit(filter, data);
}
@Override
public Object visit(PropertyIsEqualTo filter, Object data) {
PropertyName prop;
Literal lit;
if (filter.getExpression1() instanceof PropertyName && filter.getExpression2() instanceof Literal) {
prop = (PropertyName) filter.getExpression1();
lit = (Literal) filter.getExpression2();
} else if (filter.getExpression2() instanceof PropertyName
&& filter.getExpression1() instanceof Literal) {
prop = (PropertyName) filter.getExpression1();
lit = (Literal) filter.getExpression2();
} else {
return super.visit(filter, data);
}
if (prop.getPropertyName().equals(TIME_ATTRIBUTE)) {
date.setTime(((Date) lit.getValue()).getTime());
}
if (prop.getPropertyName().equals(BAND_DIMENSION)) {
band.add((String) lit.getValue());
}
return super.visit(filter, data);
}
@Override
public Object visit(PropertyIsBetween filter, Object data) {
PropertyName prop = (PropertyName) filter.getExpression();
if (prop.getPropertyName().equals(TIME_ATTRIBUTE)) {
beginDate.setTime(((Date) ((Literal)filter.getLowerBoundary()).getValue()).getTime());
endDate.setTime(((Date) ((Literal)filter.getUpperBoundary()).getValue()).getTime());
} if (prop.getPropertyName().equals(BAND_DIMENSION)) {
String bands = (String) ((Literal)filter.getLowerBoundary()).getValue();
String[] singleBands = bands.split(",");
band.addAll(Arrays.asList(singleBands));
}
return super.visit(filter, data);
}
};
Envelope2D bbox = new Envelope2D(DefaultGeographicCRS.WGS84,-180,-90,360,180);
query.getFilter().accept(filterVisitor, bbox);
LOGGER.fine("Mosaic query on bbox: " + bbox);
//very rudimentary filtering, for unit test only!
if(bbox.getMaxX()<=35.){
return wrapAndCache(Arrays.asList(feature1));
}else{
return wrapAndCache(Arrays.asList(feature1,feature2));
}