Thomas Stedman Whitwell (1784-1840) was an English architect and civil engineer, best known for his design of the secular communal utopia at New Harmony, Indiana, USA. This was done in close collaboration with the mill owner and social reformer Robert Owen, but their plans remained unrealized.
Whitwell's short stay at New Harmony allowed him to publish in the New Harmony Gazette a proposal for a new system of town naming according to their position. Whitwell thought it illogical and confusing that different towns sometimes have the same name. He suggested assigning each city a unique name that was composed of two words separated by a space. The first word corresponds to the latitude of the city, and the second word to its longitude. Latitude and longitude were converted to words by traversing each coordinate from left to right and converting each digit to the corresponding letters in this table Whitwell published in the New Harmony Gazette in 1826.
1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 0 |
---|---|---|---|---|---|---|---|---|---|
a | e | i | o | u | y | ee | ei | ie | ou |
b | d | f | k | l | m | n | p | r | t |
Selection of letters alternates between the first and second rows of the table, which guarantees that the generated words have alternating consonants and vowels. Words that correspond to latitudes in the southern hemisphere start with an S, and words corresponding to western longitudes start with a V. No extra letter is added at the beginning of the words corresponding to north latitudes and east longitudes, so that these words start with a vowel.
Thus New Harmony (USA; 38°11'N, 87°55'W) would be rechristened Ipab Veinul. Washington DC (USA; 38°90'N, 77°04'W) would become Ipiet Veenouk, Brussels (Belgium; 50°85'N, 4°35'O) would be Uteil Ofu, Kampala (Uganda; 0°32'N, 32°58'O) would be Oufe Idup and Buenos Aires (Argentina; 34°61'Z, 58°38'O) would be Sikyb Upip. What these names lack in poetry they make up in utility: a traveler given the name of a town can immediately infer its location. Unfortunately, Whitwell's scheme never caught on — and today the United States has 28 Springfields, 29 Clintons, and 30 Franklins.
Determine a city's name based on its position according to Thomas Stedman Whitwell's scheme. In order to do so, you have to
Write a function digit2letters that takes an integer (int). The function must return the letters (str) that correspond to the given integer in the table used in Whitwell's scheme. By default, the function returns the letters (consonants) found at the first row of the table. However, if the value False is passed to the second optional parameter first, the function must return the corresponding letter found at the second row of the table (a vowel). Try to minimize the number of conditions that need to be tested in calling the function.
Write a function coord2word that takes a latitude or longitude. This coordinate must be passed as a string (str) formatted as d°m'w, where, d represents a number of degrees, m a number of minutes and w a wind direction: N for north, S for south, W for west or E for east. The function must return the word (str) that corresponds to the given coordinate according to Whitwell's scheme. This word must start with an uppercase letter, followed by a series of lowercase letters.
Write a function placename that takes one or two strings (str) that indicate the position of a city. If two strings are passed to the function, they respectively represent the latitude and longitude of the city. If only a single string is passed to the function, it should contain both the latitude and the longitude of the city, separated by a comma. The same format as used with the function coord2word is used described the latitude and longitude. Whitespace (spaces, tabs, newlines, …) in the strings passed to the function placename must be ignored. The function must return the city's name (str) according to Whitwell's scheme, based on the given latitude and longitude of the city.
>>> digit2letters(3)
'i'
>>> digit2letters(7, False)
'n'
>>> digit2letters(0, first=False)
't'
>>> coord2word("38°11'N")
'Ipab'
>>> coord2word("87°55'W")
'Veinul'
>>> placename("38°11'N", "87°55'W") # New Harmony
'Ipab Veinul'
>>> placename("38°11'N, 87°55'W") # New Harmony
'Ipab Veinul'
>>> placename("38°90'N", "77°04'W") # Washington DC (VSA)
'Ipiet Veenouk'
>>> placename("50°85'N, 4°35'E") # Brussels (Belgium)
'Uteil Ofu'
>>> placename("0°32'N", "32°58'E") # Kampala (Uganda)
'Oufe Idup'
>>> placename("34°61'S, 58°38'E") # Buenos Aires (Argentina)
'Sikyb Upip'