[udig-devel] creating a feature with default values
Harry Bullen
hbullen at gmail.com
Fri May 2 10:27:28 PDT 2008
Yea I just did this exact same thing and your code look almost
identical to mine. So think you are on the right track.
On Fri, May 2, 2008 at 12:23 PM, andrea antonello
<andrea.antonello at gmail.com> wrote:
> > > 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
> >
> _______________________________________________
> User-friendly Desktop Internet GIS (uDig)
> http://udig.refractions.net
> http://lists.refractions.net/mailman/listinfo/udig-devel
>
--
Harry William Bullen IV
More information about the udig-devel
mailing list