[udig-devel] adding and modifying a new feature

andrea antonello andrea.antonello at gmail.com
Tue May 6 07:26:59 PDT 2008


> > I think by keeping the reference to the feature that is first added, I
> > achieve the same as the getNewFeature method. Right?
>
>  Nope it is not the same thing.  Because the method actually creates a
> request to the datastore and obtains the new feature that has the new id.
> Your feature has a fid that is obsolete.

Ok, that makes sense.
But doing:

                UndoableMapCommand createAddFeatureCommand = EditCommandFactory
                        .getInstance().createAddFeatureCommand(feature, layer);
                map.sendCommandASync(createAddFeatureCommand);
                // and put it inside the map
                Feature newFeatureAdded = ((AddFeatureCommand)
createAddFeatureCommand)
                        .getNewFeature();

I get a:

java.lang.NullPointerException
	at org.geotools.data.shapefile.indexed.IndexedFidReader.findFid(IndexedFidReader.java:132)
	at org.geotools.data.shapefile.indexed.IndexedShapefileDataStore.queryFidIndex(IndexedShapefileDataStore.java:562)
	at org.geotools.data.shapefile.indexed.IndexedShapefileDataStore.getAttributesReader(IndexedShapefileDataStore.java:465)
	at org.geotools.data.shapefile.indexed.IndexedShapefileDataStore.getFeatureReader(IndexedShapefileDataStore.java:405)
	at org.geotools.data.AbstractDataStore.getFeatureReader(AbstractDataStore.java:366)
	at org.geotools.data.DefaultFeatureResults.reader(DefaultFeatureResults.java:147)
	at org.geotools.data.store.DataFeatureCollection.openIterator(DataFeatureCollection.java:225)
	at org.geotools.data.store.DataFeatureCollection.iterator(DataFeatureCollection.java:201)
	at org.geotools.data.store.DataFeatureCollection.features(DataFeatureCollection.java:192)
	at net.refractions.udig.project.internal.commands.edit.AddFeatureCommand.getNewFeature(Unknown
Source)


> > My problem is that the added features are not visible, also if I do a
> > redraw, they do not appear, even if they are present in the table
> >
>
>  Does the feature that you first add have a full geometry.  IE isn't a
> singularity?

I create a full geometry, but I don't know what you mean by singularity.

> > Is this somehow related to the features sometimes not appearing while
> editing?
> >
>
>  entirely possible...  What datastore are you using for the editing?

Shapefile.

Thanks,
Andrea



>
>
>  _______________________________________________
>  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