#!/usr/bin/perl
use warnings;
use strict;

use Getopt::Long;
use Pod::Usage;
use Time::HiRes qw ( time );   # Get time with floating point seconds
use POSIX qw(sigaction);

BEGIN {
  unshift @INC, "../../perl_lib";
}

$ENV{TZ} = "UTC";

my($input, $username, $password, $api, $help, @nodes, @ways);
my $force = 0;
my $dry_run = 0;
my $loop = 0;
my $verbose = 0;
my $extract = 0;
my $api_version;

Getopt::Long::Configure('no_ignore_case');
Getopt::Long::Configure ("bundling");
GetOptions ( 'u|username=s'       => \$username,
             'p|password=s'       => \$password,
             'a|api=s'            => \$api,
	     'n|node=s'		  => \@nodes,
	     'w|way=s'		  => \@ways,
             'h|help'             => \$help,
             'v|verbose+'         => \$verbose,
             ) or pod2usage(1);

pod2usage(1) if $help;

$api ||= "";#http://www.openstreetmap.org/api/0.4";
use Geo::OSM::OsmChangeReaderV5;
use Geo::OSM::EntitiesV5;
use Geo::OSM::APIClientV5;

#$api ||= "http://www.openstreetmap.org/api/0.4";
if( defined $api and $extract > 0 )
{
  die "Can only supply one of -a and -x\n";
}

#if( $dry_run and $extract > 0 )
#{
#  die "Can't do a dry-run on extraction\n";
#}

if( not defined $api and $extract == 0)
{
  die "Must supply the URL of the API (-a) (standard is http://www.openstreetmap.org/api/0.4/)\n";
}

my $uploader = new Geo::OSM::APIClient( api => $api, username => $username, password => $password );

foreach my $node (@nodes) {
	my $ret;
	$uploader->resurrect('node', $node);
}

foreach my $way (@ways) {
	$uploader->resurrect('way', $way);
}
