Exemplo n.º 1
0
        '<path d="M 0 %POSB% L 20 %POSB%" '.
        'fill="none" stroke="%STROKE%" stroke-width="1"  '.
        'stroke-dasharray="%DASH%" />';

foreach(array("tram"=>"#ff0000", "bus"=>"#0000ff") as $modal=>$color) {
  foreach(array("single"=>array(50, 9, 5, 5), "double"=>array(50, 10, 6.5, 3.5)) as $tracks=>$pos) {
    foreach(array(1, 2, 3) as $dir) {
      $f=""; $b="";
      print $dir&2;
      if($dir&1)
	$f=$forward1;
      if($dir&2)
	$b=$backward1;
      $dir_name=array(1=>"forward", "backward", "both");
      $dir_name=$dir_name[$dir];

      $file=fopen("/tmp/x.svg", "w");
      fwrite($file, fit($f, $b, $color, $pos, ""));
      fclose($file);

      system("convert -background none /tmp/x.svg img/{$modal}_{$tracks}_{$dir_name}.png");

      $file=fopen("/tmp/x.svg", "w");
      fwrite($file, fit($f, $b, $color, $pos, "5, 5"));
      fclose($file);

      system("convert -background none /tmp/x.svg img/{$modal}_tunnel_{$tracks}_{$dir_name}.png");
    }
  }
}
Exemplo n.º 2
0
#!/usr/bin/php
<?
include("config_queries.php");
$base    =file_get_contents($argv[1].".mml");

// When you add more keys here, don't forget to add these keys also to the 
// layer detection in src/sql/02_layer.sql
// THese keys  should also have an index (src/sql/01_indices.sql)

function fit($template, $num, $where=0) {
  global $query;

  $rep=array(
    "%LAYER_NUM%"=>$num,
    "%SQL_HIGHWAY_TYPE%"=>$query["highway"],
    "%SQL_LANDUSE%"=>$query["landuse"],
    "%SQL_AMENITY%"=>$query["base_amenity"],
    "%SQL_PLACES%"=>$query["places"]
  );
  foreach($query as $k=>$sql) {
    $rep["%SQL_$k%"]=$sql;
  }

  return strtr($template, $rep);
}

$base=fit($base, 0);

print $base;
Exemplo n.º 3
0
while(ereg("%INSERTLAYERS ([^%]*)%", $base, $m)) {
  $insert=file_get_contents("$m[1].mml");

  $insert_full="";
  for($l=-5; $l<=5; $l++) {
    $insert_full.= fit($insert, $l);
  }

  $base=strtr($base, array($m[0]=>$insert_full));
}

while(ereg("%INSERTLAYERSBACK ([^%]*)%", $base, $m)) {
  $insert=file_get_contents("$m[1].mml");

  $insert_full="";
  for($l=5; $l>=-5; $l--) {
    $insert_full.= fit($insert, $l);
  }

  $base=strtr($base, array($m[0]=>$insert_full));
}

while(ereg("%INSERT ([^%]*)%", $base, $m)) {
  $insert=file_get_contents("$m[1].mml");
  $insert=fit($insert);

  $base=strtr($base, array($m[0]=>$insert));
}

print $base;