Search in sources :

Example 1 with ExampleLineInterface

use of com.sldeditor.datasource.example.ExampleLineInterface in project sldeditor by robward-scisys.

the class CreateSampleData method createAttributes.

/**
 * Creates the attributes.
 *
 * @param fieldList the field list
 * @param fieldMap the field map
 * @param featureType the feature type
 * @param builder the builder
 * @param feature the feature
 */
private void createAttributes(List<DataSourceAttributeData> fieldList, Map<String, DataSourceAttributeData> fieldMap, SimpleFeatureType featureType, SimpleFeatureBuilder builder, SimpleFeature feature) {
    builder.init((SimpleFeature) feature);
    int index = 0;
    for (AttributeDescriptor descriptor : featureType.getAttributeDescriptors()) {
        AttributeType attributeType = descriptor.getType();
        Object value = null;
        Class<?> fieldType = attributeType.getBinding();
        if (attributeType instanceof GeometryTypeImpl) {
            geometryType = GeometryTypeMapping.getGeometryType(fieldType);
            switch(geometryType) {
                case POLYGON:
                    ExamplePolygonInterface examplePolygon = DataSourceFactory.createExamplePolygon(null);
                    value = examplePolygon.getPolygon();
                    break;
                case LINE:
                    ExampleLineInterface exampleLine = DataSourceFactory.createExampleLine(null);
                    value = exampleLine.getLine();
                    break;
                case POINT:
                default:
                    ExamplePointInterface examplePoint = DataSourceFactory.createExamplePoint(null);
                    value = examplePoint.getPoint();
                    break;
            }
        } else {
            if ((fieldList != null) && (index < fieldList.size())) {
                DataSourceAttributeData attrData = fieldMap.get(descriptor.getLocalName());
                if (attrData != null) {
                    value = attrData.getValue();
                }
            }
            value = getFieldTypeValue(index, attributeType.getName().getLocalPart(), fieldType, value);
        }
        builder.add(value);
        index++;
    }
}
Also used : DataSourceAttributeData(com.sldeditor.datasource.attribute.DataSourceAttributeData) AttributeType(org.opengis.feature.type.AttributeType) AttributeDescriptor(org.opengis.feature.type.AttributeDescriptor) ExampleLineInterface(com.sldeditor.datasource.example.ExampleLineInterface) ExamplePointInterface(com.sldeditor.datasource.example.ExamplePointInterface) GeometryTypeImpl(org.geotools.feature.type.GeometryTypeImpl) ExamplePolygonInterface(com.sldeditor.datasource.example.ExamplePolygonInterface)

Example 2 with ExampleLineInterface

use of com.sldeditor.datasource.example.ExampleLineInterface in project sldeditor by robward-scisys.

the class DataSourceFactoryTest method testCreateExampleLine.

/**
 * Test method for {@link
 * com.sldeditor.datasource.impl.DataSourceFactory#createExampleLine(java.lang.Object)}.
 */
@Test
public void testCreateExampleLine() {
    ExampleLineInterface exampleLine = DataSourceFactory.createExampleLine(null);
    assertEquals(ExampleLineImpl.class, exampleLine.getClass());
}
Also used : ExampleLineInterface(com.sldeditor.datasource.example.ExampleLineInterface) Test(org.junit.jupiter.api.Test)

Aggregations

ExampleLineInterface (com.sldeditor.datasource.example.ExampleLineInterface)2 DataSourceAttributeData (com.sldeditor.datasource.attribute.DataSourceAttributeData)1 ExamplePointInterface (com.sldeditor.datasource.example.ExamplePointInterface)1 ExamplePolygonInterface (com.sldeditor.datasource.example.ExamplePolygonInterface)1 GeometryTypeImpl (org.geotools.feature.type.GeometryTypeImpl)1 Test (org.junit.jupiter.api.Test)1 AttributeDescriptor (org.opengis.feature.type.AttributeDescriptor)1 AttributeType (org.opengis.feature.type.AttributeType)1