Contents - Index


GetState (function)

GetState(sOptions) : numeric

This function is a optimized routine to calculate the state name for a given waypoint. Part of this optimization requires that the waypoint must already have a valid country. This function uses polygon files to determine the location of each country and is not guaranteed to be perfect.

sOptions

U = update user data
2 = update user data 2
B = only update if blank or = "nil" or = "none"
F = set user flag, but only if updated
R = set user flag if matching polygon found (see note)
S - Update the state field in the database
A - (abbreviate) update with the 2 or 3 letter (country specific) abbreviated state code rather than the full name.

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

Options can be entered in any order. The return value of the function is the number of records updated - or in the case of the single R option, then number of records flagged

So if you wanted to update the state column with abbreviated names, but only if there wasn't already something in there, the code would be:
 

$updated = GetState("sba")
msgok msg=Number of records updated: $updated

 
There is actually many polygon files required to make this work (even zipped they are many Megabytes in size) so they are not shipped in the GSAK install.

Accordingly the function does a "smart update" of the state polygon files as needed. For the definition of "needed" plase see this link

The first time you run this function for a particular state, you must be connected to the Internet so it can download the corresponding polygon files. From then onwards, this function can be run at anytime. 

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

Algeria
Andorra
Angola
Australia
Austria
Benin
Botswana
Burkina Faso
Burundi
Cameroon
Canada
Cape Verde
Central African Republic
Chad
China
Comoros
Congo
Democratic Republic of the Congo
Czech Republic
Cote D'Ivoire
Denmark
Djibouti
Egypt
Equatorial Guinea
Eritrea
Estonia
Ethiopia
Faroe Islands
Finland
France
Gabon
Gambia
Germany
Ghana
Greece
Greenland
Guinea
Hungary
Iceland
Ireland
Italy
Jordan
Kenya
Lesotho
Liberia
Libya
Luxembourg
Madagascar
Malawi
Mali
Malta
Mauritania
Mauritius
Morocco
Mozambique
Namibia
Netherlands
New Zealand
Niger
Nigeria
Norway
Poland
Rwanda
Reunion
Saint Helena
Sao Tome and Principe
Senegal
Sierra Leone
Slovakia
Somalia
South Africa
Spain
Sudan
Swaziland
Sweden
Tanzania
Togo
Tunisia
Turkey
Uganda
United Kingdom
United States
Western Sahara
Zambia
Zimbabwe
Aland Islands

 


Related: GetCounty() GetCountry() GetPolygon() 

Alpha List         Category List