Incorrect refresh of spatialindex
---------------------------------

                 Key: UDIG-1613
                 URL: http://jira.codehaus.org/browse/UDIG-1613
             Project: uDIG
          Issue Type: Bug
          Components: tools and editing
    Affects Versions: UDIG 1.2.M9
         Environment: JRE with gdal(jre1.6.0_17.win32_gdal_ecw.zip) , RCP 3.5.1
            Reporter: Devrim Baris Acar


I have spotted a strange behaviour while working with udig 1.2m9. I guess it is 
a bug and here are the steps to reproduce it:

   1. Open a shapefile of point geometry and choose the layer
   2. Use point tool
   3. Add a point to the layer
   4. Choose the added point with the edit geometry tool and drag drop it on 
the layer
   5. Choose an empty point in layer
   6. It is a good chance you lost the added point, in this case redraw map
   7. Iterate over steps 4-6  a couple of times
   8. Redraw map
   9. Even if you have added a single point, it is drawn multiple times on the 
map

I have tried this issue with city.shp and temporary layers, both give the same 
behaviour.

I have tracked down the issue and it seems that the the spatial index which is 
activated in RefreshTool is never refreshed truely because a move operation in 
udig(AFAIK) corresponds to a remove and add operation regarding to the code in 
org.geotools.data.Diff class. Here the modify method removes the feature from 
index and adds the new location. The problem here is the old location is 
changed to new location before this step. So the spatial index searches with 
the new coordinates thus lacks to find the position and cannot remove it.

To correct this behavior I have changed the SetAttributeCommand.java -> run()
from this:

    this.oldValue = feature2.getAttribute(xpath);
    feature2.setAttribute(xpath, value);
    AttributeDescriptor attributeType = layer.getSchema().getDescriptor(xpath);
    resource.modifyFeatures(attributeType, value, fidFilter);


to this:

    this.oldValue = feature2.getAttribute(xpath);
    AttributeDescriptor attributeType = layer.getSchema().getDescriptor(xpath);
    resource.modifyFeatures(attributeType, value, fidFilter);
    feature2.setAttribute(xpath, value);

        

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: 
http://jira.codehaus.org/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        
_______________________________________________
User-friendly Desktop Internet GIS (uDig)
http://udig.refractions.net
http://lists.refractions.net/mailman/listinfo/udig-devel

Reply via email to