Need to be able to detect an "Annotation" Feature.
Solution to Root problem:
Create a FeatureType (AnnotationFeatureType) that can be used as an
ancestor feature type to the Annotation features. The
AnnotationFeatureType defines an attribute (annotation_attribute_name)
that contains the name of the attribute to use to get the text that
should be displayed for the feature.
Problem with above Solution:
I can't set the attribute defined in the AnnotationFeatureType through
either the feature type create( Object ) method or the setAttribute
methods on the feature.
Vaguely thought out solution to above:
Have the DefaultFeature do some kind of searching up through the
ancestor types of the feature type.
And vague problems with the vague solution:
For the get/setAttribute methods that take an xPath argument this is
easy, if it's not found locally just start searching through the
ancestors. For the indexed versions it's trickier. For it to <b>really</b>
work right the FeatureType's getAttributeType methods should somehow
include the ancestor types.
Attached is the feature type definition I'm using right now. Below
are some code snippets that show how I'm making use of it.
// To build the feature type:
Vector superTypes = new Vector();
// if it's a text geometry feature type add annotation as a super type
superTypes.add( AnnotationFeatureType.ANNOTATION );
featureType = new DefaultFeatureType(cName, "VPF", columns,
// To build the feature:
boolean textPrimitive = pathName.endsWith(TEXT_PRIMITIVE);
int size = columns.size();
if (textPrimitive) size++;
Object values = new Object;
for (int inx = 0; inx < columns.size(); inx++)
values = "nam";
result = featureType.create(values);
// Of course this fails with a schema exception
// It should instead probably create the feature then
// manually add the extra attribute...
// Detecting and using the annotation:
if ( feature.getFeatureType().isDescendedFrom(
org.geotools.data.vpf.AnnotationFeatureType.ANNOTATION ) )
String attrName = (String)feature.getAttribute(
String annotationText = (String)feature.getAttribute( attrName );
CodeHaus Comment From: aaime - Time: Sun, 28 Nov 2010 02:57:12 -0600
Mass closing all issues that have been in "resolved" state for 2 months or more without any feedback or update