Hi, Gerd,
 
I just saw in the generated style documentation that I overlooked to escape the pipe symbol (|) in the rule-filters.txt. Here the small correction. Please commit it to the trunk.
 
Max
 
Gesendet: Freitag, 30. Januar 2015 um 16:35 Uhr
Von: GerdP <gpetermann_muenchen@hotmail.com>
An: mkgmap-dev@lists.mkgmap.org.uk
Betreff: Re: [mkgmap-dev] Patch: New filter "not-contained"
Hi Max,

okay, thanks for the explanation. I think I understand now.
I think we can say that your patch is also a correction and
the "side effect" is in fact the better solution.

I've committed the patch with r3422.

Gerd



&quot;Maxim Düster&quot; wrote
> Hi, Gerd,
>
> &nbsp;
>
> well, it&#39;s indeed not so easy to find an example. In most cases you
> won&#39;t see any difference because almost no existent filter uses the
> second parameter in the filter()/doFilter() method. The only one using it,
> besides the proposed new filter, is the &#39;not-equal&#39; filter. The
> example I found for using it inside the apply{} block is a bit artificial
> and probably not really meaningful, but I hope, it gives the idea.
>
> Assume, you want to find and visualize a specifical type of errors in
> data, namely streets being part of an associatedStreet relation but having
> a different name than the relation itself. To get this, you could do in
> relations file something like:
>
> &nbsp;
>
> type=associatedStreet &amp; name=* {
> &nbsp;&nbsp; &nbsp;apply {
> &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;set
> nameInRelation=&#39;&#36;{name&#124;not-equal:name}&#39;;
> &nbsp;&nbsp; &nbsp;}
> }
>
> &nbsp;
>
> where you want to compare the relation&#39;s name with the street&#39;s
> name and to remember the relation&#39;s name if it&#39;s different.
>
> Then, in lines file, you could write something like
>
> &nbsp;
>
>
> highway=* &amp; nameInRelation=* [...]
>
> &lt;finalize&gt;
> name=* { name &#39;&#36;{name}/&#36;{nameInRelation}&#39; }
>
> &nbsp;
>
> to highlight the differences. So, and now, with the current mkgmap code
> both &quot;name&quot;s referenced in the &#39;set&#39; command are the
> same, namely it&#39;s the name of the relation. You cannot pass the
> current street&#39;s name to the filter. After running mkgmap you get a
> map without any street as for every street holds name=name and so
> nameInRelation is not set.
>
> &nbsp;
>
> You could also try to pass a differently named tag to the filter by saving
> the street&#39;s name in a temporary tag, like:
>
> &nbsp;
>
> type=associatedStreet &amp; name=* {
> &nbsp;&nbsp; &nbsp;apply {
>
> &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;set myname=&#39;&#36;(name)&#39;;
> &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;set
> nameInRelation=&#39;&#36;{name&#124;not-equal:myname}&#39;;
> &nbsp;&nbsp; &nbsp;}
> }
>
>
>
> &nbsp;
>
> But in this case, the tag &#39;myname&#39; would also be looked for in the
> relation, not in the street&#39;s tags, and as the relation doesn&#39;t
> have such a tag, nameInRelation is always set to the relation&#39;s name
> and so you see in your map all the streets, not only the erroneous ones.
> So, either all or no at all.
>
> &nbsp;
>
> With the proposed change, however, the filter gets a local element as a
> second parameter in doFilter(), so in both cases the name of the relation
> would be compared to the (local) tags of the current street (either name
> or myname) and you would get only streets with errors in the map.
>
> The new filter is specifically designed for using in the apply{} block, so
> it necessarily needs an access to the local object.
>
> &nbsp;
>
> So, to summarize my reasoning: the functionality of no existent filter
> would break after the patch (almost all filters would not see any
> difference, one would potentially benefit from the change and one requires
> it). Writers of new filters would not, in my opinion, have any troubles
> with it, too. If they would need a local element, they get it for free. If
> they would need a global element, one can always save global tags in the
> local element and then call the filter with the local element.
>
> &nbsp;
>
> What do you think about it now? Could I convince you? :)
>
> &nbsp;
>
> Max
>
> &nbsp;
>
>
> Gesendet:&nbsp;Donnerstag, 29. Januar 2015 um 23:31 Uhr
> Von:&nbsp;GerdP &lt;

> gpetermann_muenchen@

> &gt;
> An:&nbsp;

> mkgmap-dev@.org

>
> Betreff:&nbsp;Re: [mkgmap-dev] Patch: New filter &quot;not-contained&quot;
>
> Hi Maxim,
>
> I tried to find out if the patch has a side effect, but
> I failed. From your description I understand that
> I should be able to produce different results (not
> using the new filter, just something that workded before)
>
> Can you give an example where I should find a difference?
>
> Gerd
>
>
> &amp;quot;Maxim D&uuml;ster&amp;quot; wrote
> &gt; Hi, Gerd,
> &gt;
> &gt; &amp;nbsp;
> &gt;
> &gt; I think, there shouldn&amp;#39;t be a problem. Actually, if you are
> using a
> &gt; filter inside of the apply{} block, you would presumably like to be
> able
> &gt; to access the current element from the filter. At the moment you
> don&amp;#39;t
> &gt; have such a possibility at all.
> &gt;
> &gt; If though there will be need to pass a tag from the global relation
> to the
> &gt; filter, one can always assign a global tag to a temporary local tag
> before
> &gt; calling the filter with this local tag.
> &gt;
> &gt; So, in my mind, nothing should go wrong here. Perhaps someone else
> can say
> &gt; something more regarding this issue.
> &gt;
> &gt; &amp;nbsp;
> &gt;
> &gt; Max
> &gt;
> &gt; &amp;nbsp;
> &gt;
> &gt; Gesendet:&amp;nbsp;Donnerstag, 29. Januar 2015 um 18:30 Uhr
> &gt; Von:&amp;nbsp;GerdP &amp;lt;
>
> &gt; gpetermann_muenchen@
>
> &gt; &amp;gt;
> &gt; An:&amp;nbsp;
>
> &gt; mkgmap-dev@.org
>
> &gt;
> &gt; Betreff:&amp;nbsp;Re: [mkgmap-dev] Patch: New filter
> &amp;quot;not-contained&amp;quot;
> &gt;
> &gt; Hi Max,
> &gt;
> &gt; not sure. What will happen if one uses another filter in the
> relations
> &gt; file?
> &gt;
> &gt; Gerd
> &gt;
> &gt;
> &gt; &amp;amp;quot;Maxim D&amp;uuml;ster&amp;amp;quot; wrote
> &gt; &amp;gt; Hi, Gerd,
> &gt; &amp;gt;
> &gt; &amp;gt; &amp;amp;nbsp;
> &gt; &amp;gt;
> &gt; &amp;gt; the change is caused by the fact that the filter was thought
> &gt; primarily for
> &gt; &amp;gt; working in relations file inside of the apply{} block and
> needs that
> &gt; the
> &gt; &amp;gt; tag given as last parameter is a local tag of the element
> being
> &gt; processed
> &gt; &amp;gt; (e.g. a way). But the old code line says:
> &amp;amp;quot;value =
> &gt; &amp;gt; filter.filter(tagval,el);&amp;amp;quot;,
> &amp;amp;#39;el&amp;amp;#39; being the
> &gt; parent relation
> &gt; &amp;gt; the way is in. That is, in the filter I only have an access
> to the
> &gt; &amp;gt; (global) relation&amp;amp;#39;s tags, but what I actually
> need are the
> &gt; tags of the
> &gt; &amp;gt; (local) element being currently processed.
> &gt; &amp;gt;
> &gt; &amp;gt; While applying filters to &amp;amp;quot;plain&amp;amp;quot;
> elements (those
> &gt; not inside a
> &gt; &amp;gt; relation, e.g. in points or lines files),
> &amp;amp;#39;local_el&amp;amp;#39;
> &gt; and
> &gt; &amp;gt; &amp;amp;#39;el&amp;amp;#39; are equal, so my change should
> not corrupt
> &gt; anything.
> &gt; &amp;gt;
> &gt; &amp;gt; &amp;amp;nbsp;
> &gt; &amp;gt;
> &gt; &amp;gt; Max
> &gt; &amp;gt;
> &gt; &amp;gt; &amp;amp;nbsp;
> &gt; &amp;gt;
> &gt; &amp;gt; Gesendet:&amp;amp;nbsp;Donnerstag, 29. Januar 2015 um 11:20
> Uhr
> &gt; &amp;gt; Von:&amp;amp;nbsp;&amp;amp;quot;Gerd Petermann&amp;amp;quot;
> &amp;amp;lt;
> &gt;
> &gt; &amp;gt; gpetermann_muenchen@
> &gt;
> &gt; &amp;gt; &amp;amp;gt;
> &gt; &amp;gt; An:&amp;amp;nbsp;&amp;amp;quot;
> &gt;
> &gt; &amp;gt; mkgmap-dev@.org
> &gt;
> &gt; &amp;gt; &amp;amp;quot; &amp;amp;lt;
> &gt;
> &gt; &amp;gt; mkgmap-dev@.org
> &gt;
> &gt; &amp;gt; &amp;amp;gt;
> &gt; &amp;gt; Betreff:&amp;amp;nbsp;Re: [mkgmap-dev] Patch: New filter
> &gt; &amp;amp;quot;not-contained&amp;amp;quot;
> &gt; &amp;gt;
> &gt; &amp;gt;
> &gt; &amp;gt;
> &gt; &amp;gt; Hi Maxim,
> &gt; &amp;gt;
> &gt; &amp;gt; please can you explain the reason for the change in
> ValueItem?
> &gt; &amp;gt;
> &gt; &amp;gt; Gerd
> &gt; &amp;gt; &amp;amp;nbsp;
> &gt; &amp;gt;
> &gt; &amp;gt; From:
> &gt;
> &gt; &amp;gt; maxc@
> &gt;
> &gt; &amp;gt;
> &gt; &amp;gt; To:
> &gt;
> &gt; &amp;gt; mkgmap-dev@.org
> &gt;
> &gt; &amp;gt;
> &gt; &amp;gt; Date: Wed, 28 Jan 2015 12:12:25 +0100
> &gt; &amp;gt; Subject: [mkgmap-dev] Patch: New filter
> &gt; &amp;amp;quot;not-contained&amp;amp;quot;
> &gt; &amp;gt; &amp;amp;nbsp;
> &gt; &amp;gt;
> &gt; &amp;gt; Hello!
> &gt; &amp;gt; &amp;amp;nbsp;
> &gt; &amp;gt; I&amp;amp;#39;ve attached a patch with a new filter that
> helps while
> &gt; processing,
> &gt; &amp;gt; for example, public transport relations. The reason: there
> can be
> &gt; multiple
> &gt; &amp;gt; route relations with the same ref attribute (for example,
> one for the
> &gt; &amp;gt; forward direction, one for the return direction), combined
> to a
> &gt; &amp;gt; route_master relation.
> &gt; &amp;gt;
> &gt; &amp;gt; If you want a name for a way to contain the refs of all of
> the routes
> &gt; &amp;gt; going through that way, you have a problem that some refs
> will be
> &gt; present
> &gt; &amp;gt; more than once, similar to
> &amp;amp;quot;1,1,2,2,2&amp;amp;quot; (if we
> &gt; assume that route
> &gt; &amp;gt; 1 has two instances, and route 2 - three instances).
> &gt; &amp;gt;
> &gt; &amp;gt; The new filter helps to circumvent this. It takes 2
> parameters: a
> &gt; &amp;gt; delimiter (a comma in the example above) and the name of a
> tag
> &gt; containg
> &gt; &amp;gt; the list. The filter works a bit like the
> &gt; &amp;amp;quot;not-equal&amp;amp;quot; filter,
> &gt; &amp;gt; but it doesn&amp;amp;#39;t just compare two values; instead
> it looks if
> &gt; the
> &gt; &amp;gt; tag&amp;amp;#39;s value (to which the filter is being
> applied) is
> &gt; contained in the
> &gt; &amp;gt; list from the (other) given tag. If it is not the case, the
> value can
> &gt; be
> &gt; &amp;gt; added to the list, otherwise the tag is considered unset.
> &gt; &amp;gt;
> &gt; &amp;gt; &amp;amp;nbsp;
> &gt; &amp;gt;
> &gt; &amp;gt; Simple example for relations file:
> &gt; &amp;gt;
> &gt; &amp;gt; &amp;amp;nbsp;
> &gt; &amp;gt;
> &gt; &amp;gt; type=route &amp;amp;amp; route=bus &amp;amp;amp; ref=* {
> &gt; &amp;gt; &amp;amp;nbsp;&amp;amp;nbsp; apply {
> &gt; &amp;gt;
> &amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp; set
> &gt; &amp;gt;
> &gt;
> route_ref=&amp;amp;#39;&amp;amp;#36;(route_ref),&amp;amp;#36;{ref&amp;amp;#124;not-contained:,:route_ref}&amp;amp;#39;
> &gt; &amp;gt; &amp;amp;#124;
> &amp;amp;#39;&amp;amp;#36;(route_ref)&amp;amp;#39; &amp;amp;#124;
> &gt; &amp;amp;#39;&amp;amp;#36;{ref}&amp;amp;#39;;
> &gt; &amp;gt; &amp;amp;nbsp;&amp;amp;nbsp; }
> &gt; &amp;gt; }
> &gt; &amp;gt;
> &gt; &amp;gt; &amp;amp;nbsp;
> &gt; &amp;gt;
> &gt; &amp;gt; Here, ref value is only added to route_ref if it is not
> already
> &gt; contained
> &gt; &amp;gt; in that list (with separator &amp;amp;#39;,&amp;amp;#39;).
> Otherwise, the
> &gt; value of
> &gt; &amp;gt; route_ref is unchanged.
> &gt; &amp;gt; &amp;amp;nbsp;
> &gt; &amp;gt; Cheers!
> &gt; &amp;gt; Max
> &gt; &amp;gt;
> &gt; &amp;gt;
> &gt; &amp;gt; _______________________________________________ mkgmap-dev
> mailing
> &gt; list
> &gt;
> &gt; &amp;gt; mkgmap-dev@.org
> &gt;
> &gt; &amp;gt; http://www.mkgmap.org.uk/mailman/listinfo/mkgmap-dev
> &gt; &amp;gt;
> &gt; &amp;gt; _______________________________________________ mkgmap-dev
> mailing
> &gt; list
> &gt;
> &gt; &amp;gt; mkgmap-dev@.org
> &gt;
> &gt; &amp;gt; http://www.mkgmap.org.uk/mailman/listinfo/mkgmap-dev
> &gt; &amp;gt;
> &gt; &amp;gt;
> &gt; &amp;gt;
> &gt; &amp;gt;
> &gt; &amp;gt;
> &gt; &amp;gt; _______________________________________________
> &gt; &amp;gt; mkgmap-dev mailing list
> &gt;
> &gt; &amp;gt; mkgmap-dev@.org
> &gt;
> &gt; &amp;gt; http://www.mkgmap.org.uk/mailman/listinfo/mkgmap-dev
> &gt;
> &gt;
> &gt;
> &gt;
> &gt;
> &gt; --
> &gt; View this message in context:
> &gt;
> http://gis.19327.n5.nabble.com/Patch-New-filter-not-contained-tp5831668p5831841.html
> &gt; Sent from the Mkgmap Development mailing list archive at Nabble.com.
> &gt; _______________________________________________
> &gt; mkgmap-dev mailing list
>
> &gt; mkgmap-dev@.org
>
> &gt;
> &gt; http://www.mkgmap.org.uk/mailman/listinfo/mkgmap-dev
> &gt;
> &gt;
> &gt;
> &gt;
> &gt; _______________________________________________
> &gt; mkgmap-dev mailing list
>
> &gt; mkgmap-dev@.org
>
> &gt; http://www.mkgmap.org.uk/mailman/listinfo/mkgmap-dev
>
>
>
>
>
> --
> View this message in context:
> http://gis.19327.n5.nabble.com/Patch-New-filter-not-contained-tp5831668p5831869.html
> Sent from the Mkgmap Development mailing list archive at Nabble.com.
> _______________________________________________
> mkgmap-dev mailing list

> mkgmap-dev@.org

>
> http://www.mkgmap.org.uk/mailman/listinfo/mkgmap-dev
>
>
>
>
> _______________________________________________
> mkgmap-dev mailing list

> mkgmap-dev@.org

> http://www.mkgmap.org.uk/mailman/listinfo/mkgmap-dev





--
View this message in context: http://gis.19327.n5.nabble.com/Patch-New-filter-not-contained-tp5831668p5831947.html
Sent from the Mkgmap Development mailing list archive at Nabble.com.
_______________________________________________
mkgmap-dev mailing list
mkgmap-dev@lists.mkgmap.org.uk
http://www.mkgmap.org.uk/mailman/listinfo/mkgmap-dev