source: subversion/applications/rendering/mapnik/customize-mapnik-map @ 17225

Last change on this file since 17225 was 12100, checked in by schuetzm, 11 years ago

Die (and returned exit code != 0) if input file cannot be opened.

  • Property svn:executable set to *
File size: 998 bytes
Line 
1#!/usr/bin/perl -w
2#
3#  customize-mapnik-map
4#
5
6use strict;
7$ENV{MAPNIK_PREFIX} ||= "planet_osm";
8
9open(IN, '<', 'osm-template.xml') or die;
10
11while(<IN>) {
12    s/%SYMBOLS_DIR%/$ENV{MAPNIK_SYMBOLS_DIR}/;
13    s/%WORLD_BOUNDARIES_DIR%/$ENV{MAPNIK_WORLD_BOUNDARIES_DIR}/;
14    s/%DBNAME%/$ENV{MAPNIK_DBNAME}/;
15    s/%PREFIX%/$ENV{MAPNIK_PREFIX}/;
16
17    if ($ENV{'MAPNIK_DBUSER'} eq '') {
18        next if m|<Parameter name="user">%DBUSER%</Parameter>|
19    } else {
20        s/%DBUSER%/$ENV{MAPNIK_DBUSER}/;
21    }
22
23    if ($ENV{'MAPNIK_DBPASS'} eq '') {
24        next if m|<Parameter name="password">%DBPASS%</Parameter>|
25    } else {
26        s/%DBPASS%/$ENV{MAPNIK_DBPASS}/;
27    }
28
29    if ($ENV{'MAPNIK_DBHOST'} eq '') {
30        next if m|<Parameter name="host">%DBHOST%</Parameter>|
31    } else {
32        s/%DBHOST%/$ENV{MAPNIK_DBHOST}/;
33    }
34    if ($ENV{'MAPNIK_DBPORT'} eq '') {
35        next if m|<Parameter name="port">%DBPORT%</Parameter>|
36    } else {
37        s/%DBPORT%/$ENV{MAPNIK_DBPORT}/;
38    }
39
40    print;
41}
42
Note: See TracBrowser for help on using the repository browser.