#!/usr/bin/perl use warnings; use strict; use Glib qw/TRUE FALSE/; use Gtk2 -init; use Image::ExifTool; use Geo::Coordinates::UTM; #geoTiff File (static) my $filename = 'q3639_DRG24k-c.tif'; #geostats my $ellipsoid = 23; #static WSG83 my $zone; my @mtp; my @ps; my @cs; #Create Window my $window = new Gtk2::Window ( "toplevel" ); $window->signal_connect ("delete_event", sub { Gtk2->main_quit; }); $window->set_border_width (10); $window->set_size_request(640,480); $window->set_position('center'); #create Table my $table = Gtk2::Table->new(1, 1, FALSE); #Create Scrolled Window my $scwin = Gtk2::ScrolledWindow->new(); $scwin->set_policy('always','always'); #Create Viewport my $vp = Gtk2::Viewport->new (undef,undef); #add GeoTiff my $exifTool = new Image::ExifTool; my $info = $exifTool->ImageInfo($filename); foreach (sort keys %$info) { print "$_ => $$info{$_}\n"; #Find the right keys(data) if ($_ eq "ModelTiePoint"){ @mtp = split(/ /,$$info{$_}); } if ($_ eq "PixelScale"){ @ps = split(/ /,$$info{$_}); } if ($_ eq "ProjectedCSType"){ @cs = split(/ /,$$info{$_}); $zone = $cs[3]; } } my $pixbuf = Gtk2::Gdk::Pixbuf->new_from_file ($filename); my $widget = Gtk2::Image->new_from_pixbuf ($pixbuf); #Create Eventbox and Pack mouse signal my $ebox = Gtk2::EventBox->new; $ebox->set_events( 'button_press_mask' ); $ebox->signal_connect( button_press_event => sub { my ($widget, $event) = @_; my ($x, $y) = ($event->x, $event->y); #convert UTM to Lat and Long my $easting = $ps[0] * $x + 0.0 * $y + $mtp[3]; my $northing = (-$ps[1]) * $y + 0.0 * $x + $mtp[4]; my ($latitude,$longitude)=utm_to_latlon($ellipsoid,$zone,$easting,$northing); print "$x, $y, ($latitude, $longitude)\n"; }); #Pack $ebox->add($widget); $vp->add($ebox); $window->add($table); $scwin->add($vp); $table->attach_defaults($scwin, 0, 1, 0, 1); #change the cursor over image $ebox->realize; $ebox->window->set_cursor(Gtk2::Gdk::Cursor->new ('hand2')); $window->show_all; Gtk2->main;