break;
            case '--input':
                $inputfile = $o[1];
                break;
            case '--output':
                $outputfile = $o[1];
                break;
            case 'help':
            default:
                print "Weathermap DSStats converter. Converts rrd targets to DSStats\n";
                print "-------------------------------------------------------------\n";
                print "Usage: php convert-to-dstats.php [options]\n\n";
                print " --input {filename}         - File to read from\n";
                print " --output {filename}        - File to write to\n";
                print " --debug                    - Enable debugging output\n";
                print " --help                    - Show this message\n";
                exit;
        }
    }
}
if ($inputfile == "" || $outputfile == "") {
    print "You must specify an input and output file. See --help.\n";
    exit;
}
$map = new WeatherMap();
$map->context = 'cacti';
$map->rrdtool = read_config_option("path_rrdtool");
print "Reading config from {$inputfile}\n";
$map->ReadConfig($inputfile);
$map->writeConfig($outputfile);
print "Wrote new config to {$outputfile}\n";
            $map->ReadConfig($input_mapfile);
            foreach ($map->nodes as $node) {
                $target = $node->name;
                if ($node->x < $min_x || $node->x >= $max_x || $node->y < $min_y || $node->y >= $max_y) {
                    print "{$target} falls outside of this map. Deleting it and links that use it.\n";
                    foreach ($map->links as $link) {
                        if ($target == $link->a->name || $target == $link->b->name) {
                            print "link {$link->name} uses it. Deleted.\n";
                            unset($map->links[$link->name]);
                        }
                    }
                    unset($map->nodes[$target]);
                } else {
                    print "{$target} is OK, but will be moved for the new map from " . $node->x . "," . $node->y . " to ";
                    $x = $node->x;
                    $y = $node->y;
                    $x = $node->x - $min_x;
                    $y = $node->y - $min_y;
                    $map->nodes[$target]->x = $x;
                    $map->nodes[$target]->y = $y;
                    print "{$x},{$y}\n";
                }
            }
            $output_mapfile = $input_mapfile . "-" . $row . "-" . $col . ".conf";
            $map->width = $desired_width;
            $map->height = $desired_height;
            $map->background = "";
            $map->writeConfig($output_mapfile);
        }
    }
}