#!/usr/bin/perl ### bs2svg - convert a route diagram to an SVG image. ### Copyright (C) 2008 ja:Matsukaze ### ### This program is free software; you can redistribute it and/or ### modify it under the terms of the GNU General Public License ### as published by the Free Software Foundation; either version 2 ### or version 3. ### ### This program is distributed in the hope that it will be useful, ### but WITHOUT ANY WARRANTY; without even the implied warranty of ### MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ### GNU General Public License for more details. use Getopt::Std; # data %symbol=( "undefined" => < EOS "leer" => < EOS "S" => < EOS "tS" => < EOS "C" => < EOS "tC" => < EOS "BS2lf" => < EOS "BS2cro" => < EOS "tBS2lf" => < EOS "tBS2cro" => < EOS "TN" => < EOS "TN2" => < EOS "CROSS" => < EOS "tCROSS" => < EOS "LUECKE" => < EOS "STP" => < EOS "STA" => < EOS "STAr" => < EOS "DST" => < EOS "ACC" => < EOS "ACC2" => < EOS "SBHF" => < EOS "INT" => < EOS "INTl" => < EOS "INTm" => < EOS "CPI" => < EOS "CPIl" => < EOS "H" => < EOS "tH" => < EOS "PORTAL" => < EOS "E" => < EOS "El" => < EOS "Erc" => < EOS "Esc" => < EOS "EC" => < EOS "Es" => < EOS "B" => < EOS "B1" => < EOS "B2" => < EOS "W" => < EOS "OVERPASS" => < EOS "HIGHWAYde" => < EOS "HIGHWAYuk" => < EOS "ONEWAY" => < EOS "tONEWAY" => < EOS "KMW" => < EOS "GRENZE" => < EOS "eGrenze" => < EOS "SUMMIT" => < EOS "BUE1" => < EOS "BUE2" => < EOS "BUE" => < EOS "END" => < EOS "eEND" => < EOS "FLUG" => < EOS "eFLUG" => < EOS "SHIP" => < EOS "eSHIP" => < EOS "Cul" => < EOS "tCul" => < EOS "Cur" => < EOS "tCur" => < EOS "Crd" => < EOS "tCrd" => < EOS "Cld" => < EOS "tCld" => < EOS "BS2rf" => < EOS "BS2lg" => < EOS "BS2rg" => < EOS "BS2clo" => < EOS "BS2cru" => < EOS "BS2clu" => < EOS "tBS2rf" => < EOS "tBS2lg" => < EOS "tBS2rg" => < EOS "tBS2clo" => < EOS "tBS2cru" => < EOS "tBS2clu" => < EOS "TNs" => < EOS "INTr" => < EOS "CPIr" => < EOS ); %depend=( "BUE" => [ "BUE1", "BUE2" ], "TN" => [ "tS" ], "TN2" => [ "tS" ], "Cul" => [ "C" ], "tCul" => [ "tC" ], "Cur" => [ "C" ], "tCur" => [ "tC" ], "Crd" => [ "C" ], "tCrd" => [ "tC" ], "Cld" => [ "C" ], "tCld" => [ "tC" ], "BS2rf" => [ "BS2lf" ], "BS2lg" => [ "BS2lf" ], "BS2rg" => [ "BS2lf" ], "BS2clo" => [ "BS2cro" ], "BS2cru" => [ "BS2cro" ], "BS2clu" => [ "BS2cro" ], "tBS2rf" => [ "tBS2lf" ], "tBS2lg" => [ "tBS2lf" ], "tBS2rg" => [ "tBS2lf" ], "tBS2clo" => [ "tBS2cro" ], "tBS2cru" => [ "tBS2cro" ], "tBS2clu" => [ "tBS2cro" ], "TNs" => [ "H", "tH", "PORTAL" ], "INTr" => [ "INTl" ], "CPIr" => [ "INTr" ] ); %table=( "leer" => [ ["leer"] ], "STR" => [ ["S"] ], "eSTR" => [ ["S"],"e" ], "HSTR" => [ ["S","",90] ], "LUECKE" => [ ["LUECKE"] ], "ELEV" => [ ["E"], ["S"] ], "HLUECKE" => [ ["LUECKE","",90] ], "HELEV" => [ ["E","",90], ["S","",90] ], "STRu" => [ ["S"], ["ONEWAY","",180] ], "tSTRu" => [ ["tS"], ["tONEWAY","",180,1] ], "texSTRu" => [ ["tS","e"], ["tONEWAY","e",180,1] ], "STRd" => [ ["S"], ["ONEWAY"] ], "STRl" => [ ["S","",90], ["ONEWAY","",90] ], "STRr" => [ ["S","",90], ["ONEWAY","",270] ], "tSTRr" => [ ["tS","",90], ["tONEWAY","",270,1] ], "texSTRr" => [ ["tS","e",90], ["tONEWAY","e",270,1] ], "BHF" => [ ["S"], ["STA"] ], "eBHF" => [ ["S"], ["STA","e"] ], "KBFa" => [ ["H"], ["STA"] ], "xKBFa" => [ ["H"], ["H","e",180], ["STA"] ], "KBFe" => [ ["H","",180], ["STA"] ], "xKBFe" => [ ["H","",180], ["H","e"], ["STA"] ], "BHF-ELEV" => [ ["E"], ["S"], ["STA"] ], "eBHF-ELEV" => [ ["E"], ["S"], ["STA","e"] ], "KBFa-ELEV" => [ ["Es"], ["H"], ["STA"] ], "KBFe-ELEV" => [ ["Es","",180], ["H","",180], ["STA"] ], "BHFl" => [ ["H","",90], ["STA"] ], "xBHFl" => [ ["H","",90], ["H","e",270], ["STA"] ], "BHFr" => [ ["H","",270], ["STA"] ], "xBHFr" => [ ["H","",270], ["H","e",90], ["STA"] ], "HBHF" => [ ["S","",90], ["STA"] ], "eHBHF" => [ ["S","",90], ["STA","e"] ], "HBHF-ELEV" => [ ["E","",90], ["S","",90], ["STA"] ], "eHBHF-ELEV" => [ ["E","",90], ["S","",90], ["STA","e"] ], "BHFl-ELEV" => [ ["Es","",90], ["H","",90], ["STA"] ], "BHFr-ELEV" => [ ["Es","",270], ["H","",270], ["STA"] ], "KBFl" => [ ["C","",90], ["C","",180], ["STAr"] ], "xKBFl" => [ ["C","e",90], ["C","",180], ["STAr"] ], "eKBFl" => [ ["STAr","e"], ["C","",90], ["C","",180] ], "KBFr" => [ ["C"], ["C","",270], ["STAr","",180] ], "xKBFl" => [ ["C","e"], ["C","",270], ["STAr","",180] ], "eKBFl" => [ ["STAr","e",180], ["C"], ["C","",270] ], "DST" => [ ["S"], ["DST"] ], "eDST" => [ ["S"], ["DST","e"] ], "HDST" => [ ["S","",90], ["DST"] ], "eHDST" => [ ["S","",90], ["DST","e"] ], "KDSa" => [ ["H"], ["DST"] ], "xKDSa" => [ ["H"], ["H","e",180], ["DST"] ], "KDSe" => [ ["H","",180], ["DST"] ], "xKDSe" => [ ["H","",180], ["H","e"], ["DST"] ], "KDSl" => [ ["H","",90], ["DST"] ], "xKDSl" => [ ["H","",90], ["H","e",270], ["DST"] ], "KDSr" => [ ["H","",270], ["DST"] ], "xKDSr" => [ ["H","",270], ["H","e",90], ["DST"] ], "HST" => [ ["S"], ["STP"] ], "eHST" => [ ["S"], ["STP","e"] ], "HSTa" => [ ["H"], ["STP"] ], "xHSTa" => [ ["H"], ["H","e",180], ["STP"] ], "HSTe" => [ ["H","",180], ["STP"] ], "xHSTe" => [ ["H","",180], ["H","e"], ["STP"] ], "HST-ELEV" => [ ["E"], ["S"], ["STP"] ], "eHST-ELEV" => [ ["E"], ["S"], ["STP","e"] ], "HSTl" => [ ["H","",90], ["STP"] ], "xHSTl" => [ ["H","",90], ["H","e",270], ["STP"] ], "HSTr" => [ ["H","",270], ["STP"] ], "xHSTr" => [ ["H","",270], ["H","e",90], ["STP"] ], "HHST" => [ ["S","",90], ["STP"] ], "eHHST" => [ ["S","",90], ["STP","e"] ], "ACC" => [ ["S"], ["ACC"] ], "ACCa" => [ ["H"], ["ACC"] ], "xACCa" => [ ["H"], ["H","e",180], ["ACC"] ], "ACCe" => [ ["H","",180], ["H","e"], ["ACC"] ], "HACC" => [ ["S","",90], ["ACC"] ], "TurmBHFo" => [ ["S","",90],["B1"],["S"],["STP"] ], "xTurmBHFo" => [ ["S","",90],["B1"],["S","e"],["STP"] ], "eTurmBHFo" => [ ["S","e",90],["B1"],["S"],["STP"] ], "uTurmBHFo" => [ ["S","",90],["B1"],["S","u"],["STP","u"] ], "TurmBHFu" => [ ["S"],["B1","",90],["S","",90],["STP"] ], "xTurmBHFu" => [ ["S","e"],["B1","",90],["S","",90],["STP"] ], "eTurmBHFu" => [ ["S"],["B1","",90],["S","e",90],["STP"] ], "uTurmBHFu" => [ ["S","u"],["B1","",90],["S","",90],["STP"] ], "UTurmBHFo" => [ ["S","u",90],["B1"],["S"],["STP"] ], "xUTurmBHFo" => [ ["S","u",90],["B1"],["S","e"],["STP"] ], "eUTurmBHFo" => [ ["S","ue",90],["B1"],["S"],["STP"] ], "UTurmBHFAo" => [ ["S","u",90],["B1"],["S"],["ACC2"] ], "UTurmBHFu" => [ ["S"],["B1","",90],["S","u",90],["STP","u"] ], "xUTurmBHFu" => [ ["S","e"],["B1","",90],["S","u",90],["STP","u"] ], "eUTurmBHFu" => [ ["S"],["B1","",90],["S","ue",90],["STP"] ], "UTurmBHFAu" => [ ["S"],["B1","",90],["S","u",90],["ACC2"] ], "KRZo" => [ ["S","",90], ["B1"], ["S"] ], "xKRZo" => [ ["S","",90], ["B1"], ["S","e"] ], "eKRZo" => [ ["S","e",90], ["B1"], ["S"] ], "uKRZo" => [ ["S","",90], ["B1"], ["S"] ], "uxKRZo" => [ ["S","",90], ["B1"], ["S","u"] ], "ueKRZo" => [ ["S","",90], ["B1"], ["S","ue"] ], "uexKRZo" => [ ["S","e",90], ["B1"], ["S","ue"] ], "KRZu" => [ ["S"], ["B1","",90], ["S","",90] ], "xKRZu" => [ ["S","e"], ["B1","",90], ["S","",90] ], "eKRZu" => [ ["S"], ["B1","",90], ["S","e",90] ], "uKRZu" => [ ["S","u"], ["B1","",90], ["S","",90] ], "uxKRZu" => [ ["S","ue"], ["B1","",90], ["S","",90] ], "ueKRZu" => [ ["S","u"], ["B1","",90], ["S","e",90] ], "uexKRZu" => [ ["S","ue"], ["B1","",90], ["S","e",90] ], "KRZo-ELEV" => [ ["S","",90], ["E"], ["S"] ], "xKRZo-ELEV" => [ ["S","",90], ["E"], ["S","e"] ], "eKRZo-ELEV" => [ ["S","e",90], ["E"], ["S"] ], "uKRZo-ELEV" => [ ["S","",90], ["E"], ["S","u"] ], "uxKRZo-ELEV" => [ ["S","",90], ["E"], ["S","ue"] ], "ueKRZo-ELEV" => [ ["S","e",90], ["E"], ["S","u"] ], "uexKRZo-ELEV" => [ ["S","e",90], ["E"], ["S","ue"] ], "HKRZo-ELEV" => [ ["S"], ["E","",90], ["S","",90] ], "xHKRZo-ELEV" => [ ["S","e"], ["E","",90], ["S","",90] ], "eHKRZo-ELEV" => [ ["S"], ["E","",90], ["S","e",90] ], "uHKRZo-ELEV" => [ ["S","u"], ["E","",90], ["S","",90] ], "uxHKRZo-ELEV" => [ ["S","ue"], ["E","",90], ["S","",90] ], "ueHKRZo-ELEV" => [ ["S","u"], ["E","",90], ["S","e",90] ], "uexHKRZo-ELEV" => [ ["S","ue"], ["E","",90], ["S","e",90] ], "UKRZo" => [ ["S","u",90], ["B1"], ["S"] ], "xUKRZo" => [ ["S","u",90], ["B1"], ["S","e"] ], "tUKRZo" => [ ["tS","",90], ["B1"], ["tS"] ], "eUKRZo" => [ ["S","ue",90], ["B1"], ["S"] ], "UKRZu" => [ ["S"], ["B1","",90], ["S","u",90] ], "xUKRZu" => [ ["S","e"], ["B1","",90], ["S","u",90] ], "tUKRZu" => [ ["tS"], ["B1","",90], ["tS","",90] ], "eUKRZu" => [ ["S"], ["B1","",90], ["S","ue",90] ], "KRZ" => [ ["S","",90], ["S"] ], "xKRZ" => [ ["S","e"], ["S","",90] ], "tKRZ" => [ ["tS"], ["S","",90] ], "eKRZ" => [ ["S","e",90], ["S"] ], "KRZt" => [ ["tS","",90], ["S"] ], "xKRZt" => [ ["S","e"], ["tS","",90] ], "eKRZt" => [ ["tS","e",90], ["S"] ], # "KRZArg" => "KRZBHF" => [ ["S"], ["S","",90], ["STA"] ], "KRZlfg" => [ ["C","",270], ["C","",90], ["S","",90], ["S"] ], "INT" => [ ["S"], ["INT"] ], "INTa" => [ ["H"], ["INT"] ], "xINTa" => [ ["H"], ["H","e",180], ["INT"] ], "INTe" => [ ["H","",180], ["INT"] ], "xINTe" => [ ["H","",180], ["H","e"], ["INT"] ], "INTl" => [ ["S"], ["INTl"] ], "INTla" => [ ["H"], ["INTl"] ], "xINTla" => [ ["H"], ["H","e",180], ["INTl"] ], "INTle" => [ ["H","",180], ["INTl"] ], "xINTle" => [ ["H","",180], ["H","e"], ["INTl"] ], "INTr" => [ ["S"], ["INTl","",180] ], "INTra" => [ ["H"], ["INTl","",180] ], "xINTra" => [ ["H"], ["H","e",180], ["INTl","",180] ], "INTre" => [ ["H","",180], ["INTl","",180] ], "xINTre" => [ ["H","",180], ["H","e"], ["INTl","",180] ], "INTm" => [ ["S"], ["INTm"] ], "INTma" => [ ["H"], ["INTm"] ], "xINTma" => [ ["H"], ["H","e",180], ["INTm"] ], "INTme" => [ ["H","",180], ["INTm"] ], "xINTme" => [ ["H","",180], ["H","e"], ["INTm"] ], "SBHF" => [ ["S"], ["SBHF"] ], "CPIC" => [ ["CPI"] ], "CPICl" => [ ["CPIl"], ["S"], ["STA"] ], "eCPICl" => [ ["CPIl"], ["S"], ["STA","e"] ], "CPICm" => [ ["CPI"], ["S"], ["STA"] ], "eCPICm" => [ ["CPI"], ["S"], ["STA","e"] ], "CPICr" => [ ["CPIl","",180], ["S"], ["STA"] ], "eCPICr" => [ ["CPIl","",180], ["S"], ["STA","e"] ], "CPICla" => [ ["CPIl"], ["H"], ["STA"] ], "xCPICla" => [ ["CPIl"], ["H"], ["H","e",180], ["STA"] ], "CPICma" => [ ["CPI"], ["H"], ["STA"] ], "xCPICma" => [ ["CPI"], ["H"], ["H","e",180], ["STA"] ], "CPICra" => [ ["CPIl","",180], ["H"], ["STA"] ], "xCPICra" => [ ["CPIl","",180], ["H"], ["H","e",180], ["STA"] ], "CPICle" => [ ["CPIl"], ["H","",180], ["STA"] ], "xCPICle" => [ ["CPIl"], ["H","",180], ["H","e"], ["STA"] ], "CPICme" => [ ["CPI"], ["H","",180], ["STA"] ], "xCPICme" => [ ["CPI"], ["H","",180], ["H","e"], ["STA"] ], "CPICre" => [ ["CPIl","",180], ["H","",180], ["STA"] ], "xCPICre" => [ ["CPIl","",180], ["H","",180], ["H","e"], ["STA"] ], "CPICpasso" => [ ["CPI"], ["S"] ], "CPICpassu" => [ ["S"], ["CPI"]], # "vBHF" => # "vKBFa" => # "vKBFe" => "CPICAl" => [ ["CPIl"], ["S"], ["ACC"] ], "CPICAm" => [ ["CPI"], ["S"], ["ACC"] ], "CPICAr" => [ ["CPIl","",180], ["S"], ["ACC"] ], "CPICAla" => [ ["CPIl"], ["H"], ["ACC"] ], "CPICAma" => [ ["CPI"], ["H"], ["ACC"] ], "CPICAra" => [ ["CPIl","",180], ["H"], ["ACC"] ], "CPICAle" => [ ["CPIl"], ["H","",180], ["ACC"] ], "CPICAme" => [ ["CPI"], ["H","",180], ["ACC"] ], "CPICAre" => [ ["CPIl","",180], ["H","",180], ["ACC"] ], "ABZlf" => [ ["C","",90], ["S"] ], "xABZlf" => [ ["S","e"], ["C","",90] ], "eABZlf" => [ ["C","e",90], ["S"] ], "ABZrf" => [ ["C"], ["S"] ], "xABZrf" => [ ["S","e"], ["C"] ], "eABZrf" => [ ["C","e"], ["S"] ], "ABZlg" => [ ["C","",270], ["S"] ], "xABZlg" => [ ["S","e"], ["C","",270] ], "eABZlg" => [ ["C","e",270], ["S"] ], "ABZrg" => [ ["C","",180], ["S"] ], "xABZrg" => [ ["S","e"], ["C","",180] ], "eABZrg" => [ ["C","e",180], ["S"] ], "ABZrl" => [ ["C"], ["C","",90] ], "xABZrl" => [ ["C","e",90], ["C"] ], "eABZrl" => [ ["C","e"], ["C","",90] ], "ABZlr" => [ ["C","",270], ["C","",180] ], "xABZlr" => [ ["C","e",270], ["C","",180] ], "eABZlr" => [ ["C","e",180], ["C","",270] ], "ABZgf" => [ ["C"], ["C","",270] ], "xABZgf" => [ ["C","e",270], ["C"] ], "eABZgf" => [ ["C","e"], ["C","",270] ], "ABZfg" => [ ["C","",90], ["C","",180] ], "xABZgf" => [ ["C","e",180], ["C","",90] ], "eABZgf" => [ ["C","e",90], ["C","",180] ], "ABZ3rf" => [ ["C"], ["S","",90] ], "xABZ3rf" => [ ["S","e",90], ["C"] ], "eABZ3rf" => [ ["C","e"], ["S","",90] ], "ABZ3lg" => [ ["C","",270], ["S","",90] ], "xABZ3lg" => [ ["S","e",90], ["C","",270] ], "eABZ3lg" => [ ["C","e",270], ["S","",90] ], "ABZ3lf" => [ ["C","",90], ["S","",90] ], "xABZ3lf" => [ ["S","e",90], ["C","",90] ], "eABZ3lf" => [ ["C","e",90], ["S","",90] ], "ABZ3rg" => [ ["C","",180], ["S","",90] ], "xABZ3rg" => [ ["S","e",90], ["C","",180] ], "eABZ3rg" => [ ["C","e",180], ["S","",90] ], "ABZlfg" => [ ["C","",90], ["C","",270], ["S"] ], "eABZlfg" => [ ["C","e",90], ["C","e",270], ["S"] ], "ABZrfg" => [ ["C"], ["S"], ["C","",180] ], "eABZrfg" => [ ["C","e"], ["C","e",180], ["S"] ], "ABZld" => [ ["C","",90], ["C","",180], ["S"] ], "xABZld" => [ ["C","e",180], ["S","e"], ["C","",90] ], "eABZld" => [ ["C","e",90], ["C","e",180],["S"] ], "ABZrd" => [ ["C"], ["C","",270], ["S"] ], "xABZrd" => [ ["C","e",270], ["S","e"], ["C"] ], "eABZrd" => [ ["C","e"], ["C","e",270],["S"] ], "ABZ_ld" => [ ["C","e",180], ["C","",90], ["S"] ], "xABZ_ld" => [ ["C","e",90], ["S","e"], ["C","",180] ], "eABZ_ld" => [ ["C","",180], ["S","e"], ["C","",90] ], "exABZ_ld" => [ ["C","e",90], ["C","",180], ["S"] ], "ABZ_rd" => [ ["C","e"], ["C","",270], ["S"] ], "xABZ_rd" => [ ["C","e"], ["S","e"], ["C","",270] ], "eABZ_rd" => [ ["C","",270], ["S","e"], ["C"] ], "exABZ_rd" => [ ["C","e"], ["C","",270], ["S"] ], # "ABZa" => # "ABZe" => "ABZrd-ELEV" => [ ["El","",180], ["Erc"], ["Erc","",270], ["S"], ["C"], ["C","",270] ], "ABZlf-ELEV" => [ ["El"], ["Erc","",90], ["Esc","",180], ["S"], ["C","",90] ], "xABZlf-ELEV" => [ ["El"], ["Erc","",90], ["Esc","",180], ["S","e"], ["C","",90] ], "eABZlf-ELEV" => [ ["El"], ["Erc","",90], ["Esc","",180], ["C","e",90], ["S"] ], "ABZrf-ELEV" => [ ["El","",180], ["Erc"], ["Esc","",270], ["S"], ["C"] ], "xABZrf-ELEV" => [ ["El","",180], ["Erc"], ["Esc","",270], ["S","e"], ["C"] ], "eABZrf-ELEV" => [ ["El","",180], ["Erc"], ["Esc","",270], ["C","e"], ["S"] ], "ABZlg-ELEV" => [ ["El","",180], ["Esc"], ["Erc","",270], ["S"], ["C","",270] ], "xABZlg-ELEV" => [ ["El","",180], ["Esc"], ["Erc","",270], ["S","e"], ["C","",270] ], "eABZlg-ELEV" => [ ["El","",180], ["Esc"], ["Erc","",270], ["C","e",270], ["S"] ], "ABZrg-ELEV" => [ ["El"], ["Esc","",90], ["Erc","",180], ["S"], ["C","",180] ], "xABZrg-ELEV" => [ ["El"], ["Esc","",90], ["Erc","",180], ["S","e"], ["C","",180] ], "eABZrg-ELEV" => [ ["El"], ["Esc","",90], ["Erc","",180], ["C","e",180], ["S"] ], "ABZdf" => [ ["C"], ["C","",90], ["S"] ], "xABZdf" => [ ["S","e"], ["C"], ["C","",90] ], "eABZdf" => [ ["C","e"], ["C","e",90],["S"] ], "ABZdrf" => [ ["C","e",90], ["C"], ["S"] ], "xABZdrf" => [ ["C","e",90],["S","e"], ["C"] ], "ABZdlf" => [ ["C","e"], ["C","",90], ["S"] ], "xABZdlf" => [ ["C","e"], ["S","e"], ["C","",90] ], "ABZdg" => [ ["C","",270], ["C","",180], ["S"] ], "xABZdg" => [ ["S","e",], ["C","",270], ["C","",180] ], "eABZdg" => [ ["C","e",270], ["C","e",180], ["S"] ], "ABZdrg" => [ ["C","e",270], ["C","",180], ["S"] ], "xABZdrg" => [ ["C","e",270], ["S","e"], ["C","",180] ], "ABZdlg" => [ ["C","e",180], ["C","",270], ["S"] ], "xABZdlg" => [ ["C","e",180], ["S","e"], ["C","",270] ], "ABZdr" => [ ["C"], ["C","",270], ["S","",90] ], "xABZdr" => [ ["S","e",90], ["C"], ["C","",270] ], "eABZdr" => [ ["C","e"], ["C","e",270], ["S","",90] ], "ABZdrr" => [ ["C","e"], ["C","",270], ["S","",90] ], "xABZdrr" => [ ["C","e"], ["S","e",90], ["C","",270] ], "ABZdrl" => [ ["C","e",270], ["C"], ["S","",90] ], "xABZdrl" => [ ["C","e",270], ["S","e",90], ["C"] ], "ABZdl" => [ ["C","",90], ["C","",180], ["S","",90] ], "xABZdl" => [ ["S","e",90], ["C","",90], ["C","",180] ], "eABZdl" => [ ["C","e",90], ["C","e",180], ["S","",90] ], "ABZdlr" => [ ["C","e",90], ["C","",180], ["S","",90] ], "xABZdlr" => [ ["C","e",90], ["S","e",90], ["C","",180] ], "ABZdll" => [ ["C","e",180], ["C","",90], ["S","",90] ], "ABZdll" => [ ["C","e",180], ["S","e",90], ["C","",90] ], "uABZdrl3" => [ ["S","u",90], ["C","e",270], ["C"] ], "STRlf" => [ ["C","",90] ], "STRrf" => [ ["C"] ], "STRlg" => [ ["C","",270] ], "STRrg" => [ ["C","",180] ], "STRlf-ELEV" => [ ["EC","",90], ["C","",90] ], "STRrf-ELEV" => [ ["EC"], ["C"] ], "STRlg-ELEV" => [ ["EC","",270], ["C","",270] ], "STRrg-ELEV" => [ ["EC","",180], ["C","",180] ], "BS2lf" => [ ["BS2lf"] ], "BS2rf" => [ ["BS2rf","",0,1] ], "BS2lg" => [ ["BS2lg","",180] ], "BS2rg" => [ ["BS2rg","",180,1] ], "BS2cro" => [ ["BS2cro"] ], "BS2clo" => [ ["BS2clo","",0,1] ], "BS2clu" => [ ["BS2clu","",180] ], "BS2cru" => [ ["BS2cru","",180,1] ], "BR�CKE" => [ ["B"], ["S"] ], "HBR�CKE" => [ ["B","",90], ["S","",90] ], "BR�CKE1" => [ ["B1"], ["S"] ], "BR�CKE2" => [ ["B2"], ["S"] ], "BR�CKE" => [ ["B"], ["S"] ], "HBR�CKE" => [ ["B","",90], ["S","",90] ], "BR�CKE1" => [ ["B1"], ["S"] ], "BR�CKE2" => [ ["B2"], ["S"] ], "BRUCKE" => [ ["B"], ["S"] ], #no umlaut "HBRUCKE" => [ ["B","",90], ["S","",90] ], #no umlaut "BRUCKE1" => [ ["B1"], ["S"] ], #no umlaut "BRUCKE2" => [ ["B2"], ["S"] ], #no umlaut "BRUCKE" => [ ["B"], ["S"] ], #no umlaut "HBRUCKE" => [ ["B","",90], ["S","",90] ], #no umlaut "BRUCKE1" => [ ["B1"], ["S"] ], #no umlaut "BRUCKE2" => [ ["B2"], ["S"] ], #no umlaut "ELEVa" => [ ["Es"] ,["S"] ], "ELEVe" => [ ["Es","",180] ,["S"] ], "HELEVa" => [ ["Es","",270] ,["S","",90] ], "HELEVe" => [ ["Es","",90] ,["S","",90] ], "WBR�CKE" => [ ["W"], ["B2"], ["S"] ], "WBR�CKE1" => [ ["W"], ["B"], ["S"] ], "WBR�CKE-ELEV" => [ ["W"], ["E"], ["S"] ], "WBR�CKE-ELEVa" => [ ["W"], ["Es"], ["S"] ], "WBR�CKE-ELEVe" => [ ["W"], ["Es","",180], ["S"] ], "HWBR�CKE" => [ ["W","",90], ["B2","",90], ["S","",90] ], "SBR�CKE" => [ ["S"], ["OVERPASS"] ], "WBRUCKE" => [ ["W"], ["B2"], ["S"] ], #no umlaut "WBRUCKE1" => [ ["W"], ["B"], ["S"] ], #no umlaut "WBRUCKE-ELEV" => [ ["W"], ["E"], ["S"] ], #no umlaut "WBRUCKE-ELEVa" => [ ["W"], ["Es"], ["S"] ], #no umlaut "WBRUCKE-ELEVe" => [ ["W"], ["Es","",180], ["S"] ], #no umlaut "HWBRUCKE" => [ ["W","",90], ["B2","",90], ["S","",90] ], #no umlaut "SBRUCKE" => [ ["S"], ["OVERPASS"] ], #no umlaut "TUNNEL1" => [ ["TN"] ], "TUNNEL2" => [ ["TN2"] ], "HTUNNEL2" => [ ["TN2","",90] ], "TUNNELa" => [ ["H","",180], ["tH"], ["PORTAL"] ], "TUNNELe" => [ ["H"], ["tH","",180], ["PORTAL","",180] ], "TUNNELlu" => [ ["H","",90], ["tH","",270], ["PORTAL","",270] ], "TUNNELru" => [ ["H","",270], ["tH","",90], ["PORTAL","",90] ], "WTUNNEL" => [ ["TN2"], ["W"] ], "WTUNNEL1" => [ ["TN"], ["W"] ], # "WTUNNEL2" => "KMW" => [ ["S"], ["KMW"] ], "GRENZE" => [ ["S"], ["GRENZE"] ], "xGRENZE" => [ ["S","e"], ["GRENZE"] ], "eGRENZE" => [ ["S"], ["eGRENZE"] ], "exGRENZE" => [ ["S","e"], ["eGRENZE"] ], "BR�CKE+GRENZE" => [ ["B"], ["S"], ["GRENZE"] ], "xBR�CKE+GRENZE" => [ ["B"], ["S","e"], ["GRENZE"] ], "eBR�CKE+GRENZE" => [ ["B"], ["S"], ["eGRENZE"] ], "exBR�CKE+GRENZE" => [ ["B"], ["S","e"], ["eGRENZE"] ], "WBR�CKE+GRENZE" => [ ["W"], ["B2"], ["S"], ["GRENZE"] ], "xWBR�CKE+GRENZE" => [ ["W"], ["B2"], ["S","e"], ["GRENZE"] ], "eWBR�CKE+GRENZE" => [ ["W"], ["B2"], ["S"], ["eGRENZE"] ], "exWBR�CKE+GRENZE" => [ ["W"], ["B2"], ["S","e"], ["eGRENZE"] ], "BRUCKE+GRENZE" => [ ["B"], ["S"], ["GRENZE"] ], #no umlaut "xBRUCKE+GRENZE" => [ ["B"], ["S","e"], ["GRENZE"] ], #no umlaut "eBRUCKE+GRENZE" => [ ["B"], ["S"], ["eGRENZE"] ], #no umlaut "exBRUCKE+GRENZE" => [ ["B"], ["S","e"], ["eGRENZE"] ], #no umlaut "WBRUCKE+GRENZE" => [ ["W"], ["B2"], ["S"], ["GRENZE"] ], #no umlaut "xWBRUCKE+GRENZE" => [ ["W"], ["B2"], ["S","e"], ["GRENZE"] ], #no umlaut "eWBRUCKE+GRENZE" => [ ["W"], ["B2"], ["S"], ["eGRENZE"] ], #no umlaut "exWBRUCKE+GRENZE" => [ ["W"], ["B2"], ["S","e"], ["eGRENZE"] ], #no umlaut "STRSummit" => [ ["S"], ["SUMMIT"] ], "�ST" => [ ["CROSS"] ], "t�ST" => [ ["tCROSS"] ], "UST" => [ ["CROSS"] ], #no umlaut "tUST" => [ ["tCROSS"] ], #no umlaut "BUE" => [ ["S"], ["BUE"] ], "TRAJEKT" => [ ["S"], ["SHIP"] ], "exTRAJEKT" => [ ["S","e"], ["eSHIP"] ], "BOOT" => [ ["SHIP"] ], "exBOOT" => [ ["eSHIP"] ], "WASSER" => [ ["W"] ], "tWASSER" => [ ["W"], ["tS"] ], "FLUG" => [ ["FLUG"] ], "exFLUG" => [ ["eFLUG"] ], # "TRAM" => "ENDEa" => [ ["H"], ["END"] ], "xENDEa" => [ ["H"], ["H","e",180], ["END"] ], "exENDEa" => [ ["H","e"], ["eEND"] ], "ENDEe" => [ ["H","",180], ["END"] ], "xENDEe" => [ ["H","",180], ["H","e"], ["END"] ], "exENDEe" => [ ["H","e",180], ["eEND"] ], "ENDEl" => [ ["H","",90], ["END","",90] ], "xENDEl" => [ ["H","",90], ["H","e",270], ["END","",90] ], "exENDEl" => [ ["H","e",90], ["eEND","",90] ], "ENDEr" => [ ["H","",270], ["END","",270] ], "xENDEr" => [ ["H","",270], ["H","e",90], ["END","",270] ], "exENDEr" => [ ["H","e",270], ["eEND","",270] ], "AKRZo" => [ ["HIGHWAYde"], ["B"], ["S"] ], "AKRZo-ELEV" => [ ["HIGHWAYde"], ["E"], ["S"] ], "AKRZu" => [ ["S"], ["B","",90], ["HIGHWAYde"] ], "AKRZ-UKo" => [ ["HIGHWAYuk"], ["B"], ["S"] ], "AKRZ-UK-ELEV" => [ ["HIGHWAYuk"], ["E"], ["S"] ], "AKRZ-UKu" => [ ["S"], ["B","",90], ["HIGHWAYuk"] ], ); ## pictgrams with "tunnel" variants %tunnel = ( "S" => "tS", "C" => "tC", "H" => "tH", "ONEWAY" => "tONEWAY", "BS2lf" => "tBS2lf", "BS2cro" => "tBS2cro", ); # end data #options %opts = (); getopts ("ac:d:hi:o:s:t:v", \%opts); if($opts{h}){ print< %s",$opts{o}); open(OUTFH,$file) or die "Cannot open file $opts{o}"; }else{ open(OUTFH,">-"); } %used_pic=(); if($opts{d}){ foreach $pic (split(/\,/,$opts{d})) { $used_pic{$pic} = 1; } } # read $width=0; $height=0; while ($line = ){ if($line =~ /^\{\{BS[0-9]*\|/){ $height += 1; $w = substr($line,0,index($line,"|")); $w =~ s/\D//g; if($w eq ""){ $w = 1; } if($width < $w){ $width = $w; } @tmp = split(/\||\}\}/,substr($line,index($line,"|")+1)); $i=0; @row = (); foreach $cell (@tmp) { if( $cell !~ /^O\d+\s*=/ ){ #not overlap $row[$i][0] = $cell; $row[$i][1] = ""; $i++; if($i >= $w){ last; } } } foreach $cell (@tmp) { if( $cell =~ /^O\d+\s*=/ ){ #overlap ($i,$cell) = split(/=/,$cell); $i =~ s/\D//g; $cell =~ s/^\s*//g; $row[$i-1][1] = $cell; } } if($opts{v}){ for($i=0;$i<$w;$i++){ print STDERR "$row[$i][0]"; if( $row[$i][1] ){ print STDERR "($row[$i][1])"; } if($i != $w-1){ print STDERR " - "; }else{ print STDERR "\n"; } } } push(@list, [ @row ]); } } close(INFH); if($opts{v}){ print(STDERR"width=$width, height=$height\n"); } # find icons for($i=0;$i<$height;$i++){ $row = $list[$i]; $w=$#{$row}+1; for ($j=0;$j<$w;$j++){ for($j2=0;$j2<2;$j2++){ $icon=$list[$i][$j][$j2]; unless($icon){ next; } $x = $j+($width-$w)/2.0; $y = $i; undef $ref; undef $flag_u; undef $flag_t; undef $flag_ex; if( exists($table{$icon}) ){ $ref = $table{$icon}; } if( ! defined($ref) && substr($icon,0,1) eq "u"){ $flag_u = 1; $icon = substr($icon,1); if( exists($table{$icon}) ){ $ref = $table{$icon}; } } if( ! defined($ref) && substr($icon,0,1) eq "t"){ $flag_t = 1; $icon = substr($icon,1); if( exists($table{$icon}) ){ $ref = $table{$icon}; } } if( ! defined($ref) && substr($icon,0,2) eq "ex"){ $flag_ex = 1; $icon = substr($icon,2); if( exists($table{$icon}) ){ $ref = $table{$icon}; } } if( ! defined($ref) ){ $line = sprintf(" ",$x,$y,$list[$i][$j][$j2]); push(@output,$line); $line = sprintf("Undefined icon %s at x=%g y=%g\n", $list[$i][$j][$j2],$x,$y); print STDERR $line; $used_pic{"undefined"} = 1; next; } for($k=0;$k<=$#$ref;$k++){ $pic = $ref->[$k][0]; if($flag_t && exists($tunnel{$pic})){ $pic = $tunnel{$pic}; } if(exists($depend{$pic})){ foreach $pic2 (@{$depend{$pic}}){ $used_pic{$pic2} = 1; } } $used_pic{$pic} = 1; if($flag_ex){ if($flag_u || index($ref->[$k][1],"u") >= 0){ $class = " class=\"bs_ue\""; }else{ $class = " class=\"bs_e\""; } }elsif($flag_u && index($ref->[$k][1],"u") == -1){ $class = sprintf(" class=\"bs_u%s\"",$ref->[$k][1]); }elsif($ref->[$k][1]){ $class = sprintf(" class=\"bs_%s\"",$ref->[$k][1]); }else{ $class = ""; } @transf = (); if($ref->[$k][2]){ push(@transf,sprintf("rotate(%d,%g,%g)", $ref->[$k][2],$x+0.5,$y+0.5)); } if($ref->[$k][3]){ push(@transf,sprintf("matrix(-1,0,0,1,%g,0)",2*$x+1)); } if($#transf < 0){ $transform = ""; }else{ $transform = sprintf(" transform=\"%s\"",join(" ",@transf)); } $line = sprintf(" ",$pic,$x,$y,$class,$transform); push(@output,$line); } } } } # write ## header print OUTFH < EOM if($opts{c}){ print OUTFH "\n"; } printf OUTFH ("\n",$width*$scale,$height*$scale); if($opts{t}){ print OUTFH " $opts{t} \n"; } ##definitions print OUTFH < EOM ##pictgrams while( ($pic, $def) = each (%symbol) ){ if($opts{a} || $used_pic{$pic}){ print OUTFH " "; unless($used_pic{$pic}){ print OUTFH " "; } print OUTFH "\n"; print OUTFH $def; print OUTFH " \n"; } } print OUTFH "\n"; ##main part print OUTFH < EOM print OUTFH join("\n",@output); print OUTFH "\n\n\n"; close(OUTFH);