Skip to main content

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

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

Back to the top