本文整理汇总了Java中org.geotools.styling.Rule.setFilter方法的典型用法代码示例。如果您正苦于以下问题:Java Rule.setFilter方法的具体用法?Java Rule.setFilter怎么用?Java Rule.setFilter使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.geotools.styling.Rule
的用法示例。
在下文中一共展示了Rule.setFilter方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testNotFilter
import org.geotools.styling.Rule; //导入方法依赖的package包/类
@Test
public void testNotFilter() {
DummyInternalSLDFile2 dummy = new DummyInternalSLDFile2();
StyledLayerDescriptor sld = createTestSLD(dummy);
List<Rule> ruleList = getRuleList(sld);
ExtractAttributes extract = new ExtractAttributes();
Rule rule = DefaultSymbols.createNewRule();
// Try with NOT
extract = new ExtractAttributes();
Filter filter = ff.not(ff.greater(ff.literal(42.1), ff.property("dble")));
rule.setFilter(filter);
ruleList.clear();
ruleList.add(rule);
extract.extractDefaultFields(sld);
// Check fields extracted ok
List<DataSourceAttributeData> actualFieldnameList = extract.getFields();
assertEquals(1, actualFieldnameList.size());
DataSourceAttributeData dataSourceField = actualFieldnameList.get(0);
assertEquals(Double.class, dataSourceField.getType());
}
示例2: testMultiComparatorFilter
import org.geotools.styling.Rule; //导入方法依赖的package包/类
@Test
public void testMultiComparatorFilter() {
DummyInternalSLDFile2 dummy = new DummyInternalSLDFile2();
StyledLayerDescriptor sld = createTestSLD(dummy);
List<Rule> ruleList = getRuleList(sld);
Rule rule = DefaultSymbols.createNewRule();
// Try with something complex
Filter filter = ff.and(ff.greater(ff.literal(42), ff.property("int")),
ff.less(ff.literal(12), ff.property("abc")));
rule.setFilter(filter);
ruleList.clear();
ruleList.add(rule);
ExtractAttributes extract = new ExtractAttributes();
extract.extractDefaultFields(sld);
// Check fields extracted ok
List<DataSourceAttributeData> actualFieldnameList = extract.getFields();
assertEquals(2, actualFieldnameList.size());
DataSourceAttributeData dataSourceField = actualFieldnameList.get(0);
assertEquals(Integer.class, dataSourceField.getType());
}
示例3: testBinaryTemporalFilter
import org.geotools.styling.Rule; //导入方法依赖的package包/类
@Test
public void testBinaryTemporalFilter() {
DummyInternalSLDFile2 dummy = new DummyInternalSLDFile2();
StyledLayerDescriptor sld = createTestSLD(dummy);
List<Rule> ruleList = getRuleList(sld);
Rule rule = DefaultSymbols.createNewRule();
// Try begins
Filter filter = ff.begins(ff.property("test"), ff.literal("1234"));
rule.setFilter(filter);
ruleList.clear();
ruleList.add(rule);
ExtractAttributes extract = new ExtractAttributes();
extract.extractDefaultFields(sld);
// Check fields extracted ok
List<DataSourceAttributeData> actualFieldnameList = extract.getFields();
assertEquals(1, actualFieldnameList.size());
DataSourceAttributeData dataSourceField = actualFieldnameList.get(0);
assertEquals(Integer.class, dataSourceField.getType());
}
示例4: testIsNull
import org.geotools.styling.Rule; //导入方法依赖的package包/类
@Test
public void testIsNull() {
DummyInternalSLDFile2 dummy = new DummyInternalSLDFile2();
StyledLayerDescriptor sld = createTestSLD(dummy);
List<Rule> ruleList = getRuleList(sld);
Rule rule = DefaultSymbols.createNewRule();
// Try isNull
Filter filter = ff.isNull(ff.property("test"));
rule.setFilter(filter);
ruleList.clear();
ruleList.add(rule);
ExtractAttributes extract = new ExtractAttributes();
extract.extractDefaultFields(sld);
// Check fields extracted ok
List<DataSourceAttributeData> actualFieldnameList = extract.getFields();
assertEquals(1, actualFieldnameList.size());
DataSourceAttributeData dataSourceField = actualFieldnameList.get(0);
assertEquals(String.class, dataSourceField.getType());
}
示例5: testIsLike
import org.geotools.styling.Rule; //导入方法依赖的package包/类
@Test
public void testIsLike() {
DummyInternalSLDFile2 dummy = new DummyInternalSLDFile2();
StyledLayerDescriptor sld = createTestSLD(dummy);
List<Rule> ruleList = getRuleList(sld);
Rule rule = DefaultSymbols.createNewRule();
// Try isLike
Filter filter = ff.like(ff.property("test"), "abcd1");
rule.setFilter(filter);
ruleList.clear();
ruleList.add(rule);
ExtractAttributes extract = new ExtractAttributes();
extract.extractDefaultFields(sld);
// Check fields extracted ok
List<DataSourceAttributeData> actualFieldnameList = extract.getFields();
assertEquals(1, actualFieldnameList.size());
DataSourceAttributeData dataSourceField = actualFieldnameList.get(0);
assertEquals(String.class, dataSourceField.getType());
}
示例6: testIsBetween
import org.geotools.styling.Rule; //导入方法依赖的package包/类
@Test
public void testIsBetween() {
DummyInternalSLDFile2 dummy = new DummyInternalSLDFile2();
StyledLayerDescriptor sld = createTestSLD(dummy);
List<Rule> ruleList = getRuleList(sld);
Rule rule = DefaultSymbols.createNewRule();
// Try isBetween
Filter filter = ff.between(ff.property("test"), ff.literal("1.23"), ff.literal(4));
rule.setFilter(filter);
ruleList.clear();
ruleList.add(rule);
ExtractAttributes extract = new ExtractAttributes();
extract.extractDefaultFields(sld);
// Check fields extracted ok
List<DataSourceAttributeData> actualFieldnameList = extract.getFields();
assertEquals(1, actualFieldnameList.size());
DataSourceAttributeData dataSourceField = actualFieldnameList.get(0);
assertEquals(Double.class, dataSourceField.getType());
}
示例7: testBinarySpatialOperator
import org.geotools.styling.Rule; //导入方法依赖的package包/类
@Test
public void testBinarySpatialOperator() {
DummyInternalSLDFile2 dummy = new DummyInternalSLDFile2();
StyledLayerDescriptor sld = createTestSLD(dummy);
List<Rule> ruleList = getRuleList(sld);
Rule rule = DefaultSymbols.createNewRule();
// Try bbox
String expectedGeometryFieldName = "test geometry";
Filter filter = ff.bbox(expectedGeometryFieldName, -1.0, 49.0, 2.0, 55.0, "EPSG:4326");
rule.setFilter(filter);
ruleList.clear();
ruleList.add(rule);
ExtractAttributes extract = new ExtractAttributes();
extract.extractDefaultFields(sld);
// Check fields extracted ok
List<String> actualGeometryFields = extract.getGeometryFields();
assertEquals(1, actualGeometryFields.size());
assertEquals(expectedGeometryFieldName, actualGeometryFields.get(0));
List<DataSourceAttributeData> actualFieldnameList = extract.getFields();
assertEquals(0, actualFieldnameList.size());
}
示例8: testFilter
import org.geotools.styling.Rule; //导入方法依赖的package包/类
/**
* Test filter.
*/
@Test
public void testFilter() {
DummyInternalSLDFile2 dummy = new DummyInternalSLDFile2();
StyledLayerDescriptor sld = createTestSLD(dummy);
List<Rule> ruleList = getRuleList(sld);
ExtractAttributes extract = new ExtractAttributes();
Rule rule = DefaultSymbols.createNewRule();
// Try it 1) property 2) Literal
Filter filter = ff.greater(ff.property("width"), ff.literal(42.1));
rule.setFilter(filter);
ruleList.add(rule);
extract.extractDefaultFields(sld);
// Check fields extracted ok
List<DataSourceAttributeData> actualFieldnameList = extract.getFields();
assertEquals(1, actualFieldnameList.size());
DataSourceAttributeData dataSourceField = actualFieldnameList.get(0);
assertEquals(Double.class, dataSourceField.getType());
// Check geometry fields extracted ok
List<String> actualGeometryFields = extract.getGeometryFields();
assertEquals(1, actualGeometryFields.size());
// Try it 1) literal 2) property
filter = ff.greater(ff.literal(42.1), ff.property("dble"));
rule.setFilter(filter);
ruleList.clear();
ruleList.add(rule);
extract.extractDefaultFields(sld);
// Check fields extracted ok
actualFieldnameList = extract.getFields();
assertEquals(2, actualFieldnameList.size());
dataSourceField = actualFieldnameList.get(0);
assertEquals(Double.class, dataSourceField.getType());
}
示例9: createSelectedStyle
import org.geotools.styling.Rule; //导入方法依赖的package包/类
private Style createSelectedStyle(FeatureId ids) {
Rule selectedRule = createRule(SELECTED_COLOUR, SELECTED_COLOUR);
selectedRule.setFilter(ff.id(ids));
Rule otherRule = createRule(OUTLINE_COLOR, FILL_COLOR);
otherRule.setElseFilter(true);
FeatureTypeStyle fts = sf.createFeatureTypeStyle();
fts.rules().add(selectedRule);
fts.rules().add(otherRule);
Style style = sf.createStyle();
style.featureTypeStyles().add(fts);
return style;
}
示例10: createFilter
import org.geotools.styling.Rule; //导入方法依赖的package包/类
/**
* Creates the filter.
*
* @param rule the rule
* @param fieldsElement the fields element
* @param fieldDelimiterElement the field delimiter element
* @param value the value
*/
private void createFilter(Rule rule, JsonElement fieldsElement,
JsonElement fieldDelimiterElement, String value)
{
if(fieldsElement == null) return;
if(value == null)
{
rule.setElseFilter(true);
}
else
{
List<String> fieldList = new ArrayList<String>();
JsonArray fieldArray = fieldsElement.getAsJsonArray();
for(int fieldIndex = 0; fieldIndex < fieldArray.size(); fieldIndex ++)
{
JsonElement jsonFieldElement = fieldArray.get(fieldIndex);
if(jsonFieldElement != null)
{
JsonObject fieldObj = jsonFieldElement.getAsJsonObject();
fieldList.add(fieldObj.get("name").getAsString());
}
}
String[] values = null;
if(fieldDelimiterElement != null)
{
values = value.split(fieldDelimiterElement.getAsString());
}
else
{
values = new String[1];
values[0] = value;
}
List<Filter> filterList = new ArrayList<Filter>();
int index = 0;
while(index < values.length)
{
Expression fieldExpression = filterFactory.property(fieldList.get(index));
Expression valueExpression = filterFactory.literal(values[index]);
PropertyIsEqualTo filter = filterFactory.equals(fieldExpression, valueExpression);
filterList.add(filter);
index ++;
}
Filter completeFilter = null;
if(filterList.size() > 1)
{
completeFilter = filterFactory.and(filterList);
}
else if(filterList.size() == 1)
{
completeFilter = filterList.get(0);
}
rule.setFilter(completeFilter);
}
}
示例11: visit
import org.geotools.styling.Rule; //导入方法依赖的package包/类
/**
* Visit.
*
* @param rule the rule
*/
/*
* (non-Javadoc)
*
* @see org.geotools.styling.visitor.DuplicatingStyleVisitor#visit(org.geotools.styling.Rule)
*/
@SuppressWarnings("deprecation")
@Override
public void visit(Rule rule) {
Rule copy = null;
Symbolizer[] symsCopy = null;
if (!displayOverall) {
if ((symbolizerIndex >= 0) && (symbolizerIndex < rule.getSymbolizers().length)) {
symsCopy = new Symbolizer[1];
symsCopy[0] = copy(rule.getSymbolizers()[symbolizerIndex]);
}
}
// As a catch all copy everything
if (symsCopy == null) {
symsCopy = rule.getSymbolizers();
for (int i = 0; i < symsCopy.length; i++) {
symsCopy[i] = copy(symsCopy[i]);
}
}
Graphic[] legendCopy = rule.getLegendGraphic();
for (int i = 0; i < legendCopy.length; i++) {
legendCopy[i] = copy(legendCopy[i]);
}
Description descCopy = rule.getDescription();
descCopy = copy(descCopy);
copy = sf.createRule();
copy.setSymbolizers(symsCopy);
copy.setDescription(descCopy);
copy.setLegendGraphic(legendCopy);
copy.setName(rule.getName());
Filter filterCopy = null;
copy.setFilter(filterCopy);
copy.setElseFilter(rule.isElseFilter());
// Do not copy the min and max scales
if (STRICT && !copy.equals(rule)) {
throw new IllegalStateException("Was unable to duplicate provided Rule:" + rule);
}
pages.push(copy);
}