Osmarender/OldSymbolsFormat

From OpenStreetMap Wiki
Jump to navigation Jump to search

IMPORTANT - Read this first!!

This page describes old format of Osmareneder symbols. It is still supported but no longer necessary. For easier way to use symbols see Osmarender/Symbols

Convert SVGs for use in Osmarender

First, open the SVG in a text editor so you can see the code. Scroll past the cruft put in by your SVG editor until you find the path definitions that will look something like this:

 <path style="stroke:#eeeeee; stroke-width:3; stroke-linecap:butt; stroke-linejoin:miter;
              stroke-miterlimit:4; stroke-dasharray:none; stroke-opacity:1"
   d="M 19.4,4.6 C 19.4,31.5 19.4,31.5 19.4,31.5"
   id="path11206" />

This can then be converted into a symbol definition:

 <svg:symbol id="pointless_node" viewBox="0 0 10 10">
   <svg:path d="M 19.4,4.6 C 19.4,31.5 19.4,31.5 19.4,31.5" style="stroke:#eeeeee" />
 </svg:symbol>

Finally, you need a rule for rendering the pointless line:

 <rule e="node" k="amenity" v="pointless_node">
   <symbol xlink:href="#pointless_node" width='2.5' height='2.5' transform='translate(-1.25,-1.25)' />
 </rule> 

Enter both the rule and the symbol definition into the rules file and you should be ready to roll!

Its probably self-explanatory, but here is an explanation of the code for the rules. Taking the example of the rule above, the first line determines what OSM feature will have the symbol displayed for it (ie any node with the key/value pair amenity=pointless_node). The second line determines what size the symbol is displayed at, in this instance 2.5 pixels square (for practical examples of relative sizes look at existing symbols, and decide whether the symbol you want displayed would be larger or smaller - in the case of hospitals below I decided that they (i) were relatively important and so should be displayed a lower zoom levels; and (ii) tended to occupy a large area; then they should be displayed as a relatively large symbol), then by translating the position half the width and half the height, you center the symbol over the relevant node.

Symbol format in the symbols directory

Airport-symbol.png

NOTE: This page describes old format of Osmareneder symbols. It is still supported but no longer necessary. For easier way to use symbols see Osmarender/Symbols



All symbols must be in SVG format, here are the details:

  • A file with only the symbol itself in it included in a <svg/> and <defs/> tag.
  • A unique ID in the id attribute of the symbol element which must start with symbol-.
  • A viewBox attribute which makes sure the symbol is centered and sized correctly. All symbols should be exactly 1x1 units of size and the point (0,0) should be the middle of your icon. That way all symbols are the same size by default and positioned correctly centered on a node. When symbols are used later they can be resized or otherwise transformed if symbols of different size are desired.

Here is an example:

 <?xml version="1.0" encoding="utf-8"?>
 <svg xmlns="http://www.w3.org/2000/svg">
   <defs>
     <symbol
       id="symbol-airport"
       viewBox="5 5 10 10"
       fill="black"
       fill-opacity="1"
       fill-rule="evenodd"
       stroke="none">
       <path d="M 9.2,5 C 9.2,4.5 9.8,3.2 10,3 L 9,3 L 8,4 L 5.5,4
                L 8,0 L 6,0 L 3,4 C 2,4 1,4.2 0.5,4.5 C 0,5 0,5 0.5,5.5
                C 1,5.8 2,6 3,6 L 6,10 L 8,10 L 5.5,6 L 7.8,6 L 9,7
                L 10,7 C 9.8,6.8 9.2,5.5 9.2,5 z " />
     </symbol>
   </defs>
 </svg>