Template:Sketch Line

From OpenStreetMap Wiki
Jump to navigation Jump to search
[Edit] [Purge] Template-info.svg Template documentation


This template can be used for inserting links to sketch diagrams of public transportation line.

To render diagrams, the lines must be tagged in OSM as route=* relations containing at least 2 Role stop nodes (or Role platform) members for stations, and at least one member way connecting them, when using the public_transport:version=2 scheme.

With the older scheme, stations will still be looked up on ways or around them using legacy tags such as highway=bus_stop or railway=tram_stop (but it may fail to locate them if they are not directly connected to the ways, in which case they are not really stops but platforms). The new scheme favors Role stop node members, preferably tagged as public_transport=stop_position and which may be multimodal (e.g. bus+tram). However multimodality is generally on other "stops" that are near the same "platform" and part of the same "stop area".

All route=* relations sharing the same specified line number (and optional network or operator) will be included in the report and combined to generate a single diagram (these route=* relations should better be members of the same route_master=* relation). The direction specified in these routes is also taken into account.

The SVG sketch diagrams are generated by the German Overpass API instance.


  • {{Sketch Line|ref|network}}
    Simplest form for use in plain-text as an external standard link (no coloring, only display the ref number).
  • {{Sketch Line|ref|network|style|
    Enhanced form showing colored line labels.
  • {{Sketch Line|ref|network=network|operator=operator|correspondences=correspondences|
    Full syntax with all supported parameters for tuning the generated sketch diagrams.

Data selection parameters

  • ref (required) – line number as specified in the ref=* tag of route=* relations.
  • network (optional) – network name as specified in the network=* tag of route=* relations.
  • operator (optional) – operator name as specified in the operator=* tag of route=* relations.
  • correspondences (optional) – A nonempty value in this field tunes the search for displaying more correspondences. This slows down the response times but gives more information. The value is interpreted as maximum acceptable distance in meters between two stations or stops to still be acceptable for changing vehicles. The default value is 100. Setting this parameter to 0 will completely disable the addition of correspondances (and will slightly accelerate response times). Note that the search of correspondances is completely disabled in the default style (see below).

You should select either an operator or network, or both, as the ref line number alone is very frequently ambiguous around the world. Note that some networks are managing distinct routes for lines with the same reference number, but with distinct operators.

Presentation parameters

tuning the generated SVG sketch diagram
  • style (optional) – A template to be used with certain display definitions, such as common abbreviations for names and automatic insertion of some connecting lines. Currently, the following style templates are defined (new ones can be added on request):
    • The default (empty) value has generic settings (also uses the English language; the search for correspondances is completely disabled).
    • padua has specific settings for Italy (also uses the Italian language; the search for correspondances is completely disabled).
    • paris has specific settings for Paris (also uses the French language; the search for correspondances to display is enabled by default and can be tuned).
    • wuppertal has specific settings for Germany (also uses the German language; the search for correspondances to display is enabled by default and can be tuned).
  • width (optional) – A number specifying the maximum display width in pixels of the generated SVG diagram (above this threshold, it will be split on several rows). The default value is 700.
  • height (optional) – A number specifying the maximum height in pixels of the generated SVG diagram. The default value is 495.
  • force-rows – This field can have values 1 or 2 or can be empty. If it is empty, the generator chooses whether to display the line in one or two rows. If it is set to 1 resp. 2, the generator displays the line in an case in one resp. two rows.
  • font-size (optional) – The font size in pixels for the stopname in the generated SVG. The default value is empty: this means that the generator takes font size is 16 for lines displayed on one row, or 10 for lines displayed on two rows.
  • max-cors-per-line (optional) – The limit for the acceptable number of line numbers to be printed per row. This option is only effective when correspondences are enabled. The default value is 6.
  • max-cors-below (optional) – The limit for the acceptable number of line numbers to be printed below the line bar. This option is only effective when correspondences are enabled. The default value is 0.
changing the display style for the label inserted in the wiki page
  • bg (optional) – Main background color of the line: used as background color for the displayed label (otherwise "transparent" by default to display the page background).
  • fg (optional) – Contrasting foreground color of the line: used as foreground color for the displayed label, usually #000 or #FFF (otherwise "inherit" by default to display the usual color for links).
  • b (optional) – Contrasting border color of the line: used as the color of the thin border box around the background of the displayed label, usually unset or grey if the background is white (otherwise "transparent" by default to display the background color). If a non transparent border is specified, the font-size of the label will be slightly reduced to 95% to avoid external expansion of rendered line height caused by the thin margin, border and padding.
  • r (optional) – Any non-empty value will display a rounded label instead of a rectangular one (this parameter has no effect if there's no border and/or background colors specified). The internal horizontal padding of the box will be automatically increased to avoid collision of the internal label with these rounded corners.
  • line (optional) – Label to display for the line number when it does not match exactly the line reference number in ref=* tag.
  • thin (optional) – Any non-empty value will display text without bold.
  • external (optional) – Any non-empty value will display icone for external link.


  • {{Sketch Line|95|ATM}} produces 95.
  • {{Sketch Line|95|ATM|thin=1|external=1}} produces 95.
  • {{Sketch Line|1|AMI Ferrara|padua|bg=#2c8839|fg=#FFF|b=transparent|r=1}} produces 1.
  • {{Sketch Line|625|VRR|wuppertal|bg=yellow|fg=black|b=orange}} produces 625.
  • {{Sketch Line|625|VRR|wuppertal|width=2000|bg=#51772c|fg=white}} produces 625.
  • {{Sketch Line|KL|FR:STAR|style=paris|bg=#FD0|fg=#3D3C3F|b=#3D3C3F|r=1|line=KER<small>LANN</small><sub>ex</sub>}} produces KERLANNex.
  • {{Sketch Line|T8|RATP|paris|bg=#FFF|fg=#333|b=#DDD}} produces T8.

Known bugs

As of Overpass API v0.7.52, support for Public transport v2 has some known issues, resulting in

  • Duplicate stop names (See Github issue #190), when:
    • the Role stop and Role platform members are present together in the type=route relation, but the Role platform member (tagged as public_transport=platform+bus=yes) is still tagged with the legacy highway=bus_stop
    • or when stops and platforms in one direction do not match geographically between directions/variants routes of a line (i.e. they are not within a reasonnable distance : you can tune it using the correspondences= parameter with the styles supporting it; see above) ;
  • Some gaps, when:
    • only a Role platform member is present in the type=route relation (tagged as public_transport=platform+bus=yes) but without the legacy highway=bus_stop, and there's no matching Role stop member (tagged with public_transport=stop_position).
    • Closed circuits or any line where the same stop appears twice are incorrectly rendered: these stops are not displayed at all and not even connected, when these stops should be kept (optionally with an additional joining loop below the diagram. See Github issue #279.
  • If the stops on the line have their names in the stop_area instead of in the stop_position, these names are not shown. See Github issue #275.

Other limitations or unimplemented features

  • Note that Public transport v2 normally associate "stop" and "platform" members (and other related members for local buildings, services, or accesses to stations) within a type=public transport+public transport=stop area relation, which is still ignored by Overpass API and could cleanly eliminate duplicates or missing stops.
  • When using legacy public transport schemes, the routes may show a single direction even if member ways don't use a forward or backward rule to restrict them. With PTv2, routes are normally separated for each direction. The current version completely ignores the actual directions when there are multiple routes (the from=* and to=* values of the first route relation found is assumed, otherwise the first and last stop or platform members).
  • As well, type=route_master relations are ignored: all matching type=route relations found in OSM will be simply merged together to find variants and directions (this means that variants are not always correctly separated as they should on the diagrams). There's still no way to select a single variant or direction for lines that have multiple route variants or for most lines that have two directions.
  • The diagrams only use a single colour for the diagram and incorrectly uses same colour for the text of line numbers over a transparent (white) background, but ignores the text_colour which should be used to render the text over a background frame matching the line colour. In rare cases, the line color is also the text color, not its background, which may be white; also OSM currently has no data to add a surrounding border color or distinguish them by shape (square/rectangular, or circle/oval). This would be necessary notably for clearly showing correspondences beside stop names.

See also