my $h_img_dims => {img_width => 200, img_height => 200}; my $h_map_bbox => {map_minx => 2090491, map_miny => 482208, map_maxx + => 2224055, map_maxy => 587708}; my $h_new_center => {x => 200, y => 100}; # for pan right/East #my $h_new_center => {x => 0, y => 100}; # for pan left/West #my $h_new_center => {x => 100, y => 200}; # for pan bottom/South #my $h_new_center => {x => 100, y => 0}; # for pan up/North # Convert the mouse click to earth coordinates my ($x, $y) = _pixel2earth( h_img_dims => $h_img_dims, h_map_bbox => $h_map_bbox, h_new_center => $h_new_center, ); sub _pixel2earth { my (%args) = @_; my $h_img_dims = $args{h_img_dims}; my $h_map_bbox = $args{h_map_bbox}; my $h_new_center = $args{h_new_center}; # Mouse clicks equivalent in earth coordinates return ( $h_map_bbox->{map_minx} + ($h_new_center->{x} * ( ($h_map_bbox->{m +ap_maxx} - $h_map_bbox->{map_minx}) / $h_img_dims->{img_width} )), $h_map_bbox->{map_miny} + ($h_new_center->{y} * ( ($h_map_bbox->{m +ap_maxy} - $h_map_bbox->{map_miny}) / $h_img_dims->{img_height} )) ); }
If you want to display a rectangular image, but measure non-rect coordinates such as lat/lon, you will have to project on the fly. Look at Proj.4, or better yet, look at MapServer which can do the image generation for you as well.
In reply to Re: Converting Pixels to LatLong
by punkish
in thread Converting Pixels to LatLong
by BaldPenguin
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |