source: subversion/utils/CityKML/run.pl @ 2058

Last change on this file since 2058 was 1932, checked in by ojw, 13 years ago

run - look for input files instead of guessing their name

  • Property svn:executable set to *
File size: 1002 bytes
RevLine 
[1929]1#!/usr/bin/perl
2use File::Copy;
3
4#----------------------------------------------------------------
5# Convert city OSM files (from http://almien.co.uk/OSM/Places)
6# to KML files, using the OsmGoogleEarth converter
7#
8# Oliver White, 2007, GNU GPL v2 or later
9#----------------------------------------------------------------
10
[1932]11# Search for files to convert
12$DataDir = "data";
13opendir(DIR, $DataDir) || die("Can't read data directory ($!) - has any data been downloaded?");
[1929]14
[1932]15while($File = readdir(DIR)){
[1929]16 
[1932]17  $GZip = "$DataDir/$File";
18  if($File =~ /data_(\d+)\.osm\.gz/){
19    $i = $1;
20    $TempDir = "osmgoogleearth";
21    $Data = "$TempDir/data.osm";
22    $DataG = "$Data.gz";
23    $Output = "output/$i.kml";
24   
25    # If input file exists, but output doesn't
26    if((-f $GZip && ! -f $Output) || (-s $Output == 0)){
27      # Transform OSM to KML
28      copy($GZip, $DataG);
29      `gunzip $DataG`;
30      `xmlstarlet tr $TempDir/osm2kml.xsl $TempDir/osm2kml.xml > $Output`;
31      unlink($Data);
32    }
[1929]33  }
34}
35
Note: See TracBrowser for help on using the repository browser.