Opened 10 years ago

Closed 10 years ago

#1463 closed defect (fixed)

Style: Icon path relative to style file

Reported by: LonelyPixel Owned by: cbro@…
Priority: minor Milestone:
Component: merkaartor Version:
Keywords: Cc:


If you select an icon to be drawn in a style, you can select some cryptic name from the internal representation of the more or less organised embedded icons. The file structure can only be known if you look hard into the source code. If you want to create or edit your own style and use more icons, it's very hard to enter these virtual file names. Supplying your own files is also hard, because you need to enter absolute pathnames. But how do you know where somebody will copy the images to your style? (Absolute path names can never be portable.)

Here's the solution: If the icon filename specification does not contain a backslash or slash (both are required features of an absolute path specification), the path of the style file is prepended. So you can just enter the icon's filename without a path, copy it in the same directory as your style (.mas) file (or in a subdirectory) and you're done.

The current situation is that if you don't enter an absolute path, the icon is loaded from the current directory - whichever that is. (At least that's what I suppose after reading the original source code. I haven't bothered finding out where that path is.)

Also, when you save a style back into a file, all absolute icon filenames that have the same path as the style file to write, the path is cut off so that only the filename is written. This keeps filenames portable when saving the style. But it'll only work if the image files are in the very same directory as the style file to be written. More logic could be used here to detect subdirectories. Maybe I'll still do that.

This also has the effect that the style is fully portable and can be given to and edited by other Merkaartor users, including all icons.

Attachments (1)

code.diff (3.0 KB) - added by LonelyPixel 10 years ago.
Patch of my proposed implementation

Download all attachments as: .zip

Change History (3)

Changed 10 years ago by LonelyPixel

Attachment: code.diff added

Patch of my proposed implementation

comment:1 Changed 10 years ago by LonelyPixel

Beware, Trac only shows the first and the last of the three patched files in its HTML preview of the patch. Something must be broken in there.

comment:2 Changed 10 years ago by Chris Browet

Resolution: fixed
Status: newclosed

(In [13150]) ADD : Save relative icon filenames in map styles if not builtin (closes #1463)

Note: See TracTickets for help on using tickets.