Question reg. LayerFilterChain.addElement

Hi, maybe I found an error, maybe my understanding is wrong... I thought that all filters in the chain are executed before any element is finally passed to eg. the MapBuilder.LineAddFilter.LineAddFilter But if eg. the LineSplitterFilter calls addElement() instead of doFilter() all following filters are skipped and MapBuilder.LineAddFilter.LineAddFilter is called directly. If this is intended, where should a filter that checks for equal coordinates be placed? I wanted to add it after RemoveEmpty(), but then some invalid lines are passed to the map.addMapObject() method. ciao, Gerd -- View this message in context: http://gis.19327.n5.nabble.com/Question-reg-LayerFilterChain-addElement-tp57... Sent from the Mkgmap Development mailing list archive at Nabble.com.

It was my intention that a filter either calls doFilter or drops the element. GerdP <gpetermann_muenchen@hotmail.com> wrote:
Hi,
maybe I found an error, maybe my understanding is wrong...
I thought that all filters in the chain are executed before any element is finally passed to eg. the MapBuilder.LineAddFilter.LineAddFilter
But if eg. the LineSplitterFilter calls addElement() instead of doFilter() all following filters are skipped and MapBuilder.LineAddFilter.LineAddFilter is called directly. If this is intended, where should a filter that checks for equal coordinates be placed? I wanted to add it after RemoveEmpty(), but then some invalid lines are passed to the map.addMapObject() method.
ciao, Gerd
-- View this message in context: http://gis.19327.n5.nabble.com/Question-reg-LayerFilterChain-addElement-tp57... Sent from the Mkgmap Development mailing list archive at Nabble.com. _______________________________________________ mkgmap-dev mailing list mkgmap-dev@lists.mkgmap.org.uk http://lists.mkgmap.org.uk/mailman/listinfo/mkgmap-dev

Hi, Steve Ratcliffe wrote
It was my intention that a filter either calls doFilter or drops the element.
the comment for addElement implies that the following filters should not be skipped. * <p>Although this is based on servlet filters, there is a complication in * that we want to be able to split up an element, this lead to the * {@link #addElement(MapElement)} method which in effect creates a new chain * that is at the same stage as the current one and with the same final * destination. So I think I found an error and I will try to fix it. Gerd -- View this message in context: http://gis.19327.n5.nabble.com/Question-reg-LayerFilterChain-addElement-tp57... Sent from the Mkgmap Development mailing list archive at Nabble.com.

Hi Steve, GerdP wrote
So I think I found an error and I will try to fix it. Gerd
what do you think about this simple change? It allows to replace all calls to LayerFilterChain.addElement() by LayerFilterChain.doFilter() which simplifies the code and corrects the problem regarding omitted filters. Gerd Index: LayerFilterChain.java =================================================================== --- LayerFilterChain.java (revision 2474) +++ LayerFilterChain.java (working copy) @@ -55,17 +55,10 @@ MapFilter f = filters.get(position++); f.doFilter(element, this); + // maintain chain position for repeated calls in the split filters + position--; } -- View this message in context: http://gis.19327.n5.nabble.com/Question-reg-LayerFilterChain-addElement-tp57... Sent from the Mkgmap Development mailing list archive at Nabble.com.

Hi Gerd
Index: LayerFilterChain.java =================================================================== --- LayerFilterChain.java (revision 2474) +++ LayerFilterChain.java (working copy) @@ -55,17 +55,10 @@
MapFilter f = filters.get(position++); f.doFilter(element, this); + // maintain chain position for repeated calls in the split filters + position--; }
Ingenious! Looks good to me. ..Steve
participants (2)
-
GerdP
-
Steve Ratcliffe