Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Latest commit

 

History

History
History
98 lines (87 loc) · 3.27 KB

File metadata and controls

98 lines (87 loc) · 3.27 KB
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
<!DOCTYPE html>
<!--
/*
* Copyright (C) 2014-2015 Stichting Mapcode Foundation (http://www.mapcode.com)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-->
<html>
<head>
<meta charset="utf-8">
<title>Mapcode PHP Test</title>
</head>
<body>
<CENTER>
<?php
// ----------------------- start of PHP ---------------------
include 'mapcode_data.php';
include 'mapcode_api.php';
include 'mapcode_countrynames.php'; // so we can show full country names (in english)
echo '<H1>Mapcode PHP version ' . mapcode_phpversion . ' example</H1>';
$input = trim($_REQUEST["s"]);
if ($input != NULL) {
//$input = utf8_decode(mb_convert_encoding($input,"utf-8" ));
if (strpos($input, ',') !== false) // contains a comma, so assume coordinates
{
$p = strpos($input, ',');
$lat = substr($input, 0, $p);
$lon = substr($input, $p + 1);
$precision = 0;
$r = encodeShortestWithPrecision($lat, $lon, $precision);
$n = count($r);
echo 'Coordinate ' . $lat . ' , ' . $lon . ' has mapcodes in ' . $n . ' territories: <BR>';
for ($i = 0; $i < $n; $i++) {
$p = strpos($r[$i], ' ');
$territory = ($p === false ? "AAA" : substr($r[$i], 0, $p));
echo ' &nbsp; <B>' . $r[$i] . '</B> (' . getTerritoryFullname($territory) . ')<BR>';
}
echo '<hr>';
} else // assume mapcode
{
$asc = convertToAlphabet($input, 0);
echo 'Input<BR>"' . $input . '"';
if ($asc != $input) {
echo ' (romanized as ' . $asc . ')';
}
$d = decode($input);
if ($d == 0) {
echo '<BR>is not a valid mapcode<BR>';
if (strpos($input, ' ') === false) {
echo '(did you include the territory?)<BR>';
}
} else {
echo '<BR>decodes to coordinate<BR>' . number_format($d->lat, 9) . ',' . number_format($d->lon, 8) . '<BR>';
}
echo '<hr>';
}
}
// ----------------------- end of PHP ---------------------
?>
Enter a mapcode
<BR>
(e.g. <A HREF="sample.php?s=NLD 49.4V"><B>NLD 49.4V</B></A>
or <A HREF="sample.php?s=MOW+%D0%9F%D0%96.%D0%A3%D0%91"><B>MOW &#1055;&#1046;.&#1059;&#1041;</B></A>
or <A HREF="sample.php?s=MH+%E0%A5%AB%E0%A4%97.%E0%A4%B8%E0%A4%A1%E0%A4%9C"><B>MH
&#2411;&#2327;.&#2360;&#2337;&#2332;</B></A>)
<BR>
or a coordinate
<BR>
(e.g. <A HREF="sample.php?s=52.3765,4.9085"><B>52.3765, 4.908</B></A>)
<BR>
and press OK
<BR>
<BR>
<form action="sample.php"><input type="text" name="s" value=""><input type="submit" value="OK"></form>
</body>
</html>
Morty Proxy This is a proxified and sanitized view of the page, visit original site.