Nope my fault; I was hoping you had caught the edit tools duplicating
a feature; I felt stupid the moment I went back to your code example.
I am glad you sorted things out.

Best of luck,
Jody

On Thu, Apr 16, 2009 at 5:11 PM, Rodolphe QUEMERAIS
<[email protected]> wrote:
> It's just I was calling the procedure to create a feature twice... but I'm
> not sure to have understood the meaning of your question... My poor non
> native speaker english ? ;)
>
> 2009/4/16 Jody Garnett <[email protected]>
>>
>> Oh I know that bug; creating two features by accident is a pain. Do
>> you have a way to reproduce it or is it just luck?
>>
>> Jody
>>
>> On Thu, Apr 16, 2009 at 12:01 AM, Rodolphe QUEMERAIS
>> <[email protected]> wrote:
>> > Thanks a lot for the answer and I'm quite ashame ... I've found out my
>> > mistake.
>> > Actually, there's no 'ghost' problem. I just initialy created 2 features
>> > at
>> > the same place. That was my mistake...
>> > Sorry if I waste your precious time.
>> > On the other hand, some uDIG newbies could find my code example
>> > interesting
>> > to manipulate features via datastore.
>> >
>> > 2009/4/15 Jody Garnett <[email protected]>
>> >>
>> >> uDig manages its own transaction; you know that right? If you would
>> >> like the transaction please contact the EditManager (it is available
>> >> via any tool or render context). This is the transaction that is
>> >> engaged when the user hits the commit or rollback buttons.
>> >>
>> >> When you ask a layer for a FeatureSource or FeatureStore this
>> >> transaction will be set prior to your code receiving it. The idea is
>> >> that your code should work directly against the featureStore API; and
>> >> the user should be able to run your code; and any other operations;
>> >> review the result prior to committing.
>> >>
>> >> Jody
>> >>
>> >> On Tue, Apr 14, 2009 at 10:05 PM, Rodolphe QUEMERAIS
>> >> <[email protected]> wrote:
>> >> > Hi all,
>> >> >
>> >> > I would be please if someone could help me to understand what's
>> >> > happening on
>> >> > my layer...
>> >> >
>> >> > Actually, I created a layer and added a feature on it. I've
>> >> > programmed a
>> >> > visual tool with arrows that let me move my feature on screen. The
>> >> > problem
>> >> > is, as I thought I created only one feature, a clone one has been
>> >> > created
>> >> > too. The cloned layer disappear if I refresh the screen but reappear
>> >> > if
>> >> > I
>> >> > move the othe feature over it...
>> >> >
>> >> > here are the code extract if that can help:
>> >> >
>> >> > To create a feature :
>> >> > Feature[] features = new Feature[1];
>> >> >         features[0] = feature;
>> >> >                 System.out.println("feature créé : "+
>> >> > features[0].getID());
>> >> >         String featureTypeName = myLayer.getSchema().getTypeName();
>> >> >         try {
>> >> >
>> >> >             FeatureSource source =
>> >> > myLayer.getResource(FeatureSource.class,
>> >> > ProgressManager.instance().get());
>> >> >             DataStore dataStore = source.getDataStore();
>> >> >
>> >> >             FeatureStore store = (FeatureStore)
>> >> > dataStore.getFeatureSource(featureTypeName);
>> >> >             store.setTransaction(transaction);
>> >> >             store.addFeatures(DataUtilities.collection(features));
>> >> >             transaction.commit();
>> >> >
>> >> >         } catch (IOException e) {
>> >> >             transaction.rollback();
>> >> >             e.printStackTrace();
>> >> >         } finally {
>> >> >             transaction.close();
>> >> >         }
>> >> >
>> >> > To move the feature :
>> >> >
>> >> >         DefaultTransaction transaction = new
>> >> > DefaultTransaction("Example1");
>> >> >
>> >> >         try {
>> >> >         FeatureStore store = (FeatureStore)
>> >> > dataStore.getFeatureSource(featureTypeName);
>> >> >
>> >> >         store.setTransaction( transaction );
>> >> >
>> >> >         FilterFactory ff = FilterFactoryFinder.createFilterFactory();
>> >> >         //To filter only the selected feature, the featureId has
>> >> > previously
>> >> > been captured
>> >> >         FidFilter filter2 = ff.createFidFilter();
>> >> >         filter2.addFid(featureId);
>> >> >
>> >> >         FeatureType featureType = store.getSchema();
>> >> >
>> >> >         AttributeType att = featureType.getDefaultGeometry();
>> >> >         //geo is the modified Geometry
>> >> >             store.modifyFeatures(att, geo, filter2);
>> >> >             transaction.commit();
>> >> >             System.out.println("Transaction effectué");
>> >> >         } catch (Exception e) {
>> >> >             transaction.rollback();
>> >> >             System.out.println("Rollback effectué");
>> >> >
>> >> >         } finally {
>> >> >             transaction.close();
>> >> >         }
>> >> >
>> >> > The 'cloned' feature ID is like new0 and the created feature ID is
>> >> > like
>> >> > fid-_61883d49_120a475c79a__7ffd
>> >> > I have the feeling that new0 is not in datastore and has only been
>> >> > created
>> >> > on the graphic layer... but I'm not sure at all...
>> >> > Any suggestions ?
>> >> >
>> >> >
>> >> > _______________________________________________
>> >> > 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
>> >
>> >
>> > _______________________________________________
>> > 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
>
>
> _______________________________________________
> 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

Reply via email to