Ignore:
Timestamp:
Dec 21, 2005, 6:16:36 PM (16 years ago)
Author:
Dominic Hargreaves
Message:

Add initial google maps support, see #46 but this isn't yet a complete
implementation so leaving the bug open for now.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/lib/OpenGuides/Utils.pm

    r729 r730  
    33use strict;
    44use vars qw( $VERSION );
    5 $VERSION = '0.08';
     5$VERSION = '0.09';
    66
    77use Carp qw( croak );
     
    217217}
    218218
     219=item B<get_wgs84_coords>
     220
     221Returns coordinate data suitable for use with Google Maps (and other GIS
     222systems that assume WGS-84 data).
     223
     224    my ($wgs84_long, $wgs84_lat) = OpenGuides::Utils->get_wgs84_coords(
     225                                        longitude => $longitude,
     226                                        latitude => $latitude,
     227                                        config => $config
     228                                   );
     229
     230=cut
     231
     232sub get_wgs84_coords {
     233    my ($self, %args) = @_;
     234    my ($longitude, $latitude, $config) = ($args{longitude}, $args{latitude},
     235                                           $args{config})
     236       or croak "No longitude supplied to get_wgs84_coords";
     237    croak "geo_handler not defined!" unless $config->geo_handler;
     238    if ($config->force_wgs84) {
     239        # Only as a rough approximation, good enough for large scale guides
     240        return ($longitude, $latitude);
     241    } elsif ($config->geo_handler == 1) {
     242        # Do conversion here
     243        return undef;
     244    } elsif ($config->geo_handler == 2) {
     245        # Do conversion here
     246        return undef;
     247    } elsif ($config->geo_handler == 3) {
     248        if ($config->ellipsoid eq "WGS-84") {
     249            return ($longitude, $latitude);
     250        } else {
     251            # Do conversion here
     252            return undef;
     253        }
     254    } else {
     255        croak "Invalid geo_handler config option $config->geo_handler";
     256    }
     257}
    219258
    220259=back
     
    226265=head1 COPYRIGHT
    227266
    228      Copyright (C) 2003-2004 The OpenGuides Project.  All Rights Reserved.
     267     Copyright (C) 2003-2005 The OpenGuides Project.  All Rights Reserved.
    229268
    230269This module is free software; you can redistribute it and/or modify it
Note: See TracChangeset for help on using the changeset viewer.