Search in sources :

Example 11 with ExtractAttributes

use of com.sldeditor.datasource.impl.ExtractAttributes in project sldeditor by robward-scisys.

the class ExtractAttributesTest method testBinarySpatialOperator.

@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());
}
Also used : StyledLayerDescriptor(org.geotools.styling.StyledLayerDescriptor) DataSourceAttributeData(com.sldeditor.datasource.attribute.DataSourceAttributeData) Filter(org.opengis.filter.Filter) ExtractAttributes(com.sldeditor.datasource.impl.ExtractAttributes) Rule(org.geotools.styling.Rule) Test(org.junit.Test)

Example 12 with ExtractAttributes

use of com.sldeditor.datasource.impl.ExtractAttributes in project sldeditor by robward-scisys.

the class ExtractAttributesTest method testBinaryTemporalFilter.

@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());
}
Also used : StyledLayerDescriptor(org.geotools.styling.StyledLayerDescriptor) DataSourceAttributeData(com.sldeditor.datasource.attribute.DataSourceAttributeData) Filter(org.opengis.filter.Filter) ExtractAttributes(com.sldeditor.datasource.impl.ExtractAttributes) Rule(org.geotools.styling.Rule) Test(org.junit.Test)

Aggregations

DataSourceAttributeData (com.sldeditor.datasource.attribute.DataSourceAttributeData)12 ExtractAttributes (com.sldeditor.datasource.impl.ExtractAttributes)12 Test (org.junit.Test)11 StyledLayerDescriptor (org.geotools.styling.StyledLayerDescriptor)9 Rule (org.geotools.styling.Rule)8 Filter (org.opengis.filter.Filter)8 DataSourceImpl (com.sldeditor.datasource.impl.DataSourceImpl)1