GSAK (Geocaching Swiss Army Knife)
Contents - Index

GetCounty (function)

GetCounty(sOptions) : numeric

This function is an optimized routine to determine the name of the county for each record (respecting filters) which has valid Country and/or State information. This optimization involves (1) a polygon file for each county as well as (2) a bounding box rectangle for each such polygon. The function first checks to see if the bounding box information can uniquely identify the county and, if not, then uses the polygon file to determine the county. Thus the accuracy is limited by the accuracy of the county polygon files.

sOptions

U = update user data
2 = update user data 2
Y = update county
B = only update if blank
F = set user flag, but only if updated
R = set user flag if matching polygon found (see note)

Note: R option should just be used by itself and was added to allow you to flag those waypoints that have matching polygons without actually updating any data in the database. The B and F options should not be used alone and must also include at least one of U,Y or 2

Options can be entered in any order. The return value of the function is the number of records changed (that is, where the new county value is different to the one already on file) - or in the case of the single R option, then number of records flagged

So if you wanted to update user data with county names, but only if there wasn't already something in there, the code would be:
 

$updated = GetCounty("ub")
msgok msg=Number of records updated: $updated

 
Thousands of polygon files are required to make this work (even zipped they are many Megabytes in size); instead of shipping all with each GSAK install, only the bounding box data are included with the GSAK installation data. The complete set of polygon files for any one state or country are installed dynamically whenever the bounding box information is not adequate for one or more of the records being evaluated. You must be connected to the Internet at that time so these polygon files can be acquired by GSAK.

At the time of writing this help file, countries supported were (More will be added as the Polygon files come to hand):
 

Algeria
Angola
Australia
Austria
Belgium
Benin
Botswana
Brazil
Burkina Faso
Burundi
Cameroon
Canada
Central African Republic
Chad
Congo
Cote D'Ivoire
Croatia
Czech Republic
Democratic Republic of the Congo
Denmark
Djibouti
Eritrea
Ethiopia
France
Gabon
Gambia
Germany
Ghana
Guinea
Ireland
Isle of Man
Italy
Jersey
Kenya
Latvia
Liberia
Lithuania
Luxembourg
Madagascar
Malawi
Mali
Malta
Mauritania
Morocco
Mozambique
Netherlands
New Zealand
Niger
Nigeria
Norway
Poland
Portugal
Reunion
Rwanda
Senegal
Sierra Leone
Slovakia
Somalia
South Africa
Spain
Sudan
Sweden
Switzerland
Tanzania
Togo
Tunisia
Uganda
United Kingdom
United States
Zambia
Zimbabwe

 
Related: GetCountry() GetState() GetPolygon() 

Alpha List         Category List
Copyright 2004-2019 CWE Computer Services  
Privacy Policy Contact