This example...
| Code Block |
|---|
LOGGER.finer("creating flat feature...");
AttributeType geometryAttribute = AttributeTypeFactory.newAttributeType("testGeometry",
LineString.class);
LOGGER.finer("created geometry attribute");
AttributeType booleanAttribute = AttributeTypeFactory.newAttributeType("testBoolean",
Boolean.class);
AttributeType charAttribute = AttributeTypeFactory.newAttributeType("testCharacter",
Character.class);
AttributeType byteAttribute = AttributeTypeFactory.newAttributeType("testByte",
Byte.class);
AttributeType shortAttribute = AttributeTypeFactory.newAttributeType("testShort",
Short.class);
AttributeType intAttribute = AttributeTypeFactory.newAttributeType("testInteger",
Integer.class);
AttributeType longAttribute = AttributeTypeFactory.newAttributeType("testLong",
Long.class);
AttributeType floatAttribute = AttributeTypeFactory.newAttributeType("testFloat",
Float.class);
AttributeType doubleAttribute = AttributeTypeFactory.newAttributeType("testDouble",
Double.class);
AttributeType stringAttribute = AttributeTypeFactory.newAttributeType("testString",
String.class);
AttributeType[] types = {
geometryAttribute, booleanAttribute, charAttribute,
byteAttribute, shortAttribute, intAttribute, longAttribute,
floatAttribute, doubleAttribute, stringAttribute
};
// Builds the schema
testSchema = FeatureTypeFactory.newFeatureType(types, "testSchema");
GeometryFactory geomFac = new GeometryFactory();
// Creates coordinates for the linestring
Coordinate[] coords = new Coordinate[3];
coords[0] = new Coordinate(1, 2);
coords[1] = new Coordinate(3, 4);
coords[2] = new Coordinate(5, 6);
// Builds the test feature
Object[] attributes = new Object[10];
attributes[0] = geomFac.createLineString(coords);
attributes[1] = new Boolean(true);
attributes[2] = new Character('t');
attributes[3] = new Byte("10");
attributes[4] = new Short("101");
attributes[5] = new Integer(1002);
attributes[6] = new Long(10003);
attributes[7] = new Float(10000.4);
attributes[8] = new Double(100000.5);
attributes[9] = "test string data";
// Creates the feature itself
testFeature = testSchema.create(attributes);
LOGGER.finer("...flat feature created");
|