#!/usr/bin/perl

use strict;
use warnings;

use lib qw(/usr/local/lib/mpmasql/modules);
use SimpleObject;
use EnhancedGrid;

my $mapfile;

while (@ARGV) {
	my $el = shift @ARGV;
	if (not $el =~ /^-/) {
		$mapfile = $el;
	}
	elsif ($el =~ /^-v/ or $el =~ /^--version/ ) {
		print <<WC2;
mapcount 1.0
(c)	Christian Troost, Universität Hohenheim, 2013-2016
WC2
}	
			
	elsif ($el =~ /^-h/ or $el =~ /^-\?/ ) {
		print <<HELP;

Lists the frequencies of different values found in a raster mapsin ESRI ASCII format.

Usage: mapcount <filename1> <options>

Options:
	-h or -? 		prints this help and exits
	-v, --version	version information
HELP
	exit 0;
	}
	
	
}

print STDERR "Please specify an ASCII map file!\n"and exit(1) unless (defined $mapfile) ;

my $map = EnhancedGrid->create_from_ascii($mapfile);

$map->update_valuetable;
$map->print_valuetable;
