Index: trunk/tools/osm-tools/osm2pgsql-style/create-language-views.pl |
— | — | @@ -8,6 +8,7 @@ |
9 | 9 | |
10 | 10 | perl wikipedia-language-codes.pl > wikipedia-languages.yml |
11 | 11 | perl create-language-views.pl --languages wikipedia-languages.yml --psql-user gis > create_views.sql |
| 12 | + perl create-language-views.pl --languages wikipedia-languages.yml --psql-user gis --delete > delete_views.sql |
12 | 13 | psql -U gis gis < create_views.sql |
13 | 14 | |
14 | 15 | =head1 OPTIONS |
— | — | @@ -26,6 +27,10 @@ |
27 | 28 | |
28 | 29 | The PostgreSQL user to use. |
29 | 30 | |
| 31 | +=item --delete |
| 32 | + |
| 33 | +Create SQL to delete the views and associated data. |
| 34 | + |
30 | 35 | =head1 LINKS |
31 | 36 | |
32 | 37 | L<http://wiki.openstreetmap.org/wiki/Regionalisedmap> |
— | — | @@ -55,6 +60,7 @@ |
56 | 61 | 'h|help' => \my $help, |
57 | 62 | 'languages=s' => \my $languages, |
58 | 63 | 'psql-user=s' => \my $psql_user, |
| 64 | + 'delete' => \my $delete, |
59 | 65 | 'style=s' => \my $style, |
60 | 66 | ) or help(); |
61 | 67 | |
— | — | @@ -120,12 +126,17 @@ |
121 | 127 | my @munged_columns = munged_columns($code, @{ $columns{$table} }); |
122 | 128 | |
123 | 129 | my $view_name = "view_${table}_lang_${code}"; |
124 | | - say "CREATE VIEW \"$view_name\" as"; |
125 | | - say " SELECT"; |
126 | | - say join ",\n", map { " $_" } @munged_columns; |
127 | | - say "FROM $table;"; |
128 | | - say ""; |
129 | 130 | |
| 131 | + if ($delete) { |
| 132 | + say "DROP VIEW \"$view_name\";"; |
| 133 | + } else { |
| 134 | + say "CREATE VIEW \"$view_name\" as"; |
| 135 | + say " SELECT"; |
| 136 | + say join ",\n", map { " $_" } @munged_columns; |
| 137 | + say "FROM $table;"; |
| 138 | + say ""; |
| 139 | + } |
| 140 | + |
130 | 141 | push @{ $created_views{ $table} } => $view_name; |
131 | 142 | } |
132 | 143 | |
— | — | @@ -154,7 +165,11 @@ |
155 | 166 | say ""; |
156 | 167 | |
157 | 168 | for my $view (@views) { |
158 | | - say qq[INSERT INTO geometry_columns VALUES ('', 'public', '$view', 'way', 2, 900913, '$type');]; |
| 169 | + if ($delete) { |
| 170 | + say qq[DELETE FROM geometry_columns WHERE f_table_catalog = '' AND f_table_schema = 'public' AND f_table_name = '$view' AND f_geometry_column = 'way' AND coord_dimension = 2 AND srid = 900913 AND type = '$type';]; |
| 171 | + } else { |
| 172 | + say qq[INSERT INTO geometry_columns VALUES ('', 'public', '$view', 'way', 2, 900913, '$type');]; |
| 173 | + } |
159 | 174 | } |
160 | 175 | } |
161 | 176 | |