CSVSpecifiedWKTStrategy extends CSVStrategy { @Override protected SimpleFeatureType buildFeatureType() { SimpleFeatureTypeBuilder featureBuilder = CSVStrategy.createBuilder(csvFileState); AttributeDescriptor descriptor = featureBuilder.get(wktField); if( descriptor != null ){ AttributeTypeBuilder attributeBuilder = new AttributeTypeBuilder(); attributeBuilder.init(descriptor); attributeBuilder.setCRS(DefaultGeographicCRS.WGS84); attributeBuilder.binding(Geometry.class); AttributeDescriptor modified = attributeBuilder.buildDescriptor(wktField); featureBuilder.set(wktField,modified ); } return featureBuilder.buildFeatureType(); } CSVSpecifiedWKTStrategy(CSVFileState csvFileState, String wktField); @Override void createSchema(SimpleFeatureType featureType); @Override String[] encode(SimpleFeature feature); @Override SimpleFeature decode(String recordId, String[] csvRecord);  }
@Test public void testBuildFeatureType() { String input = CSVTestStrategySupport.buildInputString("quux,morx\n"); CSVFileState fileState = new CSVFileState(input, "foo"); CSVStrategy strategy = new CSVSpecifiedWKTStrategy(fileState, "quux"); SimpleFeatureType featureType = strategy.getFeatureType(); assertEquals("Invalid attribute count", 2, featureType.getAttributeCount()); GeometryDescriptor geometryDescriptor = featureType.getGeometryDescriptor(); assertEquals("Invalid geometry attribute name", "quux", geometryDescriptor.getLocalName()); }