├── .gitignore
├── LICENSE
├── NOTICE
├── README.md
├── ctrynams.js
├── ctrynams_short.js
├── examples
├── FileSaver.js
├── converter.html
├── jquery.csv.js
└── sample.csv
├── mapcode.js
├── mapcode_library_js.doc
├── ndata.js
├── sample.html
└── unittest
├── test_encodes.js
├── test_territories.js
└── unittest.html
/.gitignore:
--------------------------------------------------------------------------------
1 | # -----------------------------------------------------------------------------
2 | # Compiled sources
3 | # -----------------------------------------------------------------------------
4 | *.com
5 | *.class
6 | *.dll
7 | *.exe
8 | *.o
9 | *.so
10 |
11 | # -----------------------------------------------------------------------------
12 | # Packages and archives
13 | # -----------------------------------------------------------------------------
14 | # It's better to unpack these files and commit the raw source
15 | # git has its own built in compression methods.
16 | # *.7z
17 | # *.dmg
18 | # *.gz
19 | # *.iso
20 | # *.jar
21 | # *.rar
22 | # *.tar
23 | # *.zip
24 |
25 | # -----------------------------------------------------------------------------
26 | # Logs and databases
27 | # -----------------------------------------------------------------------------
28 | *.log
29 | # *.sql - we need to commit raw SQL for test database creation
30 | *.sqlite
31 | *.tlog
32 | *.epoch
33 | *.swp
34 | *.hprof
35 | *.hprof.index
36 | *~
37 |
38 | # -----------------------------------------------------------------------------
39 | # OS generated files
40 | # -----------------------------------------------------------------------------
41 | .DS_Store*
42 | ehthumbs.db
43 | Icon?
44 | Thumbs.db
45 |
46 | # -----------------------------------------------------------------------------
47 | # Maven generated files
48 | # -----------------------------------------------------------------------------
49 | target/
50 | */target/
51 | out/
52 |
53 | # -----------------------------------------------------------------------------
54 | # IntelliJ IDEA
55 | # -----------------------------------------------------------------------------
56 | # Not safe to share any of this across different IDEA major versions. Use the POMs.
57 | *.iml
58 | *.iws
59 | *.releaseBackup
60 |
61 | .idea
62 | .idea/.name
63 | .idea/artifacts/
64 | .idea/workspace.xml
65 | .idea/dataSources.xml
66 | .idea/sqlDataSources.xml
67 | .idea/dynamic.xml
68 | .idea/compiler.xml
69 | .idea/misc.xml
70 | .idea/tasks.xml
71 | .idea/uiDesigner.xml
72 | .idea/libraries/*
73 | .idea/dictionaries/*
74 | .idea/modules.xml
75 | .idea/scopes/*
76 |
77 | # .idea/inspectionProfiles/*
78 |
79 | atlassian-ide-plugin.xml
80 |
81 | # -----------------------------------------------------------------------------
82 | # Eclipse files
83 | # -----------------------------------------------------------------------------
84 | .classpath
85 | .project
86 | .settings
87 | .cache
88 |
89 | # -----------------------------------------------------------------------------
90 | # Netbeans files
91 | # -----------------------------------------------------------------------------
92 | nb-configuration.xml
93 | *.orig
94 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 |
2 | Apache License
3 | Version 2.0, January 2004
4 | http://www.apache.org/licenses/
5 |
6 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
7 |
8 | 1. Definitions.
9 |
10 | "License" shall mean the terms and conditions for use, reproduction,
11 | and distribution as defined by Sections 1 through 9 of this document.
12 |
13 | "Licensor" shall mean the copyright owner or entity authorized by
14 | the copyright owner that is granting the License.
15 |
16 | "Legal Entity" shall mean the union of the acting entity and all
17 | other entities that control, are controlled by, or are under common
18 | control with that entity. For the purposes of this definition,
19 | "control" means (i) the power, direct or indirect, to cause the
20 | direction or management of such entity, whether by contract or
21 | otherwise, or (ii) ownership of fifty percent (50%) or more of the
22 | outstanding shares, or (iii) beneficial ownership of such entity.
23 |
24 | "You" (or "Your") shall mean an individual or Legal Entity
25 | exercising permissions granted by this License.
26 |
27 | "Source" form shall mean the preferred form for making modifications,
28 | including but not limited to software source code, documentation
29 | source, and configuration files.
30 |
31 | "Object" form shall mean any form resulting from mechanical
32 | transformation or translation of a Source form, including but
33 | not limited to compiled object code, generated documentation,
34 | and conversions to other media types.
35 |
36 | "Work" shall mean the work of authorship, whether in Source or
37 | Object form, made available under the License, as indicated by a
38 | copyright notice that is included in or attached to the work
39 | (an example is provided in the Appendix below).
40 |
41 | "Derivative Works" shall mean any work, whether in Source or Object
42 | form, that is based on (or derived from) the Work and for which the
43 | editorial revisions, annotations, elaborations, or other modifications
44 | represent, as a whole, an original work of authorship. For the purposes
45 | of this License, Derivative Works shall not include works that remain
46 | separable from, or merely link (or bind by name) to the interfaces of,
47 | the Work and Derivative Works thereof.
48 |
49 | "Contribution" shall mean any work of authorship, including
50 | the original version of the Work and any modifications or additions
51 | to that Work or Derivative Works thereof, that is intentionally
52 | submitted to Licensor for inclusion in the Work by the copyright owner
53 | or by an individual or Legal Entity authorized to submit on behalf of
54 | the copyright owner. For the purposes of this definition, "submitted"
55 | means any form of electronic, verbal, or written communication sent
56 | to the Licensor or its representatives, including but not limited to
57 | communication on electronic mailing lists, source code control systems,
58 | and issue tracking systems that are managed by, or on behalf of, the
59 | Licensor for the purpose of discussing and improving the Work, but
60 | excluding communication that is conspicuously marked or otherwise
61 | designated in writing by the copyright owner as "Not a Contribution."
62 |
63 | "Contributor" shall mean Licensor and any individual or Legal Entity
64 | on behalf of whom a Contribution has been received by Licensor and
65 | subsequently incorporated within the Work.
66 |
67 | 2. Grant of Copyright License. Subject to the terms and conditions of
68 | this License, each Contributor hereby grants to You a perpetual,
69 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70 | copyright license to reproduce, prepare Derivative Works of,
71 | publicly display, publicly perform, sublicense, and distribute the
72 | Work and such Derivative Works in Source or Object form.
73 |
74 | 3. Grant of Patent License. Subject to the terms and conditions of
75 | this License, each Contributor hereby grants to You a perpetual,
76 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77 | (except as stated in this section) patent license to make, have made,
78 | use, offer to sell, sell, import, and otherwise transfer the Work,
79 | where such license applies only to those patent claims licensable
80 | by such Contributor that are necessarily infringed by their
81 | Contribution(s) alone or by combination of their Contribution(s)
82 | with the Work to which such Contribution(s) was submitted. If You
83 | institute patent litigation against any entity (including a
84 | cross-claim or counterclaim in a lawsuit) alleging that the Work
85 | or a Contribution incorporated within the Work constitutes direct
86 | or contributory patent infringement, then any patent licenses
87 | granted to You under this License for that Work shall terminate
88 | as of the date such litigation is filed.
89 |
90 | 4. Redistribution. You may reproduce and distribute copies of the
91 | Work or Derivative Works thereof in any medium, with or without
92 | modifications, and in Source or Object form, provided that You
93 | meet the following conditions:
94 |
95 | (a) You must give any other recipients of the Work or
96 | Derivative Works a copy of this License; and
97 |
98 | (b) You must cause any modified files to carry prominent notices
99 | stating that You changed the files; and
100 |
101 | (c) You must retain, in the Source form of any Derivative Works
102 | that You distribute, all copyright, patent, trademark, and
103 | attribution notices from the Source form of the Work,
104 | excluding those notices that do not pertain to any part of
105 | the Derivative Works; and
106 |
107 | (d) If the Work includes a "NOTICE" text file as part of its
108 | distribution, then any Derivative Works that You distribute must
109 | include a readable copy of the attribution notices contained
110 | within such NOTICE file, excluding those notices that do not
111 | pertain to any part of the Derivative Works, in at least one
112 | of the following places: within a NOTICE text file distributed
113 | as part of the Derivative Works; within the Source form or
114 | documentation, if provided along with the Derivative Works; or,
115 | within a display generated by the Derivative Works, if and
116 | wherever such third-party notices normally appear. The contents
117 | of the NOTICE file are for informational purposes only and
118 | do not modify the License. You may add Your own attribution
119 | notices within Derivative Works that You distribute, alongside
120 | or as an addendum to the NOTICE text from the Work, provided
121 | that such additional attribution notices cannot be construed
122 | as modifying the License.
123 |
124 | You may add Your own copyright statement to Your modifications and
125 | may provide additional or different license terms and conditions
126 | for use, reproduction, or distribution of Your modifications, or
127 | for any such Derivative Works as a whole, provided Your use,
128 | reproduction, and distribution of the Work otherwise complies with
129 | the conditions stated in this License.
130 |
131 | 5. Submission of Contributions. Unless You explicitly state otherwise,
132 | any Contribution intentionally submitted for inclusion in the Work
133 | by You to the Licensor shall be under the terms and conditions of
134 | this License, without any additional terms or conditions.
135 | Notwithstanding the above, nothing herein shall supersede or modify
136 | the terms of any separate license agreement you may have executed
137 | with Licensor regarding such Contributions.
138 |
139 | 6. Trademarks. This License does not grant permission to use the trade
140 | names, trademarks, service marks, or product names of the Licensor,
141 | except as required for reasonable and customary use in describing the
142 | origin of the Work and reproducing the content of the NOTICE file.
143 |
144 | 7. Disclaimer of Warranty. Unless required by applicable law or
145 | agreed to in writing, Licensor provides the Work (and each
146 | Contributor provides its Contributions) on an "AS IS" BASIS,
147 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148 | implied, including, without limitation, any warranties or conditions
149 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150 | PARTICULAR PURPOSE. You are solely responsible for determining the
151 | appropriateness of using or redistributing the Work and assume any
152 | risks associated with Your exercise of permissions under this License.
153 |
154 | 8. Limitation of Liability. In no event and under no legal theory,
155 | whether in tort (including negligence), contract, or otherwise,
156 | unless required by applicable law (such as deliberate and grossly
157 | negligent acts) or agreed to in writing, shall any Contributor be
158 | liable to You for damages, including any direct, indirect, special,
159 | incidental, or consequential damages of any character arising as a
160 | result of this License or out of the use or inability to use the
161 | Work (including but not limited to damages for loss of goodwill,
162 | work stoppage, computer failure or malfunction, or any and all
163 | other commercial damages or losses), even if such Contributor
164 | has been advised of the possibility of such damages.
165 |
166 | 9. Accepting Warranty or Additional Liability. While redistributing
167 | the Work or Derivative Works thereof, You may choose to offer,
168 | and charge a fee for, acceptance of support, warranty, indemnity,
169 | or other liability obligations and/or rights consistent with this
170 | License. However, in accepting such obligations, You may act only
171 | on Your own behalf and on Your sole responsibility, not on behalf
172 | of any other Contributor, and only if You agree to indemnify,
173 | defend, and hold each Contributor harmless for any liability
174 | incurred by, or claims asserted against, such Contributor by reason
175 | of your accepting any such warranty or additional liability.
176 |
177 | END OF TERMS AND CONDITIONS
178 |
179 | Copyright 2018, Stichting Mapcode Foundation
180 |
181 | Licensed under the Apache License, Version 2.0 (the "License");
182 | you may not use this file except in compliance with the License.
183 | You may obtain a copy of the License at
184 |
185 | http://www.apache.org/licenses/LICENSE-2.0
186 |
187 | Unless required by applicable law or agreed to in writing, software
188 | distributed under the License is distributed on an "AS IS" BASIS,
189 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
190 | See the License for the specific language governing permissions and
191 | limitations under the License.
192 |
--------------------------------------------------------------------------------
/NOTICE:
--------------------------------------------------------------------------------
1 | -------------------------------------------------------------------------------
2 | MAPCODE JAVASCRIPT LIBRARY
3 | -------------------------------------------------------------------------------
4 |
5 | Original C library created by Pieter Geelen. Work on Java version
6 | of the Mapcode library by Rijn Buve (original port by Matthew Lowden).
7 |
8 | Copyright (C) 2003-2018 Stichting Mapcode Foundation (http://www.mapcode.com)
9 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # Mapcode Library for JavaScript
2 |
3 | [](https://www.codacy.com/app/rijnb/mapcode-js?utm_source=github.com&utm_medium=referral&utm_content=mapcode-foundation/mapcode-js&utm_campaign=Badge_Grade)
4 | []()
5 | [](https://github.com/mapcode-foundation/mapcode-js/releases)
6 |
7 |
8 | **Copyright (C) 2003-2018 Stichting Mapcode Foundation (http://www.mapcode.com)**
9 |
10 | ----
11 |
12 | **Online documentation can be found at: http://mapcode-foundation.github.io/mapcode-js/**
13 |
14 | If you plan to use mapcodes in HTML/Javascript extensively, you may be interested in
15 | looking at running an instance of a Mapcode REST API server in your applications
16 | landscape.
17 |
18 | This reduces the payload the HTML/Javascript tremendously, as the mapcode tables will
19 | not need to be transported to the client.
20 |
21 | You can find the Mapcode REST API sources, ready to be deployed on any JVM server,
22 | like Tomcat or Jetty, on: **https://github.com/mapcode-foundation/mapcode-rest-service**
23 |
24 | # License
25 |
26 | Licensed under the Apache License, Version 2.0 (the "License");
27 | you may not use this file except in compliance with the License.
28 | You may obtain a copy of the License at
29 |
30 | http://www.apache.org/licenses/LICENSE-2.0
31 |
32 | Unless required by applicable law or agreed to in writing, software
33 | distributed under the License is distributed on an "AS IS" BASIS,
34 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
35 | See the License for the specific language governing permissions and
36 | limitations under the License.
37 |
38 | Original C library created by Pieter Geelen. Work on Java version
39 | of the Mapcode library by Rijn Buve and Matthew Lowden.
40 |
41 | # Javascript Files for Mapcode Support
42 |
43 | The following files provide the Javascript interfaces for mapcodes:
44 |
45 | mapcode.js - Key routines for mapcode support
46 | ndata.js - Data table for mapcode support
47 |
48 | sample.html - Sample code to interpret / generate mapcodes
49 | ctrynams.js - Optional js array with the names of territories (in English)
50 |
51 | To run the Javascript unit tests, simply open the file `unittest/unittest/html`.
52 |
53 | # Using the Library
54 |
55 | ## Converting a Coordinate into a Mapcode
56 |
57 | In the mapcode system, territories are limited by rectangles, not by actual or political borders.
58 | This means that a coordinate will often yield mapcode possibilities in more than one territory.
59 | Each possibility correctly represents the coordinate, but which one is *politically* correct is a
60 | choice that must be made (in advance or afterwards) by the caller or user of the routines.
61 |
62 | There are several routines to generate the possible mapcodes for a coordinate.
63 | The right one to use depends on the situation. All routines take a latitude and a longitude,
64 | and all routines yield an array of possible mapcodes, with the following structure:
65 |
66 | attribute | description
67 | --- | ---
68 | fullmapcode | string, full mapcode including full territory alphacode
69 | mapcode | string, full mapcode excluding territory alphacode
70 | territoryAlphaCode | string, full territory alphacode
71 |
72 | ### The Shortest Mapcode
73 |
74 | The most widely used routine to generate mapcodes is probably:
75 |
76 | encodeShortest(lat, lon, territory)
77 |
78 | parameter | description
79 | --- | ---
80 | lat | latitude in degrees (maximized by routine to 90.0 and minimized to -90.0)
81 | lon | longitude in degrees (all values allowed, wrapped to -180.0 and +180.0)
82 | territory | a territory (an iso code such as “NLD”)
83 | return value | an array of result records (see above)
84 |
85 | This routine will yield at most one result: the shortest mapcode (if any) that exists
86 | for that coordinate within the specified territory. Such a mapcode is also
87 | sometimes called the “default mapcode” for a particular territory.
88 |
89 | Example Javascript:
90 |
91 | function displayMapcodes(e) {
92 | document.write('',e.length,' result(s) ');
93 | for(var i = 0; i < e.length; i++) {
94 | if (e[i].territoryAlphaCode != "AAA") {
95 | document.write(e[i].territoryAlphaCode, ' ');
96 | }
97 | document.write('', e[i].mapcode, ' ');
98 | }
99 | }
100 | displayMapcodes(encodeShortest(34.00956, -118.210572, 'US-CA'));
101 |
102 | Output:
103 |
104 | 1 result(s):
105 | US-CA XX.XX
106 |
107 | To get a mapcode for every territory in which a coordinate can be encoded, use
108 |
109 | encodeShortest(lat, lon)
110 |
111 | Since any coordinate is somewhere on the world, this routine is guaranteed to deliver at least one possibility.
112 |
113 | Example Javascript:
114 |
115 | var e = encodeShortest(34.00956, -118.210572);
116 |
117 | Output using displayMapcodes(e):
118 |
119 | 3 result(s)
120 | US-CA XX.XX
121 | USA KKYP.19MN
122 | R59KJ.W5FT
123 |
124 | This particular coordinate thus has a California mapcode (`XX.XX`), a national 8-letter mapcode,
125 | and (like any coordinate) an international 9-letter mapcode (by tradition shown without its
126 | alphacode “`AAA`”).
127 |
128 | ### All Possible Mapcodes
129 |
130 | Even within a particular territory, there are often several possible mapcodes.
131 |
132 | encode(lat,lon, territory)
133 |
134 | will yield all possible mapcodes (if any) within the specified territory, while
135 |
136 | encode(lat, lon)
137 |
138 | will simply yield all mapcodes that can represent the coordinate.
139 |
140 | Example Javascript:
141 |
142 | var e = encode(36.115, -115.1731, 'US-NV');
143 |
144 | Output using `displayMapcodes(e)`:
145 |
146 | 5 result(s)
147 | US-NV CN.NN
148 | US-NV BX.5KF
149 | US-NV NJ7.127
150 | US-NV F978.JY1
151 | US-NV L70X.6V4G
152 |
153 | The results are ordered by length, the first is the shortest (the default).
154 | The last is usually the “national” encoding, i.e. a format that all coordinates within a
155 | country share. Of course, the shortest mapcode is preferred in almost every circumstance.
156 |
157 | Example Javascript:
158 |
159 | var e = encode(36.115, -115.1731);
160 |
161 | Output using `displayMapcodes(e)`:
162 |
163 | 9 result(s)
164 | US-NV CN.NN
165 | US-NV BX.5KF
166 | US-NV NJ7.127
167 | US-NV F978.JY1
168 | US-NV L70X.6V4G
169 | US-CA F978.JY1
170 | US-CA L70X.6V4G
171 | USA L70X.6V4G
172 | R5KDM.C8C8
173 |
174 | Note that two of these (in `US-CA`) are politically incorrect, since the specified coordinate
175 | lies within the borders of Nevada and not California. However, they are valid in that the
176 | mapcodes correctly represent the original coordinate.
177 |
178 | ### International Mapcodes
179 |
180 | For very specific applications, the following routine only returns the international mapcode
181 |
182 | encodeInternational(lat, lon)
183 |
184 | returns an array with exactly one result: the 9-letter international mapcode representing
185 | the coordinate.
186 |
187 | ### Higher Precision Mapcodes
188 |
189 | A mapcode represents a coordinate with a precision of a few meters. To be precise,
190 | most mapcodes represent the center point of a 10x10 meter area. The coordinate may
191 | thus be 5 meters off both longitudinally and latitudinal, or 3.6 meters on average.
192 | This is precise enough for everyday use, but mapcodes can also be generate with higher
193 | precisions. With one extra letter (after a hyphen), a mapcode represents a 2x2 meter area,
194 | with two letters, an area of a square foot. The extra letters defeat the purpose of the
195 | mapcode system (which is to offer short, easy codes for everyday use) but there may be
196 | cases where the extra letters are appropriate.
197 |
198 | For all routines mentioned, there are “`WithPrecision`” variants:
199 |
200 | encodeShortestWithPrecision(lat, lon, territory, precision)
201 | encodeShortestWithPrecision(lat, lon, precision)
202 | encodeWithPrecision(lat, lon, territory, precision)
203 | encodeWithPrecision(lat, lon, precision)
204 | encodeInternationalWithPrecision(lat, lon, precision)
205 |
206 | where precision is an integer specifying how many extra letters must be generated.
207 | Using the value 0 just yields normal mapcodes.
208 |
209 | ## Converting a Mapcode into a Coordinate
210 |
211 | Given a string with a mapcode (which may or may not include a territory alphacode and may or may not include high-precision letters at the end), the following routines are available to decode them back to a coordinate:
212 |
213 | decode(mapcodeString)
214 |
215 | parameter | description |
216 | --- | ---
217 | mapcodeString | a string containing a mapcode
218 | return value | an object with fields `x` (longitude) and `y` (latitude), or false
219 |
220 | This routine is sufficient to decode a full mapcodeString into a coordinate.
221 |
222 | Example Javascript:
223 |
224 | var result = decode('NLD 49.4V');
225 | document.write(result.y + ',' + result.x + ' ');
226 |
227 | Output:
228 |
229 | 52.376514, 4. 908543375
230 |
231 | However, in daily life you will often have to cope with mapcodes provided by people who
232 | abbreviate or completely leave out the alphacode of the territory. For example, the
233 | alphacode `US-AR` may have been abbreviated to `AR`, which within the context of the
234 | United States of America clearly identifies the state of Arkansas, but could in fact
235 | just as well represent Arunachal Pradesh, India. Someone in The Netherlands may even
236 | abbreviate a mapcode to just “`49.4V`”, assuming that the country is obvious.
237 |
238 | The following routine provides an argument to “help” decoding such input:
239 |
240 | decode(mapcodeString, contextTerritory)
241 |
242 | parameter | description
243 | --- | ---
244 | mapcodeString | a string containing a mapcode
245 | contextTerritory | a string (an ISO code such as “NLD”)
246 | return value | an object with fields `x` (longitude) and `y` (latitude), or false
247 |
248 | By passing a context territory, you allow the decode routine to solve any ambiguities.
249 |
250 | Example Javascript:
251 |
252 | // Assume the user of the system is Delhi, India
253 | var defaultcontext = 'IN-DL';
254 |
255 | var result;
256 | result = decode('US-AR 49.4V', defaultcontext);
257 | document.write(result.y + ',' + result.x + ' ');
258 | result = decode('AR 49.4V', defaultcontext);
259 | document.write(result.y + ',' + result.x + ' ');
260 | result = decode('49.4V', defaultcontext);
261 | document.write(result.y + ',' + result.x + ' ');
262 | result = decode('xxx.xxxx', defaultcontext);
263 | document.write(result.y + ',' + result.x + ' ');
264 |
265 | Output:
266 |
267 | 34.77035,-92.3273875
268 | 27.0693605,93.59582
269 | 28.648506,77.183788
270 | 24.423323,92.506517
271 |
272 | Thus, the first, complete mapcode (`US-AR 49.4V`) does not require the provided context,
273 | and simply returns a coordinate in Arkansas. But the second, specifying only `AR`,
274 | is interpreted as `IN-AR` (without the context, it might just as well have been
275 | interpreted as Arkansas, USA). The third and fourth examples specify no territory
276 | whatsoever so could never be interpreted correctly without the aid of the context provided.
277 | The third, `49.4V`, is simply interpreted within the specified context, `IN-DL`, and yields a
278 | New Delhi address. The fourth can not be interpreted in the state of Delhi, but can be
279 | interpreted in India and yields a coordinate in Assam. Note that the input “`49.4V`”
280 | would not have yielded results if the context had been `IND` (since many states in
281 | India have mapcode `49.4V`).
282 |
283 | ## Routines Related to Territories
284 |
285 | getTerritoryFullname(territory)
286 |
287 | parameter | description
288 | --- | ---
289 | territory | an string (an ISO code such as “`NLD`”)
290 | return value | string (the full name of the territory)
291 |
292 | isSubdivision(territory)
293 |
294 | parameter | description
295 | --- | ---
296 | territory | an string (an ISO code such as “`NLD`”)
297 | return value | true iff territory is a subdivision of a country
298 |
299 | hasSubdivisions(territory)
300 |
301 | parameter | description
302 | --- | ---
303 | territory | an string (an ISO code such as “`NLD`”)
304 | return value | true iff territory is a country that has subdivisions
305 |
306 | getTerritoryAlphaCode(territory, format)
307 |
308 | parameter | description
309 | --- | ---
310 | territory | string (or internal integer between 0 and `ccode_earth`)
311 | format | 0: leave out country for subdivisions
312 | . | undefined or 1: always return full abbreviation
313 | . | 2: leave out country for subdivisions unless this would make the abbreviation ambigious
314 | return value | territory abbreviation in the specified format, or empty
315 |
316 | ## Routines Related to Distance
317 |
318 | distanceInMeters(lat1, lon1, lat2, lon2)
319 |
320 | parameter | description
321 | --- | ---
322 | lat1, lon1 | a latitude/longitude (in degrees)
323 | lat2, lon2 | another latitude/longitude (in degrees)
324 | return value | distance between the coordinates, in meters
325 |
326 | **Note:** estimate, only correct for coordinates that are within a few miles of each other.
327 |
328 | maxErrorInMeters(precision)
329 |
330 | parameter | description
331 | --- | ---
332 | precision | the number of “high precision digits” in a mapcode
333 | return value | worst-case distance in meters between the original coordinate and the decode location of the mapcode.
334 |
335 | ## Routines Related to Unicode and Alphabets
336 |
337 | Mapcodes may be specified in other alphabets. These routines takes a mapcode in any
338 | alphabet and returns its equivalent in the target alphabet. Characters that have no
339 | roman equivalent in the mapcode system are replaced by question marks. Territories
340 | (in fact anything before a separating space) are left untouched.
341 |
342 | convertToAlphabet(mapcode, targetAlphabet)
343 | convertToAlphabetAsHTML(mapcode, targetAlphabet)
344 |
345 | parameter | description
346 | --- | ---
347 | mapcode | a string
348 | targetAlphabet | an integer (identifying one of the languages)
349 | return value | a string
350 |
351 | Example Javascript:
352 |
353 | document.write(convertToAlphabetAsHTML(‘PQ.RS’, 4) ,’ ’)
354 | document.write(convertToAlphabetAsHTML(‘PQ.RS’, 2) ,’ ’)
355 |
356 | Output:
357 |
358 | नप.भम
359 | РФ.ЯЦ
360 |
361 | The following alphabets have been approved for official use,
362 |
363 | 0: roman
364 | 2: cyrillic
365 | 4: hindi
366 | 12: gurmukhi
367 |
368 | Other values are available but have not yet officially been formally approved:
369 |
370 | 1: Greek
371 | 3: Hebrew
372 | 5: Malay
373 | 6: Georgian
374 | 7: Katakana
375 | 8: Thai
376 | 9: Lao
377 | 10: Armenian
378 | 11: Bengali
379 | 13: Tibetan
380 |
381 | Please check http://www.mapcode.com to see if there is a more up-to-date version.
382 |
383 |
384 | # Version History
385 |
386 | ### 2.4.1 - 2.4.2
387 |
388 | * Fixed bug in `getTerritoryAlphaCode` when getting the shortest unambiguous code for `US-CA`,
389 | which is `CA`, not `US-CA`.
390 |
391 | ### 2.4.0
392 |
393 | * Added scripts for Korean (Choson'gul / Hangul), Burmese, Khmer, Sinhalese, Thaana (Maldivan),
394 | Chinese (Zhuyin, Bopomofo), Tifinagh (Berber), Tamil, Amharic, Telugu, Odia, Kannada, Gujarati.
395 |
396 | * Renamed language strings to more correct terms (Malay to Malayalam; Hindi to Devanagari).
397 |
398 | * Added var `alphabetsForTerritory[t]`, returning the most commonly used alphabets for territory `t`.
399 |
400 | * Improved some characters for Arabic and Devanagari.
401 | *
402 | Fixed Bengali to also support Assamese.
403 |
404 | * For some alphabets, removed recognition of letters `I` and/or `O` unless looking like digits `1` and/or `0`.
405 |
406 | * Replaced internal encoded `entity_iso[]` array by non-encoded `iso3166alpha[]`.
407 |
408 | ### 2.3.1
409 |
410 | * Minor fixes to prevent some compiler warnings, or multiple inclusion of `.h` files.
411 |
412 | * Minor data fix (`ndata.js`) for Gansu Province, China (where mountain range extending further west).
413 |
414 | ### 2.3.0
415 |
416 | * Arabic script added.
417 | * Tibetan script changed so all characters can be typed on a computer keyboard without using the SHIFT key.
418 |
419 | * Greek, Hebrew and Arabic, the scripts that have (implied) vowels in mapcode sequences, have been extended with
420 | ABJAD conversion, to prevent more than two consecutive non-digits from occurring.
421 |
422 | * NOTE: as a result, mapcodes in Greek, Arab and Hebrew scripts are now often one character longer than in the roman script.
423 |
424 | ### 2.2.0
425 |
426 | * Solved 1-microdegree gap in a few spots on Earth, noticable now extreme precision is possible;
427 |
428 | * Ran source through code prettifier
429 |
430 | ### 2.1.5
431 |
432 | * Added maxErrorInMeters to API;
433 |
434 | * Enforce `encode(decode(m)) == m` except near territory borders
435 |
436 | * Stricter unit tests;
437 |
438 | ### 2.1.1
439 |
440 | * Added DistanceInMeters to API
441 |
442 | ### 2.1.0
443 |
444 | * Rewrote fraction floating points to integer arithmetic
445 |
446 | ### 2.0.3
447 |
448 | * Minor fix. Added `unittest\unittest.html` - open to peform
449 | tests that try to verify that the library works as intended;
450 |
451 | ### 2.0.1
452 |
453 | * Minor fixes.
454 |
455 | ### 2.0.0 - July 2015
456 |
457 | * Fixes to the data rectangles (primarily intended for ISO proposal), see Word document for details.
458 |
459 | ### 1.54 - June 2015
460 |
461 | * Removed unneeded mminfo flags (no effect on functionality).
462 |
463 | ### 1.50.3 - May 2015
464 |
465 | * Redesign of the API to conform to Javascript standards and match the Java implementation of the mapcode system
466 |
467 | ### 1.50.1 - May 2015
468 |
469 | * Bugfix for mapcodes in IN-DD (in India).
470 |
471 | ### 1.50 - May 2015
472 |
473 | * Major release. This version is not backwards compatible with mapcode 1.4x: it has dropped support for
474 | Antartica AT0-8 codes and has a changed (improved) way of dealing with the Greek alphabet.
475 |
476 | * Added 22-chararcter post-processing of all-digit mapcodes for the Greek alphabet.
477 |
478 | * Retired legacy aliases EAZ and SKM, AU-QL, AU-TS, AU-NI and AU-JB.
479 |
480 | * Retired legacy Antarctica claims AT0 through AT8.
481 |
482 | ### 1.41 - January 2015
483 |
484 | * Added the India state Telangana (IN-TG), until 2014 a region in Adhra Pradesh.
485 |
486 | ### 1.33 - August 2014
487 |
488 | * Normalise results when longitude below -180 degrees.
489 |
490 | ### 1.32 - August 2014
491 |
492 | * Prevent FIJI failing to decode at exactly 180 degrees.
493 |
494 | * Prevent invalid filtering near the territory bounding rectangle.
495 |
496 | ### 1.31 - April 2014
497 |
498 | * Make `iso2ccode()` even more forgiving by allowing a state alias to be recognized in context.
499 |
500 | ### 1.3 - April 2014
501 |
502 | * Disable 7-char state codes for large states in India, and instead generate country mapcodes for states.
503 |
504 | ### 1.28 - April 2014
505 |
506 | * Fix for starpipe "zoning" error, causing the last 2 mapcode characters to be ignored in certain areas.
507 |
508 | ### 1.27 - April 2014
509 |
510 | * Support undefined ranges in data array (useful for partial JavaScript builds).
511 |
512 | ### 1.26 - May 2013
513 |
514 | * Added alias OD for India, and 2.3 code for Daman and Diu.
515 |
516 | ### 1.25 - May 2013
517 |
518 | * `Ccode2iso(c, 2)` support added.
519 |
520 | ### 1.24 - May 2013
521 |
522 | * Public domain release.
523 |
524 |
--------------------------------------------------------------------------------
/ctrynams.js:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2003-2018 Stichting Mapcode Foundation (http://www.mapcode.com)
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | // *** GENERATED FILE (coords.cpp), DO NOT CHANGE OR PRETTIFY ***
18 |
19 | var isofullname = [
20 | "Vatican (Holy See) (_ City State)",
21 | "Monaco (Principality of _)",
22 | "Gibraltar",
23 | "Tokelau",
24 | "Cocos Islands (Keeling Islands)",
25 | "Saint-Barthelemy (Collectivity of _)",
26 | "Nauru (Republic of _)",
27 | "Tuvalu",
28 | "Macau (Aomen)",
29 | "Sint Maarten",
30 | "Saint Martin (Collectivity of _)",
31 | "Norfolk and Philip Island (Philip Island) (Norfolk Island)",
32 | "Pitcairn Islands (Pitcairn, Henderson, Ducie and Oeno Islands)",
33 | "Bouvet Island",
34 | "Bermuda (Somers Isles)",
35 | "British Indian Ocean Territory",
36 | "San Marino (Republic of _)",
37 | "Guernsey (Bailiwick of _)",
38 | "Anguilla",
39 | "Montserrat",
40 | "Jersey (Bailiwick of _)",
41 | "Christmas Island",
42 | "Wallis and Futuna (Futuna) (Wallis) (Collectivity of the _ Islands)",
43 | "British Virgin Islands (Virgin Islands, British)",
44 | "Liechtenstein (Principality of _)",
45 | "Aruba",
46 | "Marshall Islands (Republic of the _)",
47 | "American Samoa (Samoa, American)",
48 | "Cook Islands",
49 | "Saint Pierre and Miquelon (Miquelon) (Saint Pierre) (Collectivity of _)",
50 | "Niue",
51 | "Saint Kitts and Nevis (Nevis) (Saint Kitts) (Federation of _)",
52 | "Cayman islands",
53 | "Bonaire, St Eustasuis and Saba (Bonaire) (Saba) (St Eustasius)",
54 | "Maldives (Republic of _)",
55 | "Saint Helena, Ascension and Tristan da Cunha (Saint Helena) (Ascension) (Tristan da Cunha)",
56 | "Malta (Republic of _)",
57 | "Grenada",
58 | "Virgin Islands of the United States (US Virgin Islands) (American Virgin Islands)",
59 | "Mayotte (Maore)",
60 | "Svalbard and Jan Mayen (Svalbard) (Jan Mayen) (Spitsbergen)",
61 | "Saint Vincent and the Grenadines (Saint Vincent) (Grenadines)",
62 | "Heard Island and McDonald Islands (Heard Island) (McDonald Islands)",
63 | "Barbados",
64 | "Antigua and Barbuda (Antigua) (Barbuda)",
65 | "Curacao",
66 | "Seychelles (Republic of _)",
67 | "Palau (Republic of _)",
68 | "Northern Mariana Islands (Commonwealth of the _)",
69 | "Andorra (Principality of _) (Principality of the Valleys of _)",
70 | "Guam",
71 | "Isle of Mann (Mann)",
72 | "Saint Lucia",
73 | "Micronesia (Federated States of Micronesia)",
74 | "Singapore (Republic of _)",
75 | "Tonga (Kingdom of _)",
76 | "Dominica (Commonwealth of _)",
77 | "Bahrain (Kingdom of _)",
78 | "Kiribati (Republic of _)",
79 | "Turks and Caicos Islands (Turks Islands) (Caicos Islands)",
80 | "Sao Tome and Principe (Sao Tome) (Principe) (Democratic Republic of _)",
81 | "Hong Kong (Xianggang)",
82 | "Martinique",
83 | "Faroe Islands",
84 | "Guadeloupe",
85 | "Comoros (Union of the _)",
86 | "Mauritius (Republic of _)",
87 | "Reunion",
88 | "Luxembourg (Grand Duchy of _)",
89 | "Samoa (Independent State of _)",
90 | "South Georgia and the South Sandwich Islands (South Georgia) (South Sandwich Islands)",
91 | "French Polynesia (Collectivity of _)",
92 | "Cape Verde (Cabo Verde) (Republic of Cabo Verde)",
93 | "Trinidad and Tobago (Republic of _) (Trinidad) (Tobago)",
94 | "Brunei (Nation of _, the Abode of Peace)",
95 | "French Southern and Antarctic Lands",
96 | "Puerto Rico (Commonwealth of _)",
97 | "Cyprus (Republic of _)",
98 | "Lebanon (Lebanese Republic)",
99 | "Jamaica",
100 | "Gambia (The Gambia) (Republic of the _)",
101 | "Qatar (State of _)",
102 | "Falkland Islands (The Falklands)",
103 | "Vanuatu (Republic of _)",
104 | "Montenegro",
105 | "Bahamas (Commonwealth of the _)",
106 | "Timor-Leste (Democratic Republic of _) (East Timor)",
107 | "Swaziland (Kingdom of _)",
108 | "Kuwait (State of _)",
109 | "Fiji (Republic of _)",
110 | "New Caledonia",
111 | "Slovenia (Republic of _)",
112 | "Israel (State of _)",
113 | "Palestinian territories (State of Palestine)",
114 | "El Salvador (Republic of _)",
115 | "Belize",
116 | "Djibouti (Republic of _)",
117 | "Macedonia (Republic of _) (FYROM) (Former Yugoslav Republic of Macedonia)",
118 | "Rwanda (Republic of _)",
119 | "Haiti (Republic of _)",
120 | "Burundi (Republic of _)",
121 | "Equatorial Guinea (Republic of _)",
122 | "Albania (Republic of _)",
123 | "Solomon Islands",
124 | "Armenia (Republic of _)",
125 | "Lesotho (Kingdom of _)",
126 | "Belgium (Kingdom of _)",
127 | "Moldova (Republic of _)",
128 | "Guinea-Bissau (Republic of _)",
129 | "Taiwan (Republic of China)",
130 | "Bhutan (Kingdom of _)",
131 | "Switzerland (Swiss Confederation)",
132 | "Netherlands (The Netherlands) (Kingdom of the _)",
133 | "Denmark (Kingdom of _)",
134 | "Estonia (Republic of _)",
135 | "Dominican Republic",
136 | "Slovakia (Slovak Republic)",
137 | "Costa Rica (Republic of _)",
138 | "Bosnia and Herzegovina",
139 | "Croatia (Republic of _)",
140 | "Togo (Togolese Republic)",
141 | "Latvia (Republic of _)",
142 | "Lithuania (Republic of _)",
143 | "Sri Lanka (Democratic Socialist Republic of _)",
144 | "Georgia",
145 | "Ireland (Republic of _)",
146 | "Sierra Leone (Republic of _)",
147 | "Panama (Republic of _)",
148 | "Czech Republic",
149 | "French Guiana (Guiana)",
150 | "United Arab Emirates (Emirates)",
151 | "Austria (Republic of _)",
152 | "Azerbaijan (Republic of _)",
153 | "Serbia (Republic of _)",
154 | "Jordan (Hashemite Kingdom of _) (Kingdom of _)",
155 | "Portugal (Portuguese Republic)",
156 | "Hungary (Republic of _)",
157 | "South Korea (Republic of Korea) (Korea, South)",
158 | "Iceland",
159 | "Guatemala (Republic of _)",
160 | "Cuba (Republic of _)",
161 | "Bulgaria (Republic of _)",
162 | "Liberia (Republic of _)",
163 | "Honduras (Republic of _)",
164 | "Benin (Republic of _)",
165 | "Eritrea (State of _)",
166 | "Malawi (Republic of _)",
167 | "North Korea (Democratic People's Republic of Korea) (Korea, North)",
168 | "Nicaragua (Republic of _)",
169 | "Greece (Hellenic Republic) (Hellas)",
170 | "Tajikistan (Republic of _)",
171 | "Bangladesh (People's Republic of _)",
172 | "Nepal (Federal Democratic Republic of _)",
173 | "Tunisia (Tunisian Republic) (Republic of _)",
174 | "Suriname (Republic of _)",
175 | "Uruguay (Eastern Republic of _)",
176 | "Cambodia (Kingdom of _)",
177 | "Syria (Syrian Arab Republic)",
178 | "Senegal (Republic of _)",
179 | "Kyrgyzstan (Kyrgyz Republic)",
180 | "Belarus (Republic of _)",
181 | "Guyana (Co-operative Republic of _)",
182 | "Laos (Lao People's Democratic Republic)",
183 | "Romania",
184 | "Ghana (Republic of _)",
185 | "Uganda (Republic of _)",
186 | "United Kingdom (Scotland) (Great Britain) (England) (Northern Ireland) (Ireland, Northern) (Britain) (United Kingdom of Great Britain and Northern Ireland)",
187 | "Guinea (Republic of _) (Guinea-Conakry)",
188 | "Ecuador (Republic of _)",
189 | "Western Sahara (Sahrawi Arab Democratic Republic)",
190 | "Gabon (Gabonese Republic)",
191 | "New Zealand",
192 | "Burkina Faso",
193 | "Philippines (Republic of the _)",
194 | "Italy (Italian Republic)",
195 | "Oman (Sultanate of _)",
196 | "Poland (Republic of _)",
197 | "Ivory Coast (Cote d'Ivoire) (Republic of Cote d'Ivoire)",
198 | "Norway (Kingdom of _)",
199 | "Malaysia",
200 | "Vietnam (Socialist Republic of _)",
201 | "Finland (Republic of _)",
202 | "Congo-Brazzaville (West Congo) (Republic of the Congo)",
203 | "Germany (Federal Republic of _)",
204 | "Japan",
205 | "Zimbabwe (Republic of _)",
206 | "Paraguay (Republic of _)",
207 | "Iraq (Republic of _)",
208 | "Morocco (Kingdom of _)",
209 | "Uzbekistan (Republic of _)",
210 | "Sweden (Kingdom of _)",
211 | "Papua New Guinea (Independent State of _)",
212 | "Cameroon (Republic of _)",
213 | "Turkmenistan",
214 | "Spain (Kingdom of _)",
215 | "Thailand (Kingdom of _)",
216 | "Yemen (Republic of _)",
217 | "France (French Republic)",
218 | "Aaland Islands",
219 | "Kenya (Republic of _)",
220 | "Botswana (Republic of _)",
221 | "Madagascar (Republic of _)",
222 | "Ukraine",
223 | "South Sudan (Republic of _)",
224 | "Central African Republic",
225 | "Somalia (Federal Republic of _)",
226 | "Afghanistan (Islamic Republic of _)",
227 | "Myanmar (Republic of the Union of _) (Burma)",
228 | "Zambia (Republic of _)",
229 | "Chile (Republic of _)",
230 | "Turkey (Republic of _)",
231 | "Pakistan (Islamic Republic of _)",
232 | "Mozambique (Republic of _)",
233 | "Namibia (Republic of _)",
234 | "Venezuela (Bolivarian Republic of _)",
235 | "Nigeria (Federal Republic of _)",
236 | "Tanzania (United Republic of _)",
237 | "Egypt (Arab Republic of _)",
238 | "Mauritania (Islamic Republic of _)",
239 | "Bolivia (Plurinational State of _)",
240 | "Ethiopia (Federal Democratic Republic of _)",
241 | "Colombia (Republic of _)",
242 | "South Africa (Republic of _)",
243 | "Mali (Republic of _)",
244 | "Angola (Republic of _)",
245 | "Niger (Republic of _)",
246 | "Chad (Republic of _)",
247 | "Peru (Republic of _)",
248 | "Mongolia",
249 | "Iran (Persia) (Islamic Republic of _)",
250 | "Libya",
251 | "Sudan (Republic of the _)",
252 | "Indonesia (Republic of _)",
253 | "Federal District",
254 | "Tlaxcala",
255 | "Morelos",
256 | "Aguascalientes",
257 | "Colima",
258 | "Queretaro",
259 | "Hidalgo",
260 | "Mexico State",
261 | "Tabasco",
262 | "Nayarit",
263 | "Guanajuato",
264 | "Puebla",
265 | "Yucatan",
266 | "Quintana Roo",
267 | "Sinaloa",
268 | "Campeche",
269 | "Michoacan",
270 | "San Luis Potosi",
271 | "Guerrero",
272 | "Nuevo Leon (New Leon)",
273 | "Baja California",
274 | "Veracruz",
275 | "Chiapas",
276 | "Baja California Sur",
277 | "Zacatecas",
278 | "Jalisco",
279 | "Tamaulipas",
280 | "Oaxaca",
281 | "Durango",
282 | "Coahuila",
283 | "Sonora",
284 | "Chihuahua",
285 | "Greenland",
286 | "Saudi Arabia (Kingdom of _)",
287 | "Congo-Kinshasa (Democratic Republic of the Congo) (East Congo)",
288 | "Algeria (People's Democratic Republic of _)",
289 | "Kazakhstan (Republic of _)",
290 | "Argentina (Argentine Republic)",
291 | "Daman and Diu",
292 | "Dadra and Nagar Haveli (Dadra) (Nagar Haveli)",
293 | "Chandigarh",
294 | "Andaman and Nicobar (Andaman) (Nicobar)",
295 | "Lakshadweep",
296 | "Delhi (National Capital Territory of _)",
297 | "Meghalaya",
298 | "Nagaland",
299 | "Manipur",
300 | "Tripura",
301 | "Mizoram",
302 | "Sikkim",
303 | "Punjab",
304 | "Haryana",
305 | "Arunachal Pradesh",
306 | "Assam",
307 | "Bihar",
308 | "Uttarakhand",
309 | "Goa",
310 | "Kerala",
311 | "Tamil Nadu",
312 | "Himachal Pradesh",
313 | "Jammu and Kashmir (Jammu) (Kashmir)",
314 | "Chhattisgarh",
315 | "Jharkhand",
316 | "Karnataka",
317 | "Rajasthan",
318 | "Odisha (Orissa)",
319 | "Gujarat",
320 | "West Bengal",
321 | "Madhya Pradesh",
322 | "Telangana",
323 | "Andhra Pradesh",
324 | "Maharashtra",
325 | "Uttar Pradesh",
326 | "Puducherry",
327 | "New South Wales",
328 | "Australian Capital Territory",
329 | "Jervis Bay Territory",
330 | "Northern Territory",
331 | "South Australia",
332 | "Tasmania",
333 | "Victoria",
334 | "Western Australia",
335 | "Queensland",
336 | "Distrito Federal",
337 | "Sergipe",
338 | "Alagoas",
339 | "Rio de Janeiro",
340 | "Espirito Santo",
341 | "Rio Grande do Norte",
342 | "Paraiba",
343 | "Santa Catarina",
344 | "Pernambuco",
345 | "Amapa",
346 | "Ceara",
347 | "Acre",
348 | "Parana",
349 | "Roraima",
350 | "Rondonia",
351 | "Sao Paulo",
352 | "Piaui",
353 | "Tocantins",
354 | "Rio Grande do Sul",
355 | "Maranhao",
356 | "Goias",
357 | "Mato Grosso do Sul",
358 | "Bahia",
359 | "Minas Gerais",
360 | "Mato Grosso",
361 | "Para",
362 | "Amazonas",
363 | "District of Columbia (Washington, D.C.)",
364 | "Rhode Island",
365 | "Delaware",
366 | "Connecticut",
367 | "New Jersey",
368 | "New Hampshire",
369 | "Vermont",
370 | "Massachusetts (Commonwealth of _)",
371 | "Hawaii",
372 | "Maryland",
373 | "West Virginia",
374 | "South Carolina",
375 | "Maine",
376 | "Indiana",
377 | "Kentucky (Commonwealth of _)",
378 | "Tennessee",
379 | "Virginia (Commonwealth of _)",
380 | "Ohio",
381 | "Pennsylvania (Commonwealth of _)",
382 | "Mississippi",
383 | "Louisiana",
384 | "Alabama",
385 | "Arkansas",
386 | "North Carolina",
387 | "New York",
388 | "Iowa",
389 | "Illinois",
390 | "Georgia",
391 | "Wisconsin",
392 | "Florida",
393 | "Missouri",
394 | "Oklahoma",
395 | "North Dakota",
396 | "Washington",
397 | "South Dakota",
398 | "Nebraska",
399 | "Kansas",
400 | "Idaho",
401 | "Utah",
402 | "Minnesota",
403 | "Michigan",
404 | "Wyoming",
405 | "Oregon",
406 | "Colorado",
407 | "Nevada",
408 | "Arizona",
409 | "New Mexico",
410 | "Montana",
411 | "California",
412 | "Texas",
413 | "Alaska",
414 | "British Columbia",
415 | "Alberta",
416 | "Ontario",
417 | "Quebec",
418 | "Saskatchewan",
419 | "Manitoba",
420 | "Newfoundland and Labrador (Newfoundland) (Labrador)",
421 | "New Brunswick",
422 | "Nova Scotia",
423 | "Prince Edward Island",
424 | "Yukon",
425 | "Northwest Territories",
426 | "Nunavut",
427 | "India (Republic of _)",
428 | "Australia (Commonwealth of _)",
429 | "Brazil (Federative Republic of _)",
430 | "USA (United States of America) (America)",
431 | "Mexico (United Mexican States)",
432 | "Moscow",
433 | "Saint Petersburg",
434 | "Kaliningrad Oblast",
435 | "Ingushetia",
436 | "Adygea Republic",
437 | "North Ossetia-Alania Republic",
438 | "Kabardino-Balkar Republic",
439 | "Karachay-Cherkess Republic",
440 | "Chechen Republic (Chechnya) (Ichkeria)",
441 | "Chuvash Republic",
442 | "Ivanovo Oblast",
443 | "Lipetsk Oblast",
444 | "Oryol Oblast",
445 | "Tula Oblast",
446 | "Belgorod Oblast",
447 | "Vladimir Oblast",
448 | "Kursk Oblast",
449 | "Kaluga Oblast",
450 | "Tambov Oblast",
451 | "Bryansk Oblast",
452 | "Yaroslavl Oblast",
453 | "Ryazan Oblast",
454 | "Astrakhan Oblast",
455 | "Moscow Oblast",
456 | "Smolensk Oblast",
457 | "Dagestan Republic",
458 | "Voronezh Oblast",
459 | "Novgorod Oblast",
460 | "Pskov Oblast",
461 | "Kostroma Oblast",
462 | "Stavropol Krai",
463 | "Krasnodar Krai",
464 | "Kalmykia Republic",
465 | "Tver Oblast",
466 | "Leningrad Oblast",
467 | "Rostov Oblast",
468 | "Volgograd Oblast",
469 | "Vologda Oblast",
470 | "Murmansk Oblast",
471 | "Karelia Republic",
472 | "Nenets Autonomous Okrug",
473 | "Komi Republic",
474 | "Arkhangelsk Oblast",
475 | "Mordovia Republic",
476 | "Nizhny Novgorod Oblast",
477 | "Penza Oblast",
478 | "Kirov Oblast",
479 | "Mari El Republic",
480 | "Orenburg Oblast",
481 | "Ulyanovsk Oblast",
482 | "Perm Krai",
483 | "Bashkortostan Republic",
484 | "Udmurt Republic",
485 | "Tatarstan Republic",
486 | "Samara Oblast",
487 | "Saratov Oblast",
488 | "Yamalo-Nenets",
489 | "Khanty-Mansi",
490 | "Sverdlovsk Oblast",
491 | "Tyumen Oblast",
492 | "Kurgan Oblast",
493 | "Chelyabinsk Oblast",
494 | "Buryatia Republic",
495 | "Zabaykalsky Krai",
496 | "Irkutsk Oblast",
497 | "Novosibirsk Oblast",
498 | "Tomsk Oblast",
499 | "Omsk Oblast",
500 | "Khakassia Republic",
501 | "Kemerovo Oblast",
502 | "Altai Republic",
503 | "Altai Krai",
504 | "Tuva Republic",
505 | "Krasnoyarsk Krai",
506 | "Magadan Oblast",
507 | "Chukotka Okrug",
508 | "Kamchatka Krai",
509 | "Sakhalin Oblast",
510 | "Primorsky Krai",
511 | "Jewish Autonomous Oblast",
512 | "Khabarovsk Krai",
513 | "Amur Oblast",
514 | "Sakha Republic (Yakutia Republic)",
515 | "Canada",
516 | "Russia (Russian Federation)",
517 | "Shanghai Municipality",
518 | "Tianjin Municipality",
519 | "Beijing Municipality",
520 | "Hainan Province",
521 | "Ningxia Hui Autonomous Region",
522 | "Chongqing Municipality",
523 | "Zhejiang Province",
524 | "Jiangsu Province",
525 | "Fujian Province",
526 | "Anhui Province",
527 | "Liaoning Province",
528 | "Shandong Province",
529 | "Shanxi Province",
530 | "Jiangxi Province",
531 | "Henan Province",
532 | "Guizhou Province",
533 | "Guangdong Province",
534 | "Hubei Province",
535 | "Jilin Province",
536 | "Hebei Province (Yanzhao Province)",
537 | "Shaanxi Province",
538 | "Nei Mongol Autonomous Region (Inner Mongolia)",
539 | "Heilongjiang Province",
540 | "Hunan Province",
541 | "Guangxi Zhuang Autonomous Region",
542 | "Sichuan Province",
543 | "Yunnan Province",
544 | "Xizang Autonomous Region (Tibet)",
545 | "Gansu Province",
546 | "Qinghai Province (Tsinghai Province)",
547 | "Xinjiang Uyghur Autonomous Region",
548 | "China (People's Republic of _)",
549 | "United States Minor Outlying Islands",
550 | "Clipperton Island",
551 | "Antarctica",
552 | "International (Worldwide) (Earth)",
553 | "?"];
554 |
555 |
--------------------------------------------------------------------------------
/ctrynams_short.js:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2003-2018 Stichting Mapcode Foundation (http://www.mapcode.com)
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | // *** GENERATED FILE (coords.cpp), DO NOT CHANGE OR PRETTIFY ***
18 |
19 | var isofullname = [
20 | "Vatican (Holy See)",
21 | "Monaco",
22 | "Gibraltar",
23 | "Tokelau",
24 | "Cocos Islands (Keeling Islands)",
25 | "Saint-Barthelemy",
26 | "Nauru",
27 | "Tuvalu",
28 | "Macau (Aomen)",
29 | "Sint Maarten",
30 | "Saint Martin",
31 | "Norfolk and Philip Island (Philip Island) (Norfolk Island)",
32 | "Pitcairn Islands (Pitcairn, Henderson, Ducie and Oeno Islands)",
33 | "Bouvet Island",
34 | "Bermuda (Somers Isles)",
35 | "British Indian Ocean Territory",
36 | "San Marino",
37 | "Guernsey",
38 | "Anguilla",
39 | "Montserrat",
40 | "Jersey",
41 | "Christmas Island",
42 | "Wallis and Futuna (Futuna) (Wallis)",
43 | "British Virgin Islands (Virgin Islands, British)",
44 | "Liechtenstein",
45 | "Aruba",
46 | "Marshall Islands",
47 | "American Samoa (Samoa, American)",
48 | "Cook Islands",
49 | "Saint Pierre and Miquelon (Miquelon) (Saint Pierre)",
50 | "Niue",
51 | "Saint Kitts and Nevis (Nevis) (Saint Kitts)",
52 | "Cayman islands",
53 | "Bonaire, St Eustasuis and Saba (Bonaire) (Saba) (St Eustasius)",
54 | "Maldives",
55 | "Saint Helena, Ascension and Tristan da Cunha (Saint Helena) (Ascension) (Tristan da Cunha)",
56 | "Malta",
57 | "Grenada",
58 | "Virgin Islands of the United States (US Virgin Islands) (American Virgin Islands)",
59 | "Mayotte (Maore)",
60 | "Svalbard and Jan Mayen (Svalbard) (Jan Mayen) (Spitsbergen)",
61 | "Saint Vincent and the Grenadines (Saint Vincent) (Grenadines)",
62 | "Heard Island and McDonald Islands (Heard Island) (McDonald Islands)",
63 | "Barbados",
64 | "Antigua and Barbuda (Antigua) (Barbuda)",
65 | "Curacao",
66 | "Seychelles",
67 | "Palau",
68 | "Northern Mariana Islands",
69 | "Andorra",
70 | "Guam",
71 | "Isle of Mann (Mann)",
72 | "Saint Lucia",
73 | "Micronesia (Federated States of Micronesia)",
74 | "Singapore",
75 | "Tonga",
76 | "Dominica",
77 | "Bahrain",
78 | "Kiribati",
79 | "Turks and Caicos Islands (Turks Islands) (Caicos Islands)",
80 | "Sao Tome and Principe (Sao Tome) (Principe)",
81 | "Hong Kong (Xianggang)",
82 | "Martinique",
83 | "Faroe Islands",
84 | "Guadeloupe",
85 | "Comoros",
86 | "Mauritius",
87 | "Reunion",
88 | "Luxembourg",
89 | "Samoa",
90 | "South Georgia and the South Sandwich Islands (South Georgia) (South Sandwich Islands)",
91 | "French Polynesia",
92 | "Cape Verde (Cabo Verde) (Republic of Cabo Verde)",
93 | "Trinidad and Tobago (Trinidad) (Tobago)",
94 | "Brunei",
95 | "French Southern and Antarctic Lands",
96 | "Puerto Rico",
97 | "Cyprus",
98 | "Lebanon (Lebanese Republic)",
99 | "Jamaica",
100 | "Gambia (The Gambia)",
101 | "Qatar",
102 | "Falkland Islands (The Falklands)",
103 | "Vanuatu",
104 | "Montenegro",
105 | "Bahamas",
106 | "Timor-Leste (East Timor)",
107 | "Swaziland",
108 | "Kuwait",
109 | "Fiji",
110 | "New Caledonia",
111 | "Slovenia",
112 | "Israel",
113 | "Palestinian territories (State of Palestine)",
114 | "El Salvador",
115 | "Belize",
116 | "Djibouti",
117 | "Macedonia (FYROM) (Former Yugoslav Republic of Macedonia)",
118 | "Rwanda",
119 | "Haiti",
120 | "Burundi",
121 | "Equatorial Guinea",
122 | "Albania",
123 | "Solomon Islands",
124 | "Armenia",
125 | "Lesotho",
126 | "Belgium",
127 | "Moldova",
128 | "Guinea-Bissau",
129 | "Taiwan (Republic of China)",
130 | "Bhutan",
131 | "Switzerland (Swiss Confederation)",
132 | "Netherlands (The Netherlands)",
133 | "Denmark",
134 | "Estonia",
135 | "Dominican Republic",
136 | "Slovakia (Slovak Republic)",
137 | "Costa Rica",
138 | "Bosnia and Herzegovina",
139 | "Croatia",
140 | "Togo (Togolese Republic)",
141 | "Latvia",
142 | "Lithuania",
143 | "Sri Lanka",
144 | "Georgia",
145 | "Ireland",
146 | "Sierra Leone",
147 | "Panama",
148 | "Czech Republic",
149 | "French Guiana (Guiana)",
150 | "United Arab Emirates (Emirates)",
151 | "Austria",
152 | "Azerbaijan",
153 | "Serbia",
154 | "Jordan",
155 | "Portugal (Portuguese Republic)",
156 | "Hungary",
157 | "South Korea (Republic of Korea) (Korea, South)",
158 | "Iceland",
159 | "Guatemala",
160 | "Cuba",
161 | "Bulgaria",
162 | "Liberia",
163 | "Honduras",
164 | "Benin",
165 | "Eritrea",
166 | "Malawi",
167 | "North Korea (Democratic People's Republic of Korea) (Korea, North)",
168 | "Nicaragua",
169 | "Greece (Hellenic Republic) (Hellas)",
170 | "Tajikistan",
171 | "Bangladesh",
172 | "Nepal",
173 | "Tunisia (Tunisian Republic)",
174 | "Suriname",
175 | "Uruguay",
176 | "Cambodia",
177 | "Syria (Syrian Arab Republic)",
178 | "Senegal",
179 | "Kyrgyzstan (Kyrgyz Republic)",
180 | "Belarus",
181 | "Guyana",
182 | "Laos (Lao People's Democratic Republic)",
183 | "Romania",
184 | "Ghana",
185 | "Uganda",
186 | "United Kingdom (Scotland) (Great Britain) (England) (Northern Ireland) (Ireland, Northern) (Britain) (United Kingdom of Great Britain and Northern Ireland)",
187 | "Guinea (Guinea-Conakry)",
188 | "Ecuador",
189 | "Western Sahara (Sahrawi Arab Democratic Republic)",
190 | "Gabon (Gabonese Republic)",
191 | "New Zealand",
192 | "Burkina Faso",
193 | "Philippines",
194 | "Italy (Italian Republic)",
195 | "Oman",
196 | "Poland",
197 | "Ivory Coast (Cote d'Ivoire) (Republic of Cote d'Ivoire)",
198 | "Norway",
199 | "Malaysia",
200 | "Vietnam",
201 | "Finland",
202 | "Congo-Brazzaville (West Congo) (Republic of the Congo)",
203 | "Germany",
204 | "Japan",
205 | "Zimbabwe",
206 | "Paraguay",
207 | "Iraq",
208 | "Morocco",
209 | "Uzbekistan",
210 | "Sweden",
211 | "Papua New Guinea",
212 | "Cameroon",
213 | "Turkmenistan",
214 | "Spain",
215 | "Thailand",
216 | "Yemen",
217 | "France (French Republic)",
218 | "Aaland Islands",
219 | "Kenya",
220 | "Botswana",
221 | "Madagascar",
222 | "Ukraine",
223 | "South Sudan",
224 | "Central African Republic",
225 | "Somalia",
226 | "Afghanistan",
227 | "Myanmar (Burma)",
228 | "Zambia",
229 | "Chile",
230 | "Turkey",
231 | "Pakistan",
232 | "Mozambique",
233 | "Namibia",
234 | "Venezuela",
235 | "Nigeria",
236 | "Tanzania",
237 | "Egypt",
238 | "Mauritania",
239 | "Bolivia",
240 | "Ethiopia",
241 | "Colombia",
242 | "South Africa",
243 | "Mali",
244 | "Angola",
245 | "Niger",
246 | "Chad",
247 | "Peru",
248 | "Mongolia",
249 | "Iran (Persia)",
250 | "Libya",
251 | "Sudan",
252 | "Indonesia",
253 | "Federal District",
254 | "Tlaxcala",
255 | "Morelos",
256 | "Aguascalientes",
257 | "Colima",
258 | "Queretaro",
259 | "Hidalgo",
260 | "Mexico State",
261 | "Tabasco",
262 | "Nayarit",
263 | "Guanajuato",
264 | "Puebla",
265 | "Yucatan",
266 | "Quintana Roo",
267 | "Sinaloa",
268 | "Campeche",
269 | "Michoacan",
270 | "San Luis Potosi",
271 | "Guerrero",
272 | "Nuevo Leon (New Leon)",
273 | "Baja California",
274 | "Veracruz",
275 | "Chiapas",
276 | "Baja California Sur",
277 | "Zacatecas",
278 | "Jalisco",
279 | "Tamaulipas",
280 | "Oaxaca",
281 | "Durango",
282 | "Coahuila",
283 | "Sonora",
284 | "Chihuahua",
285 | "Greenland",
286 | "Saudi Arabia",
287 | "Congo-Kinshasa (Democratic Republic of the Congo) (East Congo)",
288 | "Algeria",
289 | "Kazakhstan",
290 | "Argentina (Argentine Republic)",
291 | "Daman and Diu",
292 | "Dadra and Nagar Haveli (Dadra) (Nagar Haveli)",
293 | "Chandigarh",
294 | "Andaman and Nicobar (Andaman) (Nicobar)",
295 | "Lakshadweep",
296 | "Delhi",
297 | "Meghalaya",
298 | "Nagaland",
299 | "Manipur",
300 | "Tripura",
301 | "Mizoram",
302 | "Sikkim",
303 | "Punjab",
304 | "Haryana",
305 | "Arunachal Pradesh",
306 | "Assam",
307 | "Bihar",
308 | "Uttarakhand",
309 | "Goa",
310 | "Kerala",
311 | "Tamil Nadu",
312 | "Himachal Pradesh",
313 | "Jammu and Kashmir (Jammu) (Kashmir)",
314 | "Chhattisgarh",
315 | "Jharkhand",
316 | "Karnataka",
317 | "Rajasthan",
318 | "Odisha (Orissa)",
319 | "Gujarat",
320 | "West Bengal",
321 | "Madhya Pradesh",
322 | "Telangana",
323 | "Andhra Pradesh",
324 | "Maharashtra",
325 | "Uttar Pradesh",
326 | "Puducherry",
327 | "New South Wales",
328 | "Australian Capital Territory",
329 | "Jervis Bay Territory",
330 | "Northern Territory",
331 | "South Australia",
332 | "Tasmania",
333 | "Victoria",
334 | "Western Australia",
335 | "Queensland",
336 | "Distrito Federal",
337 | "Sergipe",
338 | "Alagoas",
339 | "Rio de Janeiro",
340 | "Espirito Santo",
341 | "Rio Grande do Norte",
342 | "Paraiba",
343 | "Santa Catarina",
344 | "Pernambuco",
345 | "Amapa",
346 | "Ceara",
347 | "Acre",
348 | "Parana",
349 | "Roraima",
350 | "Rondonia",
351 | "Sao Paulo",
352 | "Piaui",
353 | "Tocantins",
354 | "Rio Grande do Sul",
355 | "Maranhao",
356 | "Goias",
357 | "Mato Grosso do Sul",
358 | "Bahia",
359 | "Minas Gerais",
360 | "Mato Grosso",
361 | "Para",
362 | "Amazonas",
363 | "District of Columbia (Washington, D.C.)",
364 | "Rhode Island",
365 | "Delaware",
366 | "Connecticut",
367 | "New Jersey",
368 | "New Hampshire",
369 | "Vermont",
370 | "Massachusetts",
371 | "Hawaii",
372 | "Maryland",
373 | "West Virginia",
374 | "South Carolina",
375 | "Maine",
376 | "Indiana",
377 | "Kentucky",
378 | "Tennessee",
379 | "Virginia",
380 | "Ohio",
381 | "Pennsylvania",
382 | "Mississippi",
383 | "Louisiana",
384 | "Alabama",
385 | "Arkansas",
386 | "North Carolina",
387 | "New York",
388 | "Iowa",
389 | "Illinois",
390 | "Georgia",
391 | "Wisconsin",
392 | "Florida",
393 | "Missouri",
394 | "Oklahoma",
395 | "North Dakota",
396 | "Washington",
397 | "South Dakota",
398 | "Nebraska",
399 | "Kansas",
400 | "Idaho",
401 | "Utah",
402 | "Minnesota",
403 | "Michigan",
404 | "Wyoming",
405 | "Oregon",
406 | "Colorado",
407 | "Nevada",
408 | "Arizona",
409 | "New Mexico",
410 | "Montana",
411 | "California",
412 | "Texas",
413 | "Alaska",
414 | "British Columbia",
415 | "Alberta",
416 | "Ontario",
417 | "Quebec",
418 | "Saskatchewan",
419 | "Manitoba",
420 | "Newfoundland and Labrador (Newfoundland) (Labrador)",
421 | "New Brunswick",
422 | "Nova Scotia",
423 | "Prince Edward Island",
424 | "Yukon",
425 | "Northwest Territories",
426 | "Nunavut",
427 | "India",
428 | "Australia",
429 | "Brazil",
430 | "USA (United States of America) (America)",
431 | "Mexico (United Mexican States)",
432 | "Moscow",
433 | "Saint Petersburg",
434 | "Kaliningrad Oblast",
435 | "Ingushetia",
436 | "Adygea Republic",
437 | "North Ossetia-Alania Republic",
438 | "Kabardino-Balkar Republic",
439 | "Karachay-Cherkess Republic",
440 | "Chechen Republic (Chechnya) (Ichkeria)",
441 | "Chuvash Republic",
442 | "Ivanovo Oblast",
443 | "Lipetsk Oblast",
444 | "Oryol Oblast",
445 | "Tula Oblast",
446 | "Belgorod Oblast",
447 | "Vladimir Oblast",
448 | "Kursk Oblast",
449 | "Kaluga Oblast",
450 | "Tambov Oblast",
451 | "Bryansk Oblast",
452 | "Yaroslavl Oblast",
453 | "Ryazan Oblast",
454 | "Astrakhan Oblast",
455 | "Moscow Oblast",
456 | "Smolensk Oblast",
457 | "Dagestan Republic",
458 | "Voronezh Oblast",
459 | "Novgorod Oblast",
460 | "Pskov Oblast",
461 | "Kostroma Oblast",
462 | "Stavropol Krai",
463 | "Krasnodar Krai",
464 | "Kalmykia Republic",
465 | "Tver Oblast",
466 | "Leningrad Oblast",
467 | "Rostov Oblast",
468 | "Volgograd Oblast",
469 | "Vologda Oblast",
470 | "Murmansk Oblast",
471 | "Karelia Republic",
472 | "Nenets Autonomous Okrug",
473 | "Komi Republic",
474 | "Arkhangelsk Oblast",
475 | "Mordovia Republic",
476 | "Nizhny Novgorod Oblast",
477 | "Penza Oblast",
478 | "Kirov Oblast",
479 | "Mari El Republic",
480 | "Orenburg Oblast",
481 | "Ulyanovsk Oblast",
482 | "Perm Krai",
483 | "Bashkortostan Republic",
484 | "Udmurt Republic",
485 | "Tatarstan Republic",
486 | "Samara Oblast",
487 | "Saratov Oblast",
488 | "Yamalo-Nenets",
489 | "Khanty-Mansi",
490 | "Sverdlovsk Oblast",
491 | "Tyumen Oblast",
492 | "Kurgan Oblast",
493 | "Chelyabinsk Oblast",
494 | "Buryatia Republic",
495 | "Zabaykalsky Krai",
496 | "Irkutsk Oblast",
497 | "Novosibirsk Oblast",
498 | "Tomsk Oblast",
499 | "Omsk Oblast",
500 | "Khakassia Republic",
501 | "Kemerovo Oblast",
502 | "Altai Republic",
503 | "Altai Krai",
504 | "Tuva Republic",
505 | "Krasnoyarsk Krai",
506 | "Magadan Oblast",
507 | "Chukotka Okrug",
508 | "Kamchatka Krai",
509 | "Sakhalin Oblast",
510 | "Primorsky Krai",
511 | "Jewish Autonomous Oblast",
512 | "Khabarovsk Krai",
513 | "Amur Oblast",
514 | "Sakha Republic (Yakutia Republic)",
515 | "Canada",
516 | "Russia (Russian Federation)",
517 | "Shanghai",
518 | "Tianjin",
519 | "Beijing",
520 | "Hainan",
521 | "Ningxia Hui",
522 | "Chongqing",
523 | "Zhejiang",
524 | "Jiangsu",
525 | "Fujian",
526 | "Anhui",
527 | "Liaoning",
528 | "Shandong",
529 | "Shanxi",
530 | "Jiangxi",
531 | "Henan",
532 | "Guizhou",
533 | "Guangdong",
534 | "Hubei",
535 | "Jilin",
536 | "Hebei (Yanzhao)",
537 | "Shaanxi",
538 | "Nei Mongol (Inner Mongolia)",
539 | "Heilongjiang",
540 | "Hunan",
541 | "Guangxi Zhuang",
542 | "Sichuan",
543 | "Yunnan",
544 | "Xizang (Tibet)",
545 | "Gansu",
546 | "Qinghai (Tsinghai)",
547 | "Xinjiang Uyghur",
548 | "China",
549 | "United States Minor Outlying Islands",
550 | "Clipperton Island",
551 | "Antarctica",
552 | "International (Worldwide) (Earth)",
553 | "?"];
554 |
555 |
--------------------------------------------------------------------------------
/examples/FileSaver.js:
--------------------------------------------------------------------------------
1 | /* FileSaver.js
2 | * A saveAs() FileSaver implementation.
3 | * 1.3.2
4 | * 2016-06-16 18:25:19
5 | *
6 | * By Eli Grey, http://eligrey.com
7 | * License: MIT
8 | * See https://github.com/eligrey/FileSaver.js/blob/master/LICENSE.md
9 | */
10 |
11 | /*global self */
12 | /*jslint bitwise: true, indent: 4, laxbreak: true, laxcomma: true, smarttabs: true, plusplus: true */
13 |
14 | /*! @source http://purl.eligrey.com/github/FileSaver.js/blob/master/FileSaver.js */
15 |
16 | var saveAs = saveAs || (function(view) {
17 | "use strict";
18 | // IE <10 is explicitly unsupported
19 | if (typeof view === "undefined" || typeof navigator !== "undefined" && /MSIE [1-9]\./.test(navigator.userAgent)) {
20 | return;
21 | }
22 | var
23 | doc = view.document
24 | // only get URL when necessary in case Blob.js hasn't overridden it yet
25 | , get_URL = function() {
26 | return view.URL || view.webkitURL || view;
27 | }
28 | , save_link = doc.createElementNS("http://www.w3.org/1999/xhtml", "a")
29 | , can_use_save_link = "download" in save_link
30 | , click = function(node) {
31 | var event = new MouseEvent("click");
32 | node.dispatchEvent(event);
33 | }
34 | , is_safari = /constructor/i.test(view.HTMLElement) || view.safari
35 | , is_chrome_ios =/CriOS\/[\d]+/.test(navigator.userAgent)
36 | , throw_outside = function(ex) {
37 | (view.setImmediate || view.setTimeout)(function() {
38 | throw ex;
39 | }, 0);
40 | }
41 | , force_saveable_type = "application/octet-stream"
42 | // the Blob API is fundamentally broken as there is no "downloadfinished" event to subscribe to
43 | , arbitrary_revoke_timeout = 1000 * 40 // in ms
44 | , revoke = function(file) {
45 | var revoker = function() {
46 | if (typeof file === "string") { // file is an object URL
47 | get_URL().revokeObjectURL(file);
48 | } else { // file is a File
49 | file.remove();
50 | }
51 | };
52 | setTimeout(revoker, arbitrary_revoke_timeout);
53 | }
54 | , dispatch = function(filesaver, event_types, event) {
55 | event_types = [].concat(event_types);
56 | var i = event_types.length;
57 | while (i--) {
58 | var listener = filesaver["on" + event_types[i]];
59 | if (typeof listener === "function") {
60 | try {
61 | listener.call(filesaver, event || filesaver);
62 | } catch (ex) {
63 | throw_outside(ex);
64 | }
65 | }
66 | }
67 | }
68 | , auto_bom = function(blob) {
69 | // prepend BOM for UTF-8 XML and text/* types (including HTML)
70 | // note: your browser will automatically convert UTF-16 U+FEFF to EF BB BF
71 | if (/^\s*(?:text\/\S*|application\/xml|\S*\/\S*\+xml)\s*;.*charset\s*=\s*utf-8/i.test(blob.type)) {
72 | return new Blob([String.fromCharCode(0xFEFF), blob], {type: blob.type});
73 | }
74 | return blob;
75 | }
76 | , FileSaver = function(blob, name, no_auto_bom) {
77 | if (!no_auto_bom) {
78 | blob = auto_bom(blob);
79 | }
80 | // First try a.download, then web filesystem, then object URLs
81 | var
82 | filesaver = this
83 | , type = blob.type
84 | , force = type === force_saveable_type
85 | , object_url
86 | , dispatch_all = function() {
87 | dispatch(filesaver, "writestart progress write writeend".split(" "));
88 | }
89 | // on any filesys errors revert to saving with object URLs
90 | , fs_error = function() {
91 | if ((is_chrome_ios || (force && is_safari)) && view.FileReader) {
92 | // Safari doesn't allow downloading of blob urls
93 | var reader = new FileReader();
94 | reader.onloadend = function() {
95 | var url = is_chrome_ios ? reader.result : reader.result.replace(/^data:[^;]*;/, 'data:attachment/file;');
96 | var popup = view.open(url, '_blank');
97 | if(!popup) view.location.href = url;
98 | url=undefined; // release reference before dispatching
99 | filesaver.readyState = filesaver.DONE;
100 | dispatch_all();
101 | };
102 | reader.readAsDataURL(blob);
103 | filesaver.readyState = filesaver.INIT;
104 | return;
105 | }
106 | // don't create more object URLs than needed
107 | if (!object_url) {
108 | object_url = get_URL().createObjectURL(blob);
109 | }
110 | if (force) {
111 | view.location.href = object_url;
112 | } else {
113 | var opened = view.open(object_url, "_blank");
114 | if (!opened) {
115 | // Apple does not allow window.open, see https://developer.apple.com/library/safari/documentation/Tools/Conceptual/SafariExtensionGuide/WorkingwithWindowsandTabs/WorkingwithWindowsandTabs.html
116 | view.location.href = object_url;
117 | }
118 | }
119 | filesaver.readyState = filesaver.DONE;
120 | dispatch_all();
121 | revoke(object_url);
122 | }
123 | ;
124 | filesaver.readyState = filesaver.INIT;
125 |
126 | if (can_use_save_link) {
127 | object_url = get_URL().createObjectURL(blob);
128 | setTimeout(function() {
129 | save_link.href = object_url;
130 | save_link.download = name;
131 | click(save_link);
132 | dispatch_all();
133 | revoke(object_url);
134 | filesaver.readyState = filesaver.DONE;
135 | });
136 | return;
137 | }
138 |
139 | fs_error();
140 | }
141 | , FS_proto = FileSaver.prototype
142 | , saveAs = function(blob, name, no_auto_bom) {
143 | return new FileSaver(blob, name || blob.name || "download", no_auto_bom);
144 | }
145 | ;
146 | // IE 10+ (native saveAs)
147 | if (typeof navigator !== "undefined" && navigator.msSaveOrOpenBlob) {
148 | return function(blob, name, no_auto_bom) {
149 | name = name || blob.name || "download";
150 |
151 | if (!no_auto_bom) {
152 | blob = auto_bom(blob);
153 | }
154 | return navigator.msSaveOrOpenBlob(blob, name);
155 | };
156 | }
157 |
158 | FS_proto.abort = function(){};
159 | FS_proto.readyState = FS_proto.INIT = 0;
160 | FS_proto.WRITING = 1;
161 | FS_proto.DONE = 2;
162 |
163 | FS_proto.error =
164 | FS_proto.onwritestart =
165 | FS_proto.onprogress =
166 | FS_proto.onwrite =
167 | FS_proto.onabort =
168 | FS_proto.onerror =
169 | FS_proto.onwriteend =
170 | null;
171 |
172 | return saveAs;
173 | }(
174 | typeof self !== "undefined" && self
175 | || typeof window !== "undefined" && window
176 | || this.content
177 | ));
178 | // `self` is undefined in Firefox for Android content script context
179 | // while `this` is nsIContentFrameMessageManager
180 | // with an attribute `content` that corresponds to the window
181 |
182 | if (typeof module !== "undefined" && module.exports) {
183 | module.exports.saveAs = saveAs;
184 | } else if ((typeof define !== "undefined" && define !== null) && (define.amd !== null)) {
185 | define("FileSaver.js", function() {
186 | return saveAs;
187 | });
188 | }
189 |
--------------------------------------------------------------------------------
/examples/converter.html:
--------------------------------------------------------------------------------
1 |
16 |
17 |
18 |
19 |
20 |
28 | This page allows you to upload a CSV file with coordinates and convert
29 | them to mapcodes, also in CSV format. The input CSV file needs to have 3 columns:
30 | latitude (in degrees), longitude (in degrees), territory (optional)
31 | Field delimiter:, (comma)
32 | Decimal point:. (dot)
33 |
34 |
35 | The column context is used to specify the
36 | territory code for which the shortest mapcode should be displayed.
37 | For example, for South Africa, this would be ZAF. Note that if you leave the field empty, the result might
38 | not be what you expected. The system may choose a nearby territory instead.
39 |
54 | The output is formatted in CSV format. In some browsers this will automatically be saved to a file called
55 | mapcodes.csv in your Downloads folder.
56 | However, not all browsers support this functionality. Some will show the contents of the file on your screen
57 | instead and you'll need to copy or save it to a CSV file yourself then.
58 | (Note: We've tried this with Google Chrome and it seems to work fine.)
59 |
60 |
61 | Troubleshooting: If you select a CSV file and nothing happens, the format of the input file is not OK.
62 | It should contain exactly 3 columns, separated by comma's and the latitude/longitudes must use decimal points.
63 | Try saving the example text from above in a file and use that first, in that case.
64 | Note that this page is just an example. If you wish to have better error checking and more options, feel
65 | free to use and adapt the source files to your needs.
66 | They can be found here on Github.
67 |