|GSAK (Geocaching Swiss Army Knife)|
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.
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 without 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 changed (that is, where the new state 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 the state column with abbreviated names, but only if there wasn't already something in there, the code would be:
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" please 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):
Related: GetCounty() GetCountry() GetPolygon()
Alpha List Category List
Copyright 2004-2019 CWE Computer Services |