Acme-Geo-Whitwell-Name
view release on metacpan or search on metacpan
lib/Acme/Geo/Whitwell/Name.pm view on Meta::CPAN
# Convert Sunnyvale, CA's lat and lon to a Whitwell name pair.
my @names = to_whitwell("37.37N", "122.03");
# Same conversion, using signed latitude and longitude instead.
my @names = to_whitwell(37.37, -122.03);
# Convert a Whitwell name to a latitude and longitude.
# (Washington DC's "rational" name to N/S lat and E/W long.)
my($lat_string, $lon_string) = from_whitwell("Feiro Nyvout");
# If you want signed values, add signed => some true value.
my($lat, $long) = from_whitwell("Feiro Nyvout", signed=>1);
=head1 DESCRIPTION
This module implements Steadman Whitwell's "rational system of geographic
nomenclature", in which place names are generated by converting the latitude
and longitude of the location into a two-part name by means of a
transliteration scheme.
Whitwell devised this scheme in an attempt to provide an alternative to
the proliferation of similarly-named towns in the early US. However, people
seemed to prefer creating many Springfields and Washingtons in preference to
using Whitwell's uniquely quirky names.
=head2 THE SCHEME
Two tables of number-to-letter(s) are used to translate latitudes and
longitudes of two-decimal precision, digit-by-digit, into
vaguely-pronounceable two-part names.
1 2 3 4 5 6 7 8 9 0
latitude a e i o u y ee ei ie ou vowels
longitude b d f k l m n p r t consonants
Transliteration is done by looking up the apropriate digit in the tables above,
switching rows until all the digits are consumed. If the coordinate is negative,
a special 'sign consonant' is inserted into the (partial) name after the first
vowel is added, and the transliteration continues by choosing again from the
vowel table, then continuing to alternate again.
This is very orderly, but confusing to generate by hand (putting aside the
fact that no one in their right mind really wants to live in "Isilu Buban"
instead of Sydney, AU, or "Feiro Nyvout" instead of Washington, DC).
The generated names are guaranteed to have alternating consonants and vowels,
and should be pronounceable (though most likely bizarre). I have not been able
to locate the original documentation of the scheme, so I am unable to determine
why some example names are built in "reverse": with the first letter for the
latitude selected from the longitude table, and vice versa for the longitude. I
can only guess that the alternate construction was deemed more pronounceable or
"interesting". Since this is the case, I generate both alternatives so you can
choose the one that seems "better". In the cases of places like McMurdo Base
("Eeseepu Bymeem" or "Neeveil Amyny"), I'm not sure there I<is> a "better".
However, solely for the purposes of amusement, it can be interesting to find
out what a given location would have been called in the alternate universe
where Whitwell's scheme caught on.
It would be lovely to use this module to change all the place names on
online maps, wouldn't it?
=head2 SOURCES
=over
=item * I<The Angel and the Serpent: The Story of New Harmony>, William E.
Wilson, Indiana University Press, 1984, p. 154
=item * Search books.google.com for '"new harmony gazette" whitwell'
=item * http://www.kirchersociety.org/blog/2007/05/15/whitwells-system-for-a-rational-geographical-nomenclature/
=back
=cut
# These tables define the letters that the numbers will be transliterated into.
# 0 1 2 3 4 5 6 7 8 9
my @vowels = qw(ou a e i o u y ee ei ie);
my @consonants = qw(t b d f k l m n p r);
# Allows us to detect when to insert the "sign consonant" for negative
# lats and lons.
my %vowel;
@vowel{@vowels} = ();
=head1 EXPORT
=head1 FUNCTIONS
=head2 to_whitwell($lat, $lon)
Generates a properly-capitalized Whitwell name from a latitude-longitude pair.
Latitude and longitude are truncated to the two digits after the decimal point,
in keeping with Whitwell's original scheme. Zeroes are added after the decimal
point as necessary.
North latitudes are positve, and south latitudes are negative. East longitudes
are positive, west longitudes are negative. Trailing E/W and N/S are converted
into the appropriate sign. If you supply both for some reason, trailing
sign indicators override signs.
Returns both alternatives for the name (see L<SCHEME>).
=cut
sub to_whitwell {
my($lat, $lon) = @_;
return ( _vowel_build($lat) . ' ' . _consonant_build($lon),
_consonant_build($lat) . ' ' . _vowel_build($lon)
);
}
sub _vowel_build { _gen(shift, [\@vowels, \@consonants], 's') }
sub _consonant_build { _gen(shift, [\@consonants, \@vowels], 'v') }
sub _gen {
# The coordinate, the letter lists, and the appropriate sign consonant.
my($coord, $lists, $neg) = @_;
# Turn the floating-point number into a list of digits.
# Note that _two_decimal does NOT CARE about sign or sign indicators.
( run in 2.146 seconds using v1.01-cache-2.11-cpan-9169edd2b0e )