Osmarender/Proposal Temporary Tags

From OpenStreetMap Wiki
Jump to navigation Jump to search

Hello

I'll propose temporary tags on OSM elements inside Osmarender to simplify rule-coding or -- more general -- to re-tag elements and easy refer values in drawing instructions.

I hope, that is possible in XSLt- an Perl-Version and doesn't make processing slower or some other unwanted side effects...

the problem -- an exampe

I'm just planning do redesign some rules to support some proposed features ...

I first decided to make a lot of different width, furtheron I decided to reduce them to 4 ;-)

So I got the following first cascade of rules (written here a litle bit "simple") for some standard cases:

<rule bridgecasing>
  <rule width-a>
  </rule><else>
    <rule width-b>
    </rule><else>
      <rule width-c>
      </rule><else>
      </else>
    </else>
  </else>
</rule>

It looks small, but ...

One case is needed to check separate, so:

<rule bridgecasing>
  <rule width-c-onothercase>
  </rule><else>
    <rule width-a>
    </rule><else>
      <rule width-b>
      </rule><else>
        <rule width-c>
        </rule><else>
        </else>
      </else>
    </else>
  </else>
</rule>

When using a special tag, then two ways are close together, so I decide to draw them a little bit narrower, so another rule is added, now having the former set of rules twice:

<rule bridgecasing>
  <rule narrow-width>
    <rule width-c-onothercase>
    </rule><else>
      <rule width-a>
      </rule><else>
        <rule width-b>
        </rule><else>
          <rule width-c>
          </rule><else>
          </else>
        </else>
      </else>
    </else>
  </rule><else>
    <rule width-c-onothercase>
    </rule><else>
      <rule width-a>
      </rule><else>
        <rule width-b>
        </rule><else>
          <rule width-c>
          </rule><else>
          </else>
        </else>
      </else>
    </else>
  </else>
</rule>

Then adding some old tags, supported further on as short cuts

<rule bridgecasing>
  <rule narrow-width>
    <rule width-c-onothercase>
    </rule><else>
      <rule width-a>
      </rule><else>
        <rule width-b>
        </rule><else>
          <rule width-c>
          </rule><else>
          </else>
        </else>
      </else>
    </else>
    <rule firstoldcase>
    </rule>
    <rule secondoldcase>
    </rule>
  </rule><else>
    <rule width-c-onothercase>
    </rule><else>
      <rule width-a>
      </rule><else>
        <rule width-b>
        </rule><else>
          <rule width-c>
          </rule><else>
          </else>
        </else>
      </else>
    </else>
    <rule firstoldcase>
    </rule>
    <rule secondoldcase>
    </rule>
  </else>
</rule>

Then I want to have different cases of lines for two special cases besides standard case, so every line has

<rule speciacaseone>
</rule><else>
  <rule specialcasetwo>
  </rule><else>
  </else>
</rule>

So the result up to now is:

<rule bridgecasing>
 <rule narrow-width>
   <rule width-c-onothercase>
              <rule speciacaseone>
              </rule><else>
                <rule specialcasetwo>
                </rule><else>
                </else>
               </rule>
   </rule><else>
     <rule width-a>
              <rule speciacaseone>
              </rule><else>
                <rule specialcasetwo>
                </rule><else>
                </else>
               </rule>
     </rule><else>
       <rule width-b>
              <rule speciacaseone>
              </rule><else>
                <rule specialcasetwo>
                </rule><else>
                </else>
               </rule>
       </rule><else>
         <rule width-c>
               <rule speciacaseone>
              </rule><else>
                <rule specialcasetwo>
                </rule><else>
                </else>
               </rule>
        </rule><else>
              <rule speciacaseone>
              </rule><else>
                <rule specialcasetwo>
                </rule><else>
                </else>
               </rule>
         </else>
       </else>
     </else>
   </else>
   <rule firstoldcase>
              <rule speciacaseone>
              </rule><else>
                <rule specialcasetwo>
                </rule><else>
                </else>
               </rule>
   </rule>
   <rule secondoldcase>
              <rule speciacaseone>
              </rule><else>
                <rule specialcasetwo>
                </rule><else>
                </else>
               </rule>
   </rule>
 </rule><else>
   <rule width-c-onothercase>
              <rule speciacaseone>
              </rule><else>
                <rule specialcasetwo>
                </rule><else>
                </else>
               </rule>
   </rule><else>
     <rule width-a>
              <rule speciacaseone>
              </rule><else>
                <rule specialcasetwo>
                </rule><else>
                </else>
               </rule>
     </rule><else>
       <rule width-b>
              <rule speciacaseone>
              </rule><else>
                <rule specialcasetwo>
                </rule><else>
                </else>
               </rule>
       </rule><else>
         <rule width-c>
               <rule speciacaseone>
              </rule><else>
                <rule specialcasetwo>
                </rule><else>
                </else>
               </rule>
        </rule><else>
              <rule speciacaseone>
              </rule><else>
                <rule specialcasetwo>
                </rule><else>
                </else>
               </rule>
         </else>
       </else>
     </else>
   </else>
   <rule firstoldcase>
              <rule speciacaseone>
              </rule><else>
                <rule specialcasetwo>
                </rule><else>
                </else>
               </rule>
   </rule>
   <rule secondoldcase>
              <rule speciacaseone>
              </rule><else>
                <rule specialcasetwo>
                </rule><else>
                </else>
               </rule>
   </rule>
 </else>
</rule>

Now adding the drawing of lines:

<rule bridgecasing>
 <rule narrow-width>
   <rule width-c-onothercase>
              <rule speciacaseone>
                     <line class="x-general x-spec1 x-c-narrow"> 
              </rule><else>
                <rule specialcasetwo>
                     <line class="x-general x-spec2 x-c-narrow"> 
                </rule><else>
                     <line class="x-general         x-c-narrow"> 
                </else>
               </rule>
   </rule><else>
     <rule width-a>
              <rule speciacaseone>
                     <line class="x-general x-spec1 x-a-narrow"> 
              </rule><else>
                <rule specialcasetwo>
                     <line class="x-general x-spec2 x-a-narrow"> 
                </rule><else>
                     <line class="x-general         x-a-narrow"> 
                </else>
               </rule>
     </rule><else>
       <rule width-b>
              <rule speciacaseone>
                     <line class="x-general x-spec1 x-b-narrow"> 
              </rule><else>
                <rule specialcasetwo>
                     <line class="x-general x-spec2 x-b-narrow"> 
                </rule><else>
                     <line class="x-general         x-b-narrow"> 
                </else>
               </rule>
       </rule><else>
         <rule width-c>
              <rule speciacaseone>
                     <line class="x-general x-spec1 x-c-narrow"> 
              </rule><else>
                <rule specialcasetwo>
                     <line class="x-general x-spec2 x-c-narrow"> 
                </rule><else>
                     <line class="x-general         x-c-narrow"> 
                </else>
               </rule>
        </rule><else>
              <rule speciacaseone>
                     <line class="x-general x-spec1 x-d-narrow"> 
              </rule><else>
                <rule specialcasetwo>
                     <line class="x-general x-spec2 x-d-narrow"> 
                </rule><else>
                     <line class="x-general         x-d-narrow"> 
                </else>
               </rule>
         </else>
       </else>
     </else>
   </else>
   <rule firstoldcase>
              <rule speciacaseone>
                     <line class="x-general x-spec1 x-c-narrow"> 
              </rule><else>
                <rule specialcasetwo>
                     <line class="x-general x-spec2 x-c-narrow"> 
                </rule><else>
                     <line class="x-general         x-c-narrow"> 
                </else>
               </rule>
   </rule>
   <rule secondoldcase>
              <rule speciacaseone>
                     <line class="x-general x-spec1 x-a-narrow"> 
              </rule><else>
                <rule specialcasetwo>
                     <line class="x-general x-spec2 x-a-narrow"> 
                </rule><else>
                     <line class="x-general         x-a-narrow"> 
                </else>
               </rule>
   </rule>
 </rule><else>
   <rule width-c-onothercase>
              <rule speciacaseone>
                     <line class="x-general x-spec1 x-c-wide"> 
              </rule><else>
                <rule specialcasetwo>
                     <line class="x-general x-spec2 x-c-wide"> 
                </rule><else>
                     <line class="x-general         x-c-wide"> 
                </else>
               </rule>
   </rule><else>
     <rule width-a>
              <rule speciacaseone>
                     <line class="x-general x-spec1 x-a-wide"> 
              </rule><else>
                <rule specialcasetwo>
                     <line class="x-general x-spec2 x-a-wide"> 
                </rule><else>
                     <line class="x-general         x-a-wide"> 
                </else>
               </rule>
     </rule><else>
       <rule width-b>
              <rule speciacaseone>
                     <line class="x-general x-spec1 x-b-wide"> 
              </rule><else>
                <rule specialcasetwo>
                     <line class="x-general x-spec2 x-b-wide"> 
                </rule><else>
                     <line class="x-general         x-b-wide"> 
                </else>
               </rule>
       </rule><else>
         <rule width-c>
              <rule speciacaseone>
                     <line class="x-general x-spec1 x-c-wide"> 
              </rule><else>
                <rule specialcasetwo>
                     <line class="x-general x-spec2 x-c-wide"> 
                </rule><else>
                     <line class="x-general         x-c-wide"> 
                </else>
               </rule>
        </rule><else>
              <rule speciacaseone>
                     <line class="x-general x-spec1 x-d-wide"> 
              </rule><else>
                <rule specialcasetwo>
                     <line class="x-general x-spec2 x-d-wide"> 
                </rule><else>
                     <line class="x-general         x-d-wide"> 
                </else>
               </rule>
         </else>
       </else>
     </else>
   </else>
   <rule firstoldcase>
              <rule speciacaseone>
                     <line class="x-general x-spec1 x-c-wide"> 
              </rule><else>
                <rule specialcasetwo>
                     <line class="x-general x-spec2 x-c-wide"> 
                </rule><else>
                     <line class="x-general         x-c-wide"> 
                </else>
               </rule>
   </rule>
   <rule secondoldcase>
              <rule speciacaseone>
                     <line class="x-general x-spec1 x-a-wide"> 
              </rule><else>
                <rule specialcasetwo>
                     <line class="x-general x-spec2 x-a-wide"> 
                </rule><else>
                     <line class="x-general         x-a-wide"> 
                </else>
               </rule>
   </rule>
 </else>
</rule>

Now bridge casings are solved... But now nearly the same again for bridge cores:

<rule bridgecore>
  <rule narrow-width>
    <rule width-c-onothercase>
              <rule speciacaseone>
                     <line class="y-general y-spec1 y-c-narrow">
....

I don't copy the rest :-) Then nearly the same again for standard casings and cores, but a little bit more complicate for adding different colors and more special cases... Then nearly the same again for tunnel casings and cores

Horrible...

other proposals

I found the proposal http://wiki.openstreetmap.org/index.php/Osmarender/NewFeaturesProposal

So some cascades like

<rule bridgecasing>
  <rule narrow-width>
    <rule width-c-onothercase>
               <rule speciacaseone>
                      <line class="x-general x-spec1 x-c-narrow"> 
               </rule><else>
               ...
<rule bridgecore>
  <rule narrow-width>
    <rule width-c-onothercase>
               <rule speciacaseone>
                      <line class="y-general y-spec1 y-c-narrow"> 
               </rule><else>
               ....
...

may result in source code, where all is at the same place, that belongs together:

<setOrder "x y ...">
<rule narrow-width>
  <rule width-c-onothercase>
              <rule speciacaseone>
                <rule bridgecasing>
                     <line class="x-general x-spec1 x-c-narrow">
                </rule>
                <rule bridgecore>
                     <line class="y-general y-spec1 y-c-narrow">
                </rule>
              </rule><else>
              ...

But source code wouldn't be more simple... And the proposal isn't available. (Is anyone working to do it???)

I also found http://trac.openstreetmap.org/ticket/1476 But I don't unterstand if it may help or not to simplify code. I fear it doesn't help...

I just have anoter idea, that may help to simplify rules:

The solution? Temporary tags for OSM-elements

setting tags

Using it I can split the cascades from example, see above, into 3 smaller cascades:

<rule width-c-onothercase>
          <set k="$width" v="c" />
</rule><else>
  <rule width-a>
          <set k="$width" v="a" />
  </rule><else>
    <rule width-b>
          <set k="$width" v="b" />
    </rule><else>
      <rule width-c>
          <set k="$width" v="c" />
      </rule><else>
          <set k="$width" v="d" />
      </else>
    </else>
  </else>
</else>
<rule firstoldcase>
          <set k="$width" v="c" />
</rule>
<rule secondoldcase>
          <set k="$width" v="a" />
</rule>
<rule narrow-width>
          <set k="$narrow" v="narrow" />
</rule><else>
          <set k="$narrow" v="wide" />
</rule>
<rule speciacaseone>
          <set k="$spec" v="one" />
</rule><else>
  <rule specialcasetwo>
          <set k="$spec" v="two" />
  </rule><else>
  </else>
          <set k="$spec" v="none" />
</else>

So every way that follows the rules got an extra tag, that only exists while data is processing. The "$" only should mark it as temporary and to avoid conflicts with tags inside original data, that from now on should start with an "$" :-)

referring the tags in drawing insructions

As second step an easy way to refer them is needed. Then the whole very large cascade from the mail with the example is simplified to 3 lines:

<rule bridgecasing>
  <rule way-type>
    <line class="x-general x-{$spec} x-{$width}-{$narrow}" />
  </rule>
</rule>

That's all for all cases of bridge casings! And for bridge cores:

<rule bridgecore>
  <rule way-type>
    <line class="y-general y-{$spec} y-{$width}-{$narrow}" />
  </rule>
</rule>

Standard casings may look a little bit different, if I decide to choose different colors for other tag-combiniations, so new temporary tags are needed, but it also would look simple like the rules above...

I don't know, if thy syntax using {} is the best solution... Someone, who has more knowledge about XML, should decide... :-)

re-tagging of elements

As side effect this new feature also con be used to re-tag elements.

Up to now to sorts of tagging elements under construction, lanned, ... are used: highway=construction construction=primary or highway=primary construction=yes Supporting both results in two larger cascades...

Also now highway=cycleway acts as short cut for highway=path bicylce=designated

This may simplified to

<rule e="way" k="highway" v="construction">
  <rule e="way" k="construction" v="*">
    <set k="highway" v="{construction}" />
    <set k="construction" v="yes" />
  </rule>
</rule>

And further on only the cascades of rules for cosntruction=yes is needed. "Short cuts" may be expanded:

<rule e="way" k="highway" v="cycleway">
  <set k="highway" v="path" />
  <set k="bicycle" v="designated" />
</rule>

question

Is this use of "temporary tags" possible in XSLT and perl? Does anyone can code it for XSLT- and perl-verion, if this new feature is possible and makes sense and if it doesn't make processing slow or other unwanted side effects?

--Mueck 12:56, 30 January 2009 (UTC)