[solved] mkgmap problem: nested else in style

Hey,

although by its manual “if statements may also be nested” w/in an mkgmap style, nested else branches threw errors for me:

1 if (...) then
2    ...
3 else
4    if (...) then
5       ...
6    else
7       ...
8    end
9 end

For line 6 in the sample above (line 168 in my lines-file)

SCHWERWIEGEND (global): Error in style: Error: (lines:168): Invalid rule, 
   #      expression cannot be indexed: $hgh:Trasse!=no & $hgh:surface!=noRace

Am I expecting too much, missing something, or should this work?

Thanks.

Greets Felix

Hard to say without a complete statement.
If your code contains something like


if (gh:surface!=noRace) then
...
else 
...
end

I wouldn’t be surprised to see such a message.

Unfortunately I do no longer have the original code. But adding to my working lines-file the following snippet

if (hgh:Trasse=no) then
   ()                   [0x01 road_class=4 level 3]
else
   if (hgh:surface=Race) then
         ()             [0x01 road_class=4 level 3]
   else
         ()             [0x01 road_class=4 level 3]
   end
end

(starting at line 142) immediately reproduces the error @ style check (although pointing to line 149; the first “end”)

The following styles are available:
SCHWERWIEGEND (global): Error in style: Error: (lines:149): Invalid rule, expression cannot be indexed: $hgh:Trasse!=no & $hgh:surface!=Race
Found one style in /home/felix/AA-Poolm/osm/Styles/HGH-BikeLayer-style
SCHWERWIEGEND (global): Error in style: Error: (lines:149): Invalid rule, expression cannot be indexed: $hgh:Trasse!=no & $hgh:surface!=Race
could not open style HGH-BikeLayer-style
finished check-styles
Mkgmap version 4806
Time started: Fri Nov 12 13:46:59 CET 2021
SCHWERWIEGEND (global): Error in style: Error: (lines:149): Invalid rule, expression cannot be indexed: $hgh:Trasse!=no & $hgh:surface!=Race

The last line is repeated quite often.

From my understanding the "!"s reflect to the “else” statements and are generated during parsing the if-construct, aren’t they?.

The error message is correct. You need at least one tag test that is not negative and the last rule has no such test.

OK, I see.
“…the only restriction is you must have at least one test that depends on a tag existing” (style manual). Wouldn’t have read that this way, but that’s it, is it not?

Thanks!

Although I would have thought, there should have been at least one not negative test in the nested else branch in the original code, it probably was exactly these simplified pair of brackets only, meant to catch the rest, that failed all former tests.
In any case,

      # Test
      ()                              {set hgh:test=yes}
      if (hgh:Trasse=no) then
            ()                        [0x01 road_class=4 level 3]
      else
         if (hgh:surface=Race) then
               ()                     [0x01 road_class=4 level 3]
         else
               hgh:test=yes           [0x01 road_class=4 level 3]
         end
      end

shure stylechecks fine.

Will reorganize my original code back to those nested ifs later and take better care…