[udig-devel] creating a feature with default values

andrea antonello andrea.antonello at gmail.com
Fri May 2 09:23:42 PDT 2008


> > Hi, I am trying to create a feature for an empty layer. The feature
> > should be created with all default values in it.
> >
> >
>  That is a little bit tough; sometimes a value is required (like say a
> geometry) and no sensible default can be provided.
>
>
> > What I thought I should do, is first to get the featuretype from the
> > layer and with that create a new feature, but I seem to be wrong.
> > The only way I found in that case is bound to the existence of an
> > existing feature.
> >
> > How can I achieve that?
> >
> >
>  Your approach sounded okay. What exactly about it was wrong?

I think I am yet trying to understand what exactly is inside the
attributetype object. I tried to do something like:

                AttributeType[] attributeTypes =
newFeatureType.getAttributeTypes();
                Object[] attributes = new Object[attributeTypes.length];
                for( int i = 0; i < attributeTypes.length; i++ ) {
                    AttributeType attributeType = attributeTypes[i];
                    if (attributeType instanceof GeometryAttributeType) {
                        attributes[i] = somegeometry;
                    }else{
                        attributes[i] = attributeType.createDefaultValue();
                    }
                }
                featureToUse = featureType.create(attributes);

Should this work?

Thanks,
Andrea



>  Jody
>  _______________________________________________
>  User-friendly Desktop Internet GIS (uDig)
>  http://udig.refractions.net
>  http://lists.refractions.net/mailman/listinfo/udig-devel
>


More information about the udig-devel mailing list