Skip to content

Commit 882525f

Browse files
2.2.1 Improved getTerritoryNumber
1 parent a81a5f5 commit 882525f

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

mapcode_api.php

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
* limitations under the License.
1717
*/
1818

19-
define('mapcode_phpversion', '2.2');
19+
define('mapcode_phpversion', '2.2.1');
2020

2121
$xdivider19 = array(
2222
360, 360, 360, 360, 360, 360, 361, 361, 361, 361,
@@ -143,8 +143,11 @@ function getParentOf($territory)
143143

144144
function iso2ccode($territory)
145145
{
146-
147146
$isocode = strtoupper(trim($territory));
147+
$sep = strpos($isocode, ' ');
148+
if ($sep !== false) {
149+
$isocode = substr($isocode, 0, $sep);
150+
}
148151
if (is_numeric($isocode)) {
149152
return intval($isocode);
150153
}
@@ -214,9 +217,10 @@ function iso2ccode($territory)
214217
return -1;
215218
}
216219

217-
function getTerritoryNumber($territory, $contextTerritoryNumber = -1)
220+
function getTerritoryNumber($territory, $contextTerritory = -1)
218221
{
219-
if ($contextTerritoryNumber >= 0) {
222+
if ($contextTerritory != -1) {
223+
$contextTerritoryNumber = getTerritoryNumber($contextTerritory);
220224
set_disambiguate($GLOBALS['entity_iso'][$contextTerritoryNumber]);
221225
}
222226
return iso2ccode($territory);

0 commit comments

Comments
 (0)