package com.ximple.eofms.util; import com.vividsolutions.jts.geom.*; import org.geotools.feature.AttributeTypeBuilder; import org.geotools.feature.simple.SimpleFeatureTypeBuilder; import org.opengis.feature.type.AttributeDescriptor; import org.opengis.feature.type.AttributeType; import org.opengis.feature.type.GeometryType; import java.util.ArrayList; public final class FeatureTypeBuilderUtil { protected static GeometryFactory _geomFactory = new GeometryFactory(); private static boolean notAllowNull = false; protected static final String DEFAULTNAMESPACE = "http://www.ximple.com.tw/tpc/"; public static boolean isNotAllowNull() { return notAllowNull; } public static void setNotAllowNull(boolean notAllowNull) { FeatureTypeBuilderUtil.notAllowNull = notAllowNull; } protected static AttributeType createAttributeType(String name, Class clazz, boolean isNillable) { AttributeTypeBuilder attrBuilder = new AttributeTypeBuilder(); attrBuilder.setName(name); attrBuilder.setBinding(clazz); attrBuilder.setNillable(isNillable); return attrBuilder.buildType(); } protected static GeometryType createGeometryType(AttributeTypeBuilder attrBuilder, String name, Class clazz, boolean isNillable) { attrBuilder.setName(name); attrBuilder.setBinding(clazz); attrBuilder.setNillable(isNillable); return attrBuilder.buildGeometryType(); } protected static GeometryType createGeometryType(AttributeTypeBuilder attrBuilder, String name, Class clazz, boolean isNillable, Object defaultValue) { attrBuilder.setName(name); attrBuilder.setBinding(clazz); attrBuilder.setNillable(isNillable); attrBuilder.setDefaultValue(defaultValue); return attrBuilder.buildGeometryType(); } protected static AttributeType createAttributeType(AttributeTypeBuilder attrBuilder, String name, Class clazz, boolean isNillable) { attrBuilder.setName(name); attrBuilder.setBinding(clazz); attrBuilder.setNillable(isNillable); return attrBuilder.buildType(); } protected static AttributeType createAttributeType(AttributeTypeBuilder attrBuilder, String name, Class clazz, boolean isNillable, Object defaultValue) { attrBuilder.setName(name); attrBuilder.setBinding(clazz); attrBuilder.setNillable(isNillable); attrBuilder.setDefaultValue(defaultValue); return attrBuilder.buildType(); } protected static AttributeType createAttributeType(AttributeTypeBuilder attrBuilder, String name, Class clazz, boolean isNillable, int len, Object defaultValue) { attrBuilder.setName(name); attrBuilder.setBinding(clazz); attrBuilder.setNillable(isNillable); attrBuilder.setLength(len); attrBuilder.setDefaultValue(defaultValue); return attrBuilder.buildType(); } public static SimpleFeatureTypeBuilder createNormalPointFeatureTypeBuilder(String featureName) { SimpleFeatureTypeBuilder typeBuilder = new SimpleFeatureTypeBuilder(); typeBuilder.setName(featureName); typeBuilder.setNamespaceURI(DEFAULTNAMESPACE); // typeBuilder.add("geom", Point.class, -1); AttributeTypeBuilder attrBuilder; ArrayList attrDescs = new ArrayList(); attrBuilder = new AttributeTypeBuilder(); attrDescs.add(attrBuilder.buildDescriptor( "geom", createGeometryType(attrBuilder, "PointType", Point.class, false))); // typeBuilder.addType(AttributeTypeFactory.newAttributeType("symcolor", String.class, notAllowNull, 12, "")); attrBuilder = new AttributeTypeBuilder(); attrDescs.add(attrBuilder.buildDescriptor( "symcolor", createAttributeType(attrBuilder, "StringType", String.class, notAllowNull, 12, ""))); // typeBuilder.addType(AttributeTypeFactory.newAttributeType("font", Short.class, notAllowNull, 1, (short) 0)); attrBuilder = new AttributeTypeBuilder(); attrDescs.add(attrBuilder.buildDescriptor( "font", createAttributeType(attrBuilder, "ShortType", Short.class, notAllowNull, 1, (short) 0))); // typeBuilder.addType(AttributeTypeFactory.newAttributeType("just", Short.class, notAllowNull, 1, (short) 0)); attrBuilder = new AttributeTypeBuilder(); attrDescs.add(attrBuilder.buildDescriptor( "just", createAttributeType(attrBuilder, "ShortType", Short.class, notAllowNull, 1, (short) 0))); // typeBuilder.addType(AttributeTypeFactory.newAttributeType("height", Float.class, notAllowNull, 1, (float) 1.0)); attrBuilder = new AttributeTypeBuilder(); attrDescs.add(attrBuilder.buildDescriptor( "height", createAttributeType(attrBuilder, "FloatType", Float.class, notAllowNull, 1, (float) 1.0))); // typeBuilder.addType(AttributeTypeFactory.newAttributeType("width", Float.class, notAllowNull, 1, (float) 1.0)); attrBuilder = new AttributeTypeBuilder(); attrDescs.add(attrBuilder.buildDescriptor( "width", createAttributeType(attrBuilder, "FloatType", Float.class, notAllowNull, 1, (float) 1.0))); // typeBuilder.addType(AttributeTypeFactory.newAttributeType("angle", Float.class, notAllowNull, 1, (float) 0.0)); attrBuilder = new AttributeTypeBuilder(); attrDescs.add(attrBuilder.buildDescriptor( "angle", createAttributeType(attrBuilder, "FloatType", Float.class, notAllowNull, 1, (float) 0.0))); // typeBuilder.addType(AttributeTypeFactory.newAttributeType("context", String.class, notAllowNull, 254, "")); attrBuilder = new AttributeTypeBuilder(); attrDescs.add(attrBuilder.buildDescriptor( "context", createAttributeType(attrBuilder, "StringType", String.class, notAllowNull, 254, ""))); typeBuilder.addAll(attrDescs); return typeBuilder; } public static SimpleFeatureTypeBuilder createNormalLineFeatureTypeBuilder(String featureName) { SimpleFeatureTypeBuilder typeBuilder = new SimpleFeatureTypeBuilder(); // .build(featureName); typeBuilder.setName(featureName); typeBuilder.setNamespaceURI(DEFAULTNAMESPACE); AttributeTypeBuilder attrBuilder; ArrayList attrDescs = new ArrayList(); // typeBuilder.addType(AttributeTypeFactory.newAttributeType("geom", LineString.class, true)); attrBuilder = new AttributeTypeBuilder(); attrDescs.add(attrBuilder.buildDescriptor( "geom", createGeometryType(attrBuilder, "LineType", LineString.class, true))); // typeBuilder.addType(AttributeTypeFactory.newAttributeType("symcolor", String.class, notAllowNull, 12, "")); attrBuilder = new AttributeTypeBuilder(); attrDescs.add(attrBuilder.buildDescriptor( "symcolor", createAttributeType(attrBuilder, "StringType", String.class, notAllowNull, 12, ""))); // typeBuilder.addType(AttributeTypeFactory.newAttributeType("symweight", Short.class, notAllowNull, 1, (short) 0)); attrBuilder = new AttributeTypeBuilder(); attrDescs.add(attrBuilder.buildDescriptor( "symweight", createAttributeType(attrBuilder, "ShortType", Short.class, notAllowNull, 1, (short) 0))); // typeBuilder.addType(AttributeTypeFactory.newAttributeType("symstyle", Short.class, notAllowNull, 1, (short) 0)); attrBuilder = new AttributeTypeBuilder(); attrDescs.add(attrBuilder.buildDescriptor( "symstyle", createAttributeType(attrBuilder, "ShortType", Short.class, notAllowNull, 1, (short) 0))); typeBuilder.addAll(attrDescs); return typeBuilder; } public static SimpleFeatureTypeBuilder createNormalMultiLineFeatureTypeBuilder(String featureName) { SimpleFeatureTypeBuilder typeBuilder = new SimpleFeatureTypeBuilder(); // .build(featureName); typeBuilder.setName(featureName); typeBuilder.setNamespaceURI(DEFAULTNAMESPACE); AttributeTypeBuilder attrBuilder; ArrayList attrDescs = new ArrayList(); // typeBuilder.addType(AttributeTypeFactory.newAttributeType("geom", MultiLineString.class, true)); attrBuilder = new AttributeTypeBuilder(); attrDescs.add(attrBuilder.buildDescriptor( "geom", createGeometryType(attrBuilder, "MultiLineStringType", MultiLineString.class, true))); // typeBuilder.addType(AttributeTypeFactory.newAttributeType("symcolor", String.class, notAllowNull, 12, "")); attrBuilder = new AttributeTypeBuilder(); attrDescs.add(attrBuilder.buildDescriptor( "symcolor", createAttributeType(attrBuilder, "StringType", String.class, notAllowNull, 12, ""))); // typeBuilder.addType(AttributeTypeFactory.newAttributeType("symweight", Short.class, notAllowNull, 1, (short) 0)); attrBuilder = new AttributeTypeBuilder(); attrDescs.add(attrBuilder.buildDescriptor( "symweight", createAttributeType(attrBuilder, "ShortType", Short.class, notAllowNull, 1, (short) 0))); // typeBuilder.addType(AttributeTypeFactory.newAttributeType("symstyle", Short.class, notAllowNull, 1, (short) 0)); attrBuilder = new AttributeTypeBuilder(); attrDescs.add(attrBuilder.buildDescriptor( "symstyle", createAttributeType(attrBuilder, "ShortType", Short.class, notAllowNull, 1, (short) 0))); typeBuilder.addAll(attrDescs); return typeBuilder; } public static SimpleFeatureTypeBuilder createNormalPolygonFeatureTypeBuilder(String featureName) { SimpleFeatureTypeBuilder typeBuilder = new SimpleFeatureTypeBuilder(); // .build(featureName); typeBuilder.setName(featureName); typeBuilder.setNamespaceURI(DEFAULTNAMESPACE); AttributeTypeBuilder attrBuilder; ArrayList attrDescs = new ArrayList(); // typeBuilder.addType(AttributeTypeFactory.newAttributeType("geom", Polygon.class, true)); attrBuilder = new AttributeTypeBuilder(); attrDescs.add(attrBuilder.buildDescriptor( "geom", createGeometryType(attrBuilder, "PolygonType", Polygon.class, true))); // typeBuilder.addType(AttributeTypeFactory.newAttributeType("symcolor", String.class, notAllowNull, 12, "")); attrBuilder = new AttributeTypeBuilder(); attrDescs.add(attrBuilder.buildDescriptor( "symcolor", createAttributeType(attrBuilder, "StringType", String.class, notAllowNull, 12, ""))); // typeBuilder.addType(AttributeTypeFactory.newAttributeType("symweight", Short.class, notAllowNull, 1, (short) 0)); attrBuilder = new AttributeTypeBuilder(); attrDescs.add(attrBuilder.buildDescriptor( "symweight", createAttributeType(attrBuilder, "ShortType", Short.class, notAllowNull, 1, (short) 0))); // typeBuilder.addType(AttributeTypeFactory.newAttributeType("symstyle", Short.class, notAllowNull, 1, (short) 0)); attrBuilder = new AttributeTypeBuilder(); attrDescs.add(attrBuilder.buildDescriptor( "symstyle", createAttributeType(attrBuilder, "ShortType", Short.class, notAllowNull, 1, (short) 0))); typeBuilder.addAll(attrDescs); return typeBuilder; } public static SimpleFeatureTypeBuilder createNormalArcFeatureTypeBuilder(String featureName) { return createNormalLineFeatureTypeBuilder(featureName); /* FeatureTypeBuilder typeBuilder = FeatureTypeBuilder.newInstance(featureName); typeBuilder.addType(AttributeTypeFactory.newAttributeType("geom", Geometry.class, false)); typeBuilder.addType(AttributeTypeFactory.newAttributeType("symcolor", String.class, notAllowNull, 12)); typeBuilder.addType(AttributeTypeFactory.newAttributeType("symweight", Short.class, false)); typeBuilder.addType(AttributeTypeFactory.newAttributeType("symstyle", Short.class, false)); return typeBuilder; */ } public static SimpleFeatureTypeBuilder createNormalEllipseFeatureTypeBuilder(String featureName) { return createNormalPolygonFeatureTypeBuilder(featureName); /* FeatureTypeBuilder typeBuilder = FeatureTypeBuilder.newInstance(featureName); typeBuilder.addType(AttributeTypeFactory.newAttributeType("geom", Geometry.class, false)); typeBuilder.addType(AttributeTypeFactory.newAttributeType("symcolor", String.class, notAllowNull, 12)); typeBuilder.addType(AttributeTypeFactory.newAttributeType("symweight", Short.class, false)); typeBuilder.addType(AttributeTypeFactory.newAttributeType("symstyle", Short.class, false)); return typeBuilder; */ } public static SimpleFeatureTypeBuilder createNormalIndexFeatureTypeBuilder(String featureName) { SimpleFeatureTypeBuilder typeBuilder = new SimpleFeatureTypeBuilder(); // .build(featureName); typeBuilder.setName(featureName); typeBuilder.setNamespaceURI(DEFAULTNAMESPACE); AttributeTypeBuilder attrBuilder; ArrayList attrDescs = new ArrayList(); // typeBuilder.addType(AttributeTypeFactory.newAttributeType("geom", Polygon.class, true)); attrBuilder = new AttributeTypeBuilder(); attrDescs.add(attrBuilder.buildDescriptor( "geom", createGeometryType(attrBuilder, "PolygonType", Polygon.class, true))); // typeBuilder.addType(AttributeTypeFactory.newAttributeType("x1", Double.class, notAllowNull, 1, 0.0)); attrBuilder = new AttributeTypeBuilder(); attrDescs.add(attrBuilder.buildDescriptor( "x1", createAttributeType(attrBuilder, "DoubleType", Double.class, notAllowNull, 1, 0.0))); // typeBuilder.addType(AttributeTypeFactory.newAttributeType("y1", Double.class, notAllowNull, 1, 0.0)); attrBuilder = new AttributeTypeBuilder(); attrDescs.add(attrBuilder.buildDescriptor( "y1", createAttributeType(attrBuilder, "DoubleType", Double.class, notAllowNull, 1, 0.0))); // typeBuilder.addType(AttributeTypeFactory.newAttributeType("x2", Double.class, notAllowNull, 1, 0.0)); attrBuilder = new AttributeTypeBuilder(); attrDescs.add(attrBuilder.buildDescriptor( "x2", createAttributeType(attrBuilder, "DoubleType", Double.class, notAllowNull, 1, 0.0))); // typeBuilder.addType(AttributeTypeFactory.newAttributeType("y2", Double.class, notAllowNull, 1, 0.0)); attrBuilder = new AttributeTypeBuilder(); attrDescs.add(attrBuilder.buildDescriptor( "y2", createAttributeType(attrBuilder, "DoubleType", Double.class, notAllowNull, 1, 0.0))); // typeBuilder.addType(AttributeTypeFactory.newAttributeType("tpclid", String.class, notAllowNull, 12, "")); attrBuilder = new AttributeTypeBuilder(); attrDescs.add(attrBuilder.buildDescriptor( "tpclid", createAttributeType(attrBuilder, "StringType", String.class, notAllowNull, 12, ""))); // typeBuilder.addType(AttributeTypeFactory.newAttributeType("symcolor", String.class, notAllowNull, 12, "")); attrBuilder = new AttributeTypeBuilder(); attrDescs.add(attrBuilder.buildDescriptor( "symcolor", createAttributeType(attrBuilder, "StringType", String.class, notAllowNull, 12, ""))); // typeBuilder.addType(AttributeTypeFactory.newAttributeType("symweight", Short.class, notAllowNull, 1, (short) 0)); attrBuilder = new AttributeTypeBuilder(); attrDescs.add(attrBuilder.buildDescriptor( "symweight", createAttributeType(attrBuilder, "ShortType", Short.class, notAllowNull, 1, (short) 0))); // typeBuilder.addType(AttributeTypeFactory.newAttributeType("symstyle", Short.class, notAllowNull, 1, (short) 0)); attrBuilder = new AttributeTypeBuilder(); attrDescs.add(attrBuilder.buildDescriptor( "symstyle", createAttributeType(attrBuilder, "ShortType", Short.class, notAllowNull, 1, (short) 0))); typeBuilder.addAll(attrDescs); return typeBuilder; } public static SimpleFeatureTypeBuilder createNormalIndexTextFeatureTypeBuilder(String featureName) { SimpleFeatureTypeBuilder typeBuilder = new SimpleFeatureTypeBuilder(); // .build(featureName); typeBuilder.setName(featureName); typeBuilder.setNamespaceURI(DEFAULTNAMESPACE); AttributeTypeBuilder attrBuilder; ArrayList attrDescs = new ArrayList(); // typeBuilder.addType(AttributeTypeFactory.newAttributeType("geom", Point.class, true)); attrBuilder = new AttributeTypeBuilder(); attrDescs.add(attrBuilder.buildDescriptor( "geom", createGeometryType(attrBuilder, "PointType", Point.class, true))); // typeBuilder.addType(AttributeTypeFactory.newAttributeType("symcolor", String.class, notAllowNull, 12, "")); attrBuilder = new AttributeTypeBuilder(); attrDescs.add(attrBuilder.buildDescriptor( "symcolor", createAttributeType(attrBuilder, "StringType", String.class, notAllowNull, 12, ""))); // typeBuilder.addType(AttributeTypeFactory.newAttributeType("symweight", Short.class, notAllowNull, 1, (short) 0)); attrBuilder = new AttributeTypeBuilder(); attrDescs.add(attrBuilder.buildDescriptor( "symweight", createAttributeType(attrBuilder, "ShortType", Short.class, notAllowNull, 1, (short) 0))); // typeBuilder.addType(AttributeTypeFactory.newAttributeType("symstyle", Short.class, notAllowNull, 1, (short) 0)); attrBuilder = new AttributeTypeBuilder(); attrDescs.add(attrBuilder.buildDescriptor( "symstyle", createAttributeType(attrBuilder, "ShortType", Short.class, notAllowNull, 1, (short) 0))); // typeBuilder.addType(AttributeTypeFactory.newAttributeType("just", Short.class, notAllowNull, 1, (short) 0)); attrBuilder = new AttributeTypeBuilder(); attrDescs.add(attrBuilder.buildDescriptor( "just", createAttributeType(attrBuilder, "ShortType", Short.class, notAllowNull, 1, (short) 0))); // typeBuilder.addType(AttributeTypeFactory.newAttributeType("height", Float.class, notAllowNull, 1, (float) 1.0)); attrBuilder = new AttributeTypeBuilder(); attrDescs.add(attrBuilder.buildDescriptor( "height", createAttributeType(attrBuilder, "FloatType", Float.class, notAllowNull, 1, (float) 1.0))); // typeBuilder.addType(AttributeTypeFactory.newAttributeType("width", Float.class, notAllowNull, 1, (float) 1.0)); attrBuilder = new AttributeTypeBuilder(); attrDescs.add(attrBuilder.buildDescriptor( "width", createAttributeType(attrBuilder, "FloatType", Float.class, notAllowNull, 1, (float) 1.0))); // typeBuilder.addType(AttributeTypeFactory.newAttributeType("angle", Float.class, notAllowNull, 1, (float) 0.0)); attrBuilder = new AttributeTypeBuilder(); attrDescs.add(attrBuilder.buildDescriptor( "angle", createAttributeType(attrBuilder, "FloatType", Float.class, notAllowNull, 1, (float) 0.0))); // typeBuilder.addType(AttributeTypeFactory.newAttributeType("tpclid", String.class, notAllowNull, 12, "")); attrBuilder = new AttributeTypeBuilder(); attrDescs.add(attrBuilder.buildDescriptor( "tpclid", createAttributeType(attrBuilder, "StringType", String.class, notAllowNull, 12, ""))); typeBuilder.addAll(attrDescs); return typeBuilder; } public static SimpleFeatureTypeBuilder createPointFeatureTypeBuilder(String featureName) { SimpleFeatureTypeBuilder typeBuilder = new SimpleFeatureTypeBuilder(); // .build(featureName); typeBuilder.setName(featureName); typeBuilder.setNamespaceURI(DEFAULTNAMESPACE); AttributeTypeBuilder attrBuilder; ArrayList attrDescs = new ArrayList(); // typeBuilder.addType(AttributeTypeFactory.newAttributeType("geom", Point.class, notAllowNull)); attrBuilder = new AttributeTypeBuilder(); attrDescs.add(attrBuilder.buildDescriptor( "geom", createGeometryType(attrBuilder, "PointType", Point.class, notAllowNull))); // typeBuilder.addType(AttributeTypeFactory.newAttributeType("tid", Short.class, notAllowNull)); attrBuilder = new AttributeTypeBuilder(); attrDescs.add(attrBuilder.buildDescriptor( "tid", createAttributeType(attrBuilder, "ShortType", Short.class, notAllowNull))); // typeBuilder.addType(AttributeTypeFactory.newAttributeType("oid", Long.class, notAllowNull)); attrBuilder = new AttributeTypeBuilder(); attrDescs.add(attrBuilder.buildDescriptor( "oid", createAttributeType(attrBuilder, "LongType", Long.class, notAllowNull))); // typeBuilder.addType(AttributeTypeFactory.newAttributeType("cid", Short.class, notAllowNull)); attrBuilder = new AttributeTypeBuilder(); attrDescs.add(attrBuilder.buildDescriptor( "cid", createAttributeType(attrBuilder, "ShortType", Short.class, notAllowNull))); // typeBuilder.addType(AttributeTypeFactory.newAttributeType("lid", Short.class, notAllowNull)); attrBuilder = new AttributeTypeBuilder(); attrDescs.add(attrBuilder.buildDescriptor( "lid", createAttributeType(attrBuilder, "ShortType", Short.class, notAllowNull))); // typeBuilder.addType(AttributeTypeFactory.newAttributeType("level", Short.class, notAllowNull)); attrBuilder = new AttributeTypeBuilder(); attrDescs.add(attrBuilder.buildDescriptor( "level", createAttributeType(attrBuilder, "ShortType", Short.class, notAllowNull))); // typeBuilder.addType(AttributeTypeFactory.newAttributeType("symcolor", String.class, notAllowNull, 12, "")); attrBuilder = new AttributeTypeBuilder(); attrDescs.add(attrBuilder.buildDescriptor( "symcolor", createAttributeType(attrBuilder, "StringType", String.class, notAllowNull, 12, ""))); // typeBuilder.addType(AttributeTypeFactory.newAttributeType("symweight", Short.class, notAllowNull, 1, (short) 0)); attrBuilder = new AttributeTypeBuilder(); attrDescs.add(attrBuilder.buildDescriptor( "symweight", createAttributeType(attrBuilder, "ShortType", Short.class, notAllowNull, 1, (short) 0))); // typeBuilder.addType(AttributeTypeFactory.newAttributeType("symstyle", Short.class, notAllowNull, 1, (short) 0)); attrBuilder = new AttributeTypeBuilder(); attrDescs.add(attrBuilder.buildDescriptor( "symstyle", createAttributeType(attrBuilder, "ShortType", Short.class, notAllowNull, 1, (short) 0))); // typeBuilder.addType(AttributeTypeFactory.newAttributeType("just", Short.class, notAllowNull)); attrBuilder = new AttributeTypeBuilder(); attrDescs.add(attrBuilder.buildDescriptor( "just", createAttributeType(attrBuilder, "ShortType", Short.class, notAllowNull, 1, (short) 0))); // typeBuilder.addType(AttributeTypeFactory.newAttributeType("height", Float.class, notAllowNull, 1, (float) 1.0)); attrBuilder = new AttributeTypeBuilder(); attrDescs.add(attrBuilder.buildDescriptor( "height", createAttributeType(attrBuilder, "FloatType", Float.class, notAllowNull, 1, (float) 1.0))); // typeBuilder.addType(AttributeTypeFactory.newAttributeType("width", Float.class, notAllowNull, 1, (float) 1.0)); attrBuilder = new AttributeTypeBuilder(); attrDescs.add(attrBuilder.buildDescriptor( "width", createAttributeType(attrBuilder, "FloatType", Float.class, notAllowNull, 1, (float) 1.0))); // typeBuilder.addType(AttributeTypeFactory.newAttributeType("angle", Float.class, notAllowNull, 1, (float) 0.0)); attrBuilder = new AttributeTypeBuilder(); attrDescs.add(attrBuilder.buildDescriptor( "angle", createAttributeType(attrBuilder, "FloatType", Float.class, notAllowNull, 1, (float) 0.0))); // typeBuilder.addType(AttributeTypeFactory.newAttributeType("context", String.class, true, 254)); attrBuilder = new AttributeTypeBuilder(); attrDescs.add(attrBuilder.buildDescriptor( "context", createAttributeType(attrBuilder, "StringType", String.class, true, 254))); typeBuilder.addAll(attrDescs); return typeBuilder; } public static SimpleFeatureTypeBuilder createSymbolFeatureTypeBuilder(String featureName) { SimpleFeatureTypeBuilder typeBuilder = new SimpleFeatureTypeBuilder(); // .build(featureName); typeBuilder.setName(featureName); typeBuilder.setNamespaceURI(DEFAULTNAMESPACE); AttributeTypeBuilder attrBuilder; ArrayList attrDescs = new ArrayList(); // typeBuilder.addType(AttributeTypeFactory.newAttributeType("geom", Point.class, notAllowNull)); attrBuilder = new AttributeTypeBuilder(); attrDescs.add(attrBuilder.buildDescriptor( "geom", createGeometryType(attrBuilder, "PointType", Point.class, notAllowNull))); // typeBuilder.addType(AttributeTypeFactory.newAttributeType("tid", Short.class, notAllowNull)); attrBuilder = new AttributeTypeBuilder(); attrDescs.add(attrBuilder.buildDescriptor( "tid", createAttributeType(attrBuilder, "ShortType", Short.class, notAllowNull))); // typeBuilder.addType(AttributeTypeFactory.newAttributeType("oid", Long.class, notAllowNull)); attrBuilder = new AttributeTypeBuilder(); attrDescs.add(attrBuilder.buildDescriptor( "oid", createAttributeType(attrBuilder, "LongType", Long.class, notAllowNull))); // typeBuilder.addType(AttributeTypeFactory.newAttributeType("cid", Short.class, notAllowNull)); attrBuilder = new AttributeTypeBuilder(); attrDescs.add(attrBuilder.buildDescriptor( "cid", createAttributeType(attrBuilder, "ShortType", Short.class, notAllowNull))); // typeBuilder.addType(AttributeTypeFactory.newAttributeType("lid", Short.class, notAllowNull)); attrBuilder = new AttributeTypeBuilder(); attrDescs.add(attrBuilder.buildDescriptor( "lid", createAttributeType(attrBuilder, "ShortType", Short.class, notAllowNull))); // typeBuilder.addType(AttributeTypeFactory.newAttributeType("level", Short.class, notAllowNull)); attrBuilder = new AttributeTypeBuilder(); attrDescs.add(attrBuilder.buildDescriptor( "level", createAttributeType(attrBuilder, "ShortType", Short.class, notAllowNull))); // typeBuilder.addType(AttributeTypeFactory.newAttributeType("symcolor", String.class, notAllowNull, 12, "")); attrBuilder = new AttributeTypeBuilder(); attrDescs.add(attrBuilder.buildDescriptor( "symcolor", createAttributeType(attrBuilder, "StringType", String.class, notAllowNull, 12, ""))); // typeBuilder.addType(AttributeTypeFactory.newAttributeType("symweight", Short.class, notAllowNull, 1, (short) 0)); attrBuilder = new AttributeTypeBuilder(); attrDescs.add(attrBuilder.buildDescriptor( "symweight", createAttributeType(attrBuilder, "ShortType", Short.class, notAllowNull, 1, (short) 0))); // typeBuilder.addType(AttributeTypeFactory.newAttributeType("symstyle", Short.class, notAllowNull, 1, (short) 0)); attrBuilder = new AttributeTypeBuilder(); attrDescs.add(attrBuilder.buildDescriptor( "symstyle", createAttributeType(attrBuilder, "ShortType", Short.class, notAllowNull, 1, (short) 0))); // typeBuilder.addType(AttributeTypeFactory.newAttributeType("just", Short.class, notAllowNull)); attrBuilder = new AttributeTypeBuilder(); attrDescs.add(attrBuilder.buildDescriptor( "just", createAttributeType(attrBuilder, "ShortType", Short.class, notAllowNull, 1, (short) 0))); // typeBuilder.addType(AttributeTypeFactory.newAttributeType("height", Float.class, notAllowNull, 1, (float) 1.0)); attrBuilder = new AttributeTypeBuilder(); attrDescs.add(attrBuilder.buildDescriptor( "height", createAttributeType(attrBuilder, "FloatType", Float.class, notAllowNull, 1, (float) 1.0))); // typeBuilder.addType(AttributeTypeFactory.newAttributeType("width", Float.class, notAllowNull, 1, (float) 1.0)); attrBuilder = new AttributeTypeBuilder(); attrDescs.add(attrBuilder.buildDescriptor( "width", createAttributeType(attrBuilder, "FloatType", Float.class, notAllowNull, 1, (float) 1.0))); // typeBuilder.addType(AttributeTypeFactory.newAttributeType("angle", Float.class, notAllowNull, 1, (float) 0.0)); attrBuilder = new AttributeTypeBuilder(); attrDescs.add(attrBuilder.buildDescriptor( "angle", createAttributeType(attrBuilder, "FloatType", Float.class, notAllowNull, 1, (float) 0.0))); // typeBuilder.addType(AttributeTypeFactory.newAttributeType("symbol", String.class, notAllowNull, 20)); attrBuilder = new AttributeTypeBuilder(); attrDescs.add(attrBuilder.buildDescriptor( "symbol", createAttributeType(attrBuilder, "StringType", String.class, notAllowNull, 20))); typeBuilder.addAll(attrDescs); return typeBuilder; } public static SimpleFeatureTypeBuilder createPolygonFeatureTypeBuilder(String featureName) { SimpleFeatureTypeBuilder typeBuilder = new SimpleFeatureTypeBuilder(); // .build(featureName); typeBuilder.setName(featureName); typeBuilder.setNamespaceURI(DEFAULTNAMESPACE); AttributeTypeBuilder attrBuilder; ArrayList attrDescs = new ArrayList(); // typeBuilder.addType(AttributeTypeFactory.newAttributeType("geom", Polygon.class, notAllowNull)); attrBuilder = new AttributeTypeBuilder(); attrDescs.add(attrBuilder.buildDescriptor( "geom", createGeometryType(attrBuilder, "PolygonType", Polygon.class, notAllowNull))); // typeBuilder.addType(AttributeTypeFactory.newAttributeType("tid", Short.class, notAllowNull)); attrBuilder = new AttributeTypeBuilder(); attrDescs.add(attrBuilder.buildDescriptor( "tid", createAttributeType(attrBuilder, "ShortType", Short.class, notAllowNull))); // typeBuilder.addType(AttributeTypeFactory.newAttributeType("oid", Long.class, notAllowNull)); attrBuilder = new AttributeTypeBuilder(); attrDescs.add(attrBuilder.buildDescriptor( "oid", createAttributeType(attrBuilder, "LongType", Long.class, notAllowNull))); // typeBuilder.addType(AttributeTypeFactory.newAttributeType("cid", Short.class, notAllowNull)); attrBuilder = new AttributeTypeBuilder(); attrDescs.add(attrBuilder.buildDescriptor( "cid", createAttributeType(attrBuilder, "ShortType", Short.class, notAllowNull))); // typeBuilder.addType(AttributeTypeFactory.newAttributeType("lid", Short.class, notAllowNull)); attrBuilder = new AttributeTypeBuilder(); attrDescs.add(attrBuilder.buildDescriptor( "lid", createAttributeType(attrBuilder, "ShortType", Short.class, notAllowNull))); // typeBuilder.addType(AttributeTypeFactory.newAttributeType("level", Short.class, notAllowNull)); attrBuilder = new AttributeTypeBuilder(); attrDescs.add(attrBuilder.buildDescriptor( "level", createAttributeType(attrBuilder, "ShortType", Short.class, notAllowNull))); // typeBuilder.addType(AttributeTypeFactory.newAttributeType("symcolor", String.class, notAllowNull, 12, "")); attrBuilder = new AttributeTypeBuilder(); attrDescs.add(attrBuilder.buildDescriptor( "symcolor", createAttributeType(attrBuilder, "StringType", String.class, notAllowNull, 12, ""))); // typeBuilder.addType(AttributeTypeFactory.newAttributeType("symweight", Short.class, notAllowNull, 1, (short) 0)); attrBuilder = new AttributeTypeBuilder(); attrDescs.add(attrBuilder.buildDescriptor( "symweight", createAttributeType(attrBuilder, "ShortType", Short.class, notAllowNull, 1, (short) 0))); // typeBuilder.addType(AttributeTypeFactory.newAttributeType("symstyle", Short.class, notAllowNull, 1, (short) 0)); attrBuilder = new AttributeTypeBuilder(); attrDescs.add(attrBuilder.buildDescriptor( "symstyle", createAttributeType(attrBuilder, "ShortType", Short.class, notAllowNull, 1, (short) 0))); typeBuilder.addAll(attrDescs); return typeBuilder; } public static SimpleFeatureTypeBuilder createLineFeatureTypeBuilder(String featureName) { SimpleFeatureTypeBuilder typeBuilder = new SimpleFeatureTypeBuilder(); // .build(featureName); typeBuilder.setName(featureName); typeBuilder.setNamespaceURI(DEFAULTNAMESPACE); AttributeTypeBuilder attrBuilder; ArrayList attrDescs = new ArrayList(); // typeBuilder.addType(AttributeTypeFactory.newAttributeType("geom", LineString.class, notAllowNull)); attrBuilder = new AttributeTypeBuilder(); attrDescs.add(attrBuilder.buildDescriptor( "geom", createGeometryType(attrBuilder, "LineStringType", LineString.class, notAllowNull))); // typeBuilder.addType(AttributeTypeFactory.newAttributeType("tid", Short.class, notAllowNull)); attrBuilder = new AttributeTypeBuilder(); attrDescs.add(attrBuilder.buildDescriptor( "tid", createAttributeType(attrBuilder, "ShortType", Short.class, notAllowNull))); // typeBuilder.addType(AttributeTypeFactory.newAttributeType("oid", Long.class, notAllowNull)); attrBuilder = new AttributeTypeBuilder(); attrDescs.add(attrBuilder.buildDescriptor( "oid", createAttributeType(attrBuilder, "LongType", Long.class, notAllowNull))); // typeBuilder.addType(AttributeTypeFactory.newAttributeType("cid", Short.class, notAllowNull)); attrBuilder = new AttributeTypeBuilder(); attrDescs.add(attrBuilder.buildDescriptor( "cid", createAttributeType(attrBuilder, "ShortType", Short.class, notAllowNull))); // typeBuilder.addType(AttributeTypeFactory.newAttributeType("lid", Short.class, notAllowNull)); attrBuilder = new AttributeTypeBuilder(); attrDescs.add(attrBuilder.buildDescriptor( "lid", createAttributeType(attrBuilder, "ShortType", Short.class, notAllowNull))); // typeBuilder.addType(AttributeTypeFactory.newAttributeType("level", Short.class, notAllowNull)); attrBuilder = new AttributeTypeBuilder(); attrDescs.add(attrBuilder.buildDescriptor( "level", createAttributeType(attrBuilder, "ShortType", Short.class, notAllowNull))); // typeBuilder.addType(AttributeTypeFactory.newAttributeType("symcolor", String.class, notAllowNull, 12, "")); attrBuilder = new AttributeTypeBuilder(); attrDescs.add(attrBuilder.buildDescriptor( "symcolor", createAttributeType(attrBuilder, "StringType", String.class, notAllowNull, 12, ""))); // typeBuilder.addType(AttributeTypeFactory.newAttributeType("symweight", Short.class, notAllowNull, 1, (short) 0)); attrBuilder = new AttributeTypeBuilder(); attrDescs.add(attrBuilder.buildDescriptor( "symweight", createAttributeType(attrBuilder, "ShortType", Short.class, notAllowNull, 1, (short) 0))); // typeBuilder.addType(AttributeTypeFactory.newAttributeType("symstyle", Short.class, notAllowNull, 1, (short) 0)); attrBuilder = new AttributeTypeBuilder(); attrDescs.add(attrBuilder.buildDescriptor( "symstyle", createAttributeType(attrBuilder, "ShortType", Short.class, notAllowNull, 1, (short) 0))); typeBuilder.addAll(attrDescs); return typeBuilder; } public static SimpleFeatureTypeBuilder createMultiLineFeatureTypeBuilder(String featureName) { SimpleFeatureTypeBuilder typeBuilder = new SimpleFeatureTypeBuilder(); // .build(featureName); typeBuilder.setName(featureName); typeBuilder.setNamespaceURI(DEFAULTNAMESPACE); AttributeTypeBuilder attrBuilder; ArrayList attrDescs = new ArrayList(); // typeBuilder.addType(AttributeTypeFactory.newAttributeType("geom", MultiLineString.class, notAllowNull)); attrBuilder = new AttributeTypeBuilder(); attrDescs.add(attrBuilder.buildDescriptor( "geom", createGeometryType(attrBuilder, "MultiLineStringType", MultiLineString.class, notAllowNull))); // typeBuilder.addType(AttributeTypeFactory.newAttributeType("tid", Short.class, notAllowNull)); attrBuilder = new AttributeTypeBuilder(); attrDescs.add(attrBuilder.buildDescriptor( "tid", createAttributeType(attrBuilder, "ShortType", Short.class, notAllowNull))); // typeBuilder.addType(AttributeTypeFactory.newAttributeType("oid", Long.class, notAllowNull)); attrBuilder = new AttributeTypeBuilder(); attrDescs.add(attrBuilder.buildDescriptor( "oid", createAttributeType(attrBuilder, "LongType", Long.class, notAllowNull))); // typeBuilder.addType(AttributeTypeFactory.newAttributeType("cid", Short.class, notAllowNull)); attrBuilder = new AttributeTypeBuilder(); attrDescs.add(attrBuilder.buildDescriptor( "cid", createAttributeType(attrBuilder, "ShortType", Short.class, notAllowNull))); // typeBuilder.addType(AttributeTypeFactory.newAttributeType("lid", Short.class, notAllowNull)); attrBuilder = new AttributeTypeBuilder(); attrDescs.add(attrBuilder.buildDescriptor( "lid", createAttributeType(attrBuilder, "ShortType", Short.class, notAllowNull))); // typeBuilder.addType(AttributeTypeFactory.newAttributeType("level", Short.class, notAllowNull)); attrBuilder = new AttributeTypeBuilder(); attrDescs.add(attrBuilder.buildDescriptor( "level", createAttributeType(attrBuilder, "ShortType", Short.class, notAllowNull))); // typeBuilder.addType(AttributeTypeFactory.newAttributeType("symcolor", String.class, notAllowNull, 12, "")); attrBuilder = new AttributeTypeBuilder(); attrDescs.add(attrBuilder.buildDescriptor( "symcolor", createAttributeType(attrBuilder, "StringType", String.class, notAllowNull, 12, ""))); // typeBuilder.addType(AttributeTypeFactory.newAttributeType("symweight", Short.class, notAllowNull, 1, (short) 0)); attrBuilder = new AttributeTypeBuilder(); attrDescs.add(attrBuilder.buildDescriptor( "symweight", createAttributeType(attrBuilder, "ShortType", Short.class, notAllowNull, 1, (short) 0))); // typeBuilder.addType(AttributeTypeFactory.newAttributeType("symstyle", Short.class, notAllowNull, 1, (short) 0)); attrBuilder = new AttributeTypeBuilder(); attrDescs.add(attrBuilder.buildDescriptor( "symstyle", createAttributeType(attrBuilder, "ShortType", Short.class, notAllowNull, 1, (short) 0))); typeBuilder.addAll(attrDescs); return typeBuilder; } public static SimpleFeatureTypeBuilder createEllipseFeatureTypeBuilder(String featureName) { return createPolygonFeatureTypeBuilder(featureName); /* FeatureTypeBuilder typeBuilder = FeatureTypeBuilder.newInstance(featureName); typeBuilder.addType(AttributeTypeFactory.newAttributeType("geom", Geometry.class, notAllowNull)); typeBuilder.addType(AttributeTypeFactory.newAttributeType("tid", Short.class, notAllowNull)); typeBuilder.addType(AttributeTypeFactory.newAttributeType("oid", Long.class)); typeBuilder.addType(AttributeTypeFactory.newAttributeType("cid", Short.class, notAllowNull)); typeBuilder.addType(AttributeTypeFactory.newAttributeType("lid", Short.class, notAllowNull)); typeBuilder.addType(AttributeTypeFactory.newAttributeType("level", Short.class, notAllowNull)); typeBuilder.addType(AttributeTypeFactory.newAttributeType("symcolor", String.class, notAllowNull, 12)); typeBuilder.addType(AttributeTypeFactory.newAttributeType("symweight", Short.class, notAllowNull)); typeBuilder.addType(AttributeTypeFactory.newAttributeType("symstyle", Short.class, notAllowNull)); return typeBuilder; */ } public static SimpleFeatureTypeBuilder createArcFeatureTypeBuilder(String featureName) { return createLineFeatureTypeBuilder(featureName); /* FeatureTypeBuilder typeBuilder = FeatureTypeBuilder.newInstance(featureName); typeBuilder.addType(AttributeTypeFactory.newAttributeType("geom", Geometry.class, notAllowNull)); typeBuilder.addType(AttributeTypeFactory.newAttributeType("tid", Short.class, notAllowNull)); typeBuilder.addType(AttributeTypeFactory.newAttributeType("oid", Long.class)); typeBuilder.addType(AttributeTypeFactory.newAttributeType("cid", Short.class, notAllowNull)); typeBuilder.addType(AttributeTypeFactory.newAttributeType("lid", Short.class, notAllowNull)); typeBuilder.addType(AttributeTypeFactory.newAttributeType("level", Short.class, notAllowNull)); typeBuilder.addType(AttributeTypeFactory.newAttributeType("symcolor", String.class, notAllowNull, 12)); typeBuilder.addType(AttributeTypeFactory.newAttributeType("symweight", Short.class, notAllowNull)); typeBuilder.addType(AttributeTypeFactory.newAttributeType("symstyle", Short.class, notAllowNull)); return typeBuilder; */ } public static SimpleFeatureTypeBuilder createMultiSymbolFeatureTypeBuilder(String featureName) { SimpleFeatureTypeBuilder typeBuilder = new SimpleFeatureTypeBuilder(); // .build(featureName); typeBuilder.setName(featureName); typeBuilder.setNamespaceURI(DEFAULTNAMESPACE); AttributeTypeBuilder attrBuilder; ArrayList attrDescs = new ArrayList(); // typeBuilder.addType(AttributeTypeFactory.newAttributeType("geom", MultiPoint.class, notAllowNull)); attrBuilder = new AttributeTypeBuilder(); attrDescs.add(attrBuilder.buildDescriptor( "geom", createGeometryType(attrBuilder, "MultiPointType", MultiPoint.class, notAllowNull))); // typeBuilder.addType(AttributeTypeFactory.newAttributeType("tid", Short.class, notAllowNull)); attrBuilder = new AttributeTypeBuilder(); attrDescs.add(attrBuilder.buildDescriptor( "tid", createAttributeType(attrBuilder, "ShortType", Short.class, notAllowNull))); // typeBuilder.addType(AttributeTypeFactory.newAttributeType("oid", Long.class, notAllowNull)); attrBuilder = new AttributeTypeBuilder(); attrDescs.add(attrBuilder.buildDescriptor( "oid", createAttributeType(attrBuilder, "LongType", Long.class, notAllowNull))); // typeBuilder.addType(AttributeTypeFactory.newAttributeType("cid", Short.class, notAllowNull)); attrBuilder = new AttributeTypeBuilder(); attrDescs.add(attrBuilder.buildDescriptor( "cid", createAttributeType(attrBuilder, "ShortType", Short.class, notAllowNull))); // typeBuilder.addType(AttributeTypeFactory.newAttributeType("lid", Short.class, notAllowNull)); attrBuilder = new AttributeTypeBuilder(); attrDescs.add(attrBuilder.buildDescriptor( "lid", createAttributeType(attrBuilder, "ShortType", Short.class, notAllowNull))); // typeBuilder.addType(AttributeTypeFactory.newAttributeType("level", Short.class, notAllowNull)); attrBuilder = new AttributeTypeBuilder(); attrDescs.add(attrBuilder.buildDescriptor( "level", createAttributeType(attrBuilder, "ShortType", Short.class, notAllowNull))); // typeBuilder.addType(AttributeTypeFactory.newAttributeType("symcolor", String.class, notAllowNull, 12, "")); attrBuilder = new AttributeTypeBuilder(); attrDescs.add(attrBuilder.buildDescriptor( "symcolor", createAttributeType(attrBuilder, "StringType", String.class, notAllowNull, 12, ""))); // typeBuilder.addType(AttributeTypeFactory.newAttributeType("symweight", Short.class, notAllowNull, 1, (short) 0)); attrBuilder = new AttributeTypeBuilder(); attrDescs.add(attrBuilder.buildDescriptor( "symweight", createAttributeType(attrBuilder, "ShortType", Short.class, notAllowNull, 1, (short) 0))); // typeBuilder.addType(AttributeTypeFactory.newAttributeType("symstyle", Short.class, notAllowNull, 1, (short) 0)); attrBuilder = new AttributeTypeBuilder(); attrDescs.add(attrBuilder.buildDescriptor( "symstyle", createAttributeType(attrBuilder, "ShortType", Short.class, notAllowNull, 1, (short) 0))); // typeBuilder.addType(AttributeTypeFactory.newAttributeType("just", Short.class, notAllowNull)); attrBuilder = new AttributeTypeBuilder(); attrDescs.add(attrBuilder.buildDescriptor( "just", createAttributeType(attrBuilder, "ShortType", Short.class, notAllowNull, 1, (short) 0))); // typeBuilder.addType(AttributeTypeFactory.newAttributeType("height", Float.class, notAllowNull, 1, (float) 1.0)); attrBuilder = new AttributeTypeBuilder(); attrDescs.add(attrBuilder.buildDescriptor( "height", createAttributeType(attrBuilder, "FloatType", Float.class, notAllowNull, 1, (float) 1.0))); // typeBuilder.addType(AttributeTypeFactory.newAttributeType("width", Float.class, notAllowNull, 1, (float) 1.0)); attrBuilder = new AttributeTypeBuilder(); attrDescs.add(attrBuilder.buildDescriptor( "width", createAttributeType(attrBuilder, "FloatType", Float.class, notAllowNull, 1, (float) 1.0))); // typeBuilder.addType(AttributeTypeFactory.newAttributeType("angle", Float.class, notAllowNull, 1, (float) 0.0)); attrBuilder = new AttributeTypeBuilder(); attrDescs.add(attrBuilder.buildDescriptor( "angle", createAttributeType(attrBuilder, "FloatType", Float.class, notAllowNull, 1, (float) 0.0))); // typeBuilder.addType(AttributeTypeFactory.newAttributeType("symbol", String.class, notAllowNull, 20)); attrBuilder = new AttributeTypeBuilder(); attrDescs.add(attrBuilder.buildDescriptor( "symbol", createAttributeType(attrBuilder, "StringType", String.class, notAllowNull, 20))); typeBuilder.addAll(attrDescs); return typeBuilder; } }