This is an issue submitted to me by user "joshk".
It's not yet clear whether this can be addressed by changing the implementation of the API or just the module:
Sometimes, you might run into a situation where you want to tag a node with a location, but you don't (or configured the settings so that you can't) include a postal code in the location tag. However, you still want to be able to have the node turn up in a proximity search.
A couple of ideas:
(1) Assign a default postal code to nodes where only a city name is given. The problem with this approach is that postal codes show up in search results and for cities with multiple postal codes, the default postal code may yield an inaccurate location.
(2 - joshk's idea) On the search in location.module, we should also put together a list of unique city names that contains at least one postal_code that falls within the search radius. We would then change the query for nodes so that it also checks table "location_node" for nodes that contains one of these city names.... Perhaps the querying for cities that fall within a certain proximity should be implemented on the API layer (location.inc) while the search for matching nodes should be implemented in location.module.... The city-radius search would probably implement the same kind of caching of searches...
The question, the first that I can think of, is what distance do we display for the returned city, when we try to display the approximate distance between a search point and a node tagged with only a city where the city has multiple postal codes... currently, searches on nodes display the distance between the approximate centers of the search-point postal code and the search result postal code... what do we use for the approximate center of a city in cases where a node only has a city....?
The second idea looks more sensible... but I'd like to let this incubate for ideas for a couple days....
-Ankur
Comments
Comment #1
ankur commentedForget about letting this thing incubate with ideas for a couple of days! I think I have a good idea of what this will mean on the API level (i.e., in "location.inc"):
@param $location
An associative array where
'street' => the street location
'additional' => extra street location or building name or hall or something like that.
'city' => a city name
'province' => province code as defined by the country specific include file
'country' => lower-cased two-letter ISO 3166 code (REQUIRED)
'postal_code' => the postal_code
@return
A linear array where the values themselves are associative arrays. In each of these associative arrays,
'city' => the name of the city
'province' => the standard UPPER-CASE abbreviation (this will be NULL or the empty string if not applicable)
'country' => the lower-case, two-letter ISO code
'distance' => the approximate distance of this city to the search-point specified by $location (this can be based on the closest postal code within this city, or lat/lon data from another source that associates cities with lat/lon pairs if these are being pulled from a database table at the country-specific level)
'distance_unit' => 'km' or 'mile' depending on the parameter.
location_nearby_cities_bylocation($location, $distance, $distance_unit = 'km');
This will be analogous to location_nearby_postalcodes_bylocation();
This function will be implemented on top of a helper function called _location_nearby_cities() which will be analogous to _location_nearby_postalcodes().
Also, there should be a location_nearby_cities_bylatlon() that is analogous to location_nearby_postalcodes_bylatlon().
All the hard work will be done in _location_nearby_cities(). You can look to the implemented functions that these specified functions will be analogous to for pointers on how to go about this. Understandably, this is no easy task. If you feel ready to take on it, but need more details. Hit me up: ankur AT civicspacelabs DOT org
Aw yeah. I've never spelled by email address like that
The code that actually makes use of this function in location.module will be a seperate task for after when this portion is implemented... Any takers?
-Ankur
Comment #2
scriptnews commentedHi
I hope I don´t miss post here. Just to bring anopther issue to Your attention.
When working with several countries it may not be surprising that several cities or location have identical zip-codes. Happened just to me, with USA and German locations.
And on the other handm, when I want to use the code for Central America, where mostly NO zip codes exist or are inconsistent, the actual module does not allow me to use location codes at all for this countries.
Here I would prefer a "simple" :-) ID country:province:location related to lat and long-values.
Just 1 cent :-)
Best regards
Roland
Comment #3
damien tournoud commentedIn fact this problem is "by design". The location module+API was designed with the United-States in mind, a country where zipcodes are (mostly) geographic. This means that there is a 1-1 relationship between a zipcode and its coordinates.
In other countries (and most countries in Europe), this relationship is not true, because zipcodes are "Postal Codes" : a code that indicate a Post office. In rural areas, the same Post office can distribute mail for several town. In dense urban areas, several Post office may be needed for the same town.
Because there is no simple relationship between zipcode and geo-data, the location module should be sure that it has enough data to find the location of a given address at validation time. This matching should be done on (country, zipcode, city, state), and the module should display several choices to the user if there is not an unique match.
This will solve at the same time the "city-without-zipcode" problem.
I think this issue should be postponed, until the next major rewriting of the location module+api.
-- DamZ
Comment #4
scriptnews commentedHi again
reading the last response in this topic, it occures that we could have a mayor improvement
if we change some workflow to "user-centric". What do I mean ?
Imagine, there are millions of potential users world wide, some have a postal code, most
do not. Some know there aprox. location by long - latitude, some don't.
Maybe we should have the module beeing able - optionally - to collect what
ever data a user has available, including reference to "The next big city", in
case no other data is available.
Than this data would be checked against a living pool of comparison
data and the location would be given as precisely as possible, indicating
a range of long / lat. This would be a set of 4 geo-points instead of only two,
and the data set would say - in plain language - that a given site is
located between or within a rectangular
I have seen a similar procedure in a script and service to match IP numers to locations,
but I do not remember in this moment where and which.
Just 1 cent to share
Roland
Comment #5
catchhttp://drupal.org/node/66887