Search in sources :

Example 36 with DataSourceAttributeData

use of com.sldeditor.datasource.attribute.DataSourceAttributeData in project sldeditor by robward-scisys.

the class ExtractAttributesTest method testIsNull.

@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());
}
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 37 with DataSourceAttributeData

use of com.sldeditor.datasource.attribute.DataSourceAttributeData in project sldeditor by robward-scisys.

the class ExtractAttributesTest method testNonStandardGeometryField.

/**
 * Test sld symbol contains non-default geometry field.
 *
 * {@link com.sldeditor.datasource.impl.ExtractAttributes#addDefaultFields(org.geotools.feature.simple.SimpleFeatureTypeBuilder, java.lang.String)}.
 */
@Test
public void testNonStandardGeometryField() {
    DummyInternalSLDFile2 dummy = new DummyInternalSLDFile2();
    ExtractAttributes extract = new ExtractAttributes();
    extract.extractDefaultFields(SLDUtils.createSLDFromString(dummy.getSLDData()));
    // Check fields extracted ok - should be none
    List<String> expectedFieldList = dummy.getExpectedFieldList();
    List<DataSourceAttributeData> actualFieldnameList = extract.getFields();
    assertTrue(expectedFieldList.size() == actualFieldnameList.size());
    assertEquals(0, actualFieldnameList.size());
    // Check geometry fields extracted ok
    List<String> actualGeometryFields = extract.getGeometryFields();
    assertEquals(1, actualGeometryFields.size());
    String expectedGeometryFieldName = dummy.getExpectedGeometryFieldList().get(0);
    assertTrue(expectedGeometryFieldName.compareTo(actualGeometryFields.get(0)) == 0);
}
Also used : DataSourceAttributeData(com.sldeditor.datasource.attribute.DataSourceAttributeData) ExtractAttributes(com.sldeditor.datasource.impl.ExtractAttributes) Test(org.junit.Test)

Example 38 with DataSourceAttributeData

use of com.sldeditor.datasource.attribute.DataSourceAttributeData in project sldeditor by robward-scisys.

the class ExtractAttributesTest method testMultiComparatorFilter.

@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());
}
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 39 with DataSourceAttributeData

use of com.sldeditor.datasource.attribute.DataSourceAttributeData 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 40 with DataSourceAttributeData

use of com.sldeditor.datasource.attribute.DataSourceAttributeData 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)40 Test (org.junit.Test)23 ExtractAttributes (com.sldeditor.datasource.impl.ExtractAttributes)12 ArrayList (java.util.ArrayList)11 StyledLayerDescriptor (org.geotools.styling.StyledLayerDescriptor)10 Rule (org.geotools.styling.Rule)8 Filter (org.opengis.filter.Filter)8 LineString (com.vividsolutions.jts.geom.LineString)5 SLDDataInterface (com.sldeditor.common.SLDDataInterface)4 DataSourceAttributeList (com.sldeditor.datasource.attribute.DataSourceAttributeList)4 Point (com.vividsolutions.jts.geom.Point)4 IOException (java.io.IOException)4 SimpleFeature (org.opengis.feature.simple.SimpleFeature)4 SimpleFeatureType (org.opengis.feature.simple.SimpleFeatureType)4 DataSourceImpl (com.sldeditor.datasource.impl.DataSourceImpl)3 MultiLineString (com.vividsolutions.jts.geom.MultiLineString)3 MultiPoint (com.vividsolutions.jts.geom.MultiPoint)3 AttributeDescriptor (org.opengis.feature.type.AttributeDescriptor)3 SLDData (com.sldeditor.common.data.SLDData)2 CreateDataSourceInterface (com.sldeditor.datasource.impl.CreateDataSourceInterface)2