Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [udig-devel] Trouble with modifying feature attributes

Hi Jesse,
thanks (!!) for the eSetDeliver(..) hint. I've never used it before. I think I can speed up my application in general with using it in some more scenarios.
 
tony roth


I think what you need to do is ensure that the rendering is triggered after the updates.  The quick way is:

Layer layer2 = (Layer)layer;
try{
layer2.eSetDeliver(false);
// do your stuff
layer.refresh(areaToRefresh);
}finally{
layer2.eSetDeliver(true);
}

As you can probably guess the eSetDeliver() turns off events for the layer.

Hope this helps,

Jesse



On Oct 4, 2007, at 6:01 AM, tony.roth@xxxxxx wrote:

situation:
The features of a point layer are symbolized with external graphics. All elements are presented to the user in a table and if he selectes one or more in this table the items shall be highlighted in the map. The SLD specification defines that a graphic either contains a mark or an external graphic, therefore it's not possible to surround the external graphic with a red square or something like that: I need another external grahpic.
To realize this my features have the featureattribute 'selected' and I generate a bunch of sld rulez: For each category of my items and for {selected;unselected} I generate a rule with a certain external graphic. (The categories define the symbol like windmill or tower)
If the user selects one or more items of the table this happens:
 public void setSelection(List<Integer> selectedItems){
  try {
   FeatureStore fs = layer.getResource(FeatureStore.class, null);
   // deselect all: setting the dedictated attribute type to  UNSELECTED (static variable)
   // this happens since we don't know which of the elements are selected at the moment
   fs.modifyFeatures(selectionAttributeType, UNSELECTED, Filter.NONE);
   FilterFactory filterFactory = FilterFactoryFinder.createFilterFactory();
   // set the selected ones
   for (Integer id:selectedItems){
    AttributeExpression attributeExpression = filterFactory.createAttributeExpression(IDAttributeName);
    LiteralExpression literalExpression = filterFactory.createLiteralExpression(id);
    CompareFilter compareFilter = filterFactory.createCompareFilter(FilterType.COMPARE_EQUALS);
    compareFilter.addLeftValue(attributeExpression);
    compareFilter.addRightValue(literalExpression);
    // this sets the filtered features to SELECTED
    fs.modifyFeatures(selectionAttributeType, SELECTED, compareFilter);
   }
  } catch (Exception e) {
    // ...
  }
 }
It works... somehow .. but not the way I wanted:
The renderer starts and on the first modifyFeatures comand (the deselection) all items are rendered. This takes about 14 seconds (on a pentium 4) with just four features in the layer. And only the graphics / symbols are rendered, the labels below the symbols are destroyed and I have to update the layer.
Another way could be to check which features switch >from selected to not selected and just modify these in the first step but with hundreds or more featuers this also takes a while.
Is this approach to be doomed and / or crap?
What is the best way to realize a kind of highlight features in the map with external graphics?
tony roth
_______________________________________________
User-friendly Desktop Internet GIS (uDig)

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


Back to the top