[solved] Including from another style

Including files from within a style (dir or subdir) works fine, but I can’t make including from another style work as expected.

From the style manual:

Let’s assume a dir “MyStyles” with two subdirs “Style1” and “Style2”, referenced for mkgmap by “–style-file=/…/MyStyles” and “style=Style1” for example. Both styles get listed due to “–list-styles”.

Including a file “MyInclude” from within Style1’s line-file directly from Style1 or from a subdir “/inc/MyInclude” works as expected.

But having statements like

include "MyInclude" from Style1;
include "/inc/MyInclude" from Style1;

in Style2’s line-file fails either way with error output like

SCHWERWIEGEND (global): Error in style: Error: (lines:225): Cannot find style: Style1

This does neither work using full path’s for Style1 using from, nor directly for MyInclude.

Hence I do neither understand the manuals

Actually I’m looking for means to nonredundantly share a block between styles, hence would prefer to have “MyInclude” separately and not as part of one style anyway.

Referencing a link “/style2/LinkToMyIncludeFromStyle1” pointing to “MyInclude” under Style1 in the include statement of Style2’s lines-file (include “LinkToMyIncludeFromStyle1”:wink: does work for the sample above and such might even serve to provide a separate location for include blocks.

But still: What am I misunderstanding or doing wrong following the manual?



I’ve never done it, but the source shows different syntax, so maybe the doc is wrong. Did you try one of these alternatives?

include /inc/MyInclude from Style1;
include '/inc/MyInclude' from Style1;

As the double tiks struck me as odd I tried numerous variations w/ and w/o single ticks and w/ and w/o leading and trailing slashes. No dice.

SCHWERWIEGEND (global): Error in style: Error: (lines:260): Stack size is 10 (missing or incomplete expression)
SCHWERWIEGEND (global): Error in style: Error: (lines:233): Cannot find style: ...

From my perspective referencing another style is suboptimal anyway. I would prefer parsing relative (to the calling style) or full path’s here.


In the meantime I found an example for shared rules in https://github.com/aiomaster/aiostyles/
The main style files contain lots of shared includes. Hope this helps.


I was able to grepfind “include” in two spots only in master: build.xml and Makefile.
Git is not my realm though.

You are right, these sources don’t match the one that I have on my machine. Have to search longer to find out where the repo is…

Thought as much :wink:

Or just quote a sample or relay a functioning syntax?

Sitting on another machine right now. The main difference to your method was that directory inc was at the same level as the different style directories and something like
include …/inc/foo
include …/inc/bah
in the lines file.

Jep, that seems to parse (quick shot only).

AND, quite well matches, what I was asking for.

Should have tried that in the first place…
Did try

to no avail though.

And if there was a topical version of that repo available somewhere, I’d certainly be interested…


Upon trying to cleanup the testing code this syntax too does NOT work for me.
Maybe I have run mkgmap on unsaved style edits…

Spent more time already on further trials and errors.

Gerd, would you mind to lookup working syntax from that other repo or the code for me?


Scratch that please. Sorry.

After spending plenty of time (quite poorly) trying to figure out

private boolean readInclude(StyleFileLoader currentLoader, TokenScanner scanner)

from RuleFileReader.java, I cleaned up my tests more thoroughly and made

include "../inc/MyInclude";

work again.

I guess I had missed one of the workaround links.