Hi all,

I'm a new user of geotools, and I have the following problem.
In my application I have to develop a kind a "navigator". To do this, I
have a map layer in which I want to set up the position every two seconds.

I did a method called "updateVehiclePosition" in which a transaction
modifies the geometry value (Point). The problem is that this method works
until no timing function is called. When I insert the TimerTask, the
method stops at the transaction commit, and the map is not painted.

Can anyone help me in fixing this problem?
I report in the following the interested piece of code.

public static void updateVehiclePosition(Object object) throws IOException {

DefaultTransaction transaction = new DefaultTransaction("Example1");
FeatureStore fstore =  (FeatureStore) map.getLayer(5).getFeatureSource();
fstore.setTransaction( transaction );

FilterFactory ff =
CommonFactoryFinder.getFilterFactory(GeoTools.getDefaultHints() );
Filter filter = ff.id( Collections.singleton( ff.featureId("location.1")));

SimpleFeatureType featureType = (SimpleFeatureType) fstore.getSchema();
AttributeType attributeType = featureType.getType("Location");

try {
   fstore.modifyFeatures( attributeType.getName(), object, filter );
   transaction.commit(); //here there is the problem!!!
}
catch( Exception eek){
    transaction.rollback();
}
finally{
   transaction.close();
}
}

public static void go() {
  final java.util.Timer timer = new java.util.Timer();
  TimerTask task = new TimerTask() {
  int line = 1;
  public void run() {
    if(line>3){timer.cancel();}
    leggi(line);
    line++;
  };
 };
 timer.scheduleAtFixedRate(task, 0, 2000);
}

private static void leggi(int line2) {
  Object pos;
  pos=C2XVisualizer.readPosition(line2);
  try {
    C2XVisualizer.updateVehiclePosition(pos);
  } catch (IOException e) {e.printStackTrace();}
}


-- 
View this message in context: 
http://osgeo-org.1803224.n2.nabble.com/commit-does-not-return-tp5651336p5651336.html
Sent from the geotools-gt2-users mailing list archive at Nabble.com.

------------------------------------------------------------------------------
Download new Adobe(R) Flash(R) Builder(TM) 4
The new Adobe(R) Flex(R) 4 and Flash(R) Builder(TM) 4 (formerly 
Flex(R) Builder(TM)) enable the development of rich applications that run
across multiple browsers and platforms. Download your free trials today!
http://p.sf.net/sfu/adobe-dev2dev
_______________________________________________
Geotools-gt2-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users

Reply via email to