[udig-devel] adding and modifying a new feature
andrea antonello
andrea.antonello at gmail.com
Tue May 6 06:14:48 PDT 2008
Hi Jesse,
> Ah yes. I don't think that will work. You see when a feature is created it
> is assigned a more or less random ID. However when it is added to a data
> store it is assigned a different id. Then to make matters worse some
> datastores (WFS) assign it a new ID when a commit occurs.
>
> For the wfs datastore I put some code that keeps track of added features so
> that after a commit the same FID can be used. But for trunk we are planning
> on changing the events so that the new FIDs are broadcast so interested
> parties can update the FIDs they are holding to be accurate after the
> commit.
>
> I think on the AddFeatureCommand there are methods for either getting the
> new feature or at least the FID of the new feature.
>
> Yeah, there it is. getNewFeature().
I think by keeping the reference to the feature that is first added, I
achieve the same as the getNewFeature method. Right?
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
view.
Is this somehow related to the features sometimes not appearing while editing?
Andrea
>
> Good luck :)
>
> Jesse
>
>
> On 6-May-08, at 11:11 AM, andrea antonello wrote:
>
>
> >
> >
> >
> > I'm trying to add programmatically a new feature to a layer and to
> > modify it as new coordinates come to make the geometry of that feature
> > evolve.
> > What I am doing is:
> >
> > - the first time create a feature and add it to the layer with
> > UndoableMapCommand createAddFeatureCommand =
> EditCommandFactory
> > .getInstance().createAddFeatureCommand(feature,
> layer);
> > layer.getMap().sendCommandASync(createAddFeatureCommand);
> >
> > - having kept the reference to that feature, every time new
> > coordinates come, I add the coordinate to the geometry of the feature
> > I created at the first round and modify on the layer with the
> > following:
> >
> > UndoableMapCommand[] cmds = new UndoableMapCommand[3];
> > cmds[0] = EditCommandFactory.getInstance()
> > .createSetEditFeatureCommand(feature, layer);
> > cmds[1] = EditCommandFactory.getInstance()
> > .createSetGeomteryCommand(feature, layer, geometry);
> >
> > layer.getMap().sendCommandASync(cmds[0]);
> > layer.getMap().sendCommandASync(cmds[1]);
> >
> > Should this work?
> >
> > Ciao,
> > Andrea
> > _______________________________________________
> > 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
>
More information about the udig-devel
mailing list