├── .dockerignore
├── .gitignore
├── .travis.yml
├── CONTRIBUTING.md
├── Dockerfile
├── Framework
├── Info.plist
└── OpenLocationCode.h
├── LICENSE
├── OpenLocationCode.xcodeproj
├── project.pbxproj
├── project.xcworkspace
│ ├── contents.xcworkspacedata
│ └── xcshareddata
│ │ └── IDEWorkspaceChecks.plist
└── xcshareddata
│ └── xcschemes
│ ├── OpenLocationCode_iOS.xcscheme
│ ├── OpenLocationCode_macOS.xcscheme
│ ├── OpenLocationCode_tvOS.xcscheme
│ └── OpenLocationCode_watchOS.xcscheme
├── OpenLocationCodeFramework.podspec
├── Package.swift
├── README.md
├── Source
├── OpenLocationCode.swift
└── OpenLocationCodeObjCBridge.swift
├── Tests
├── Info.plist
├── LinuxMain.swift
├── OpenLocationCodeObjCTests
│ └── OpenLocationCodeObjCExampleTests.m
└── OpenLocationCodeTests
│ ├── OpenLocationCodeAdditionalTests.swift
│ ├── OpenLocationCodeCoreTests.swift
│ └── OpenLocationCodeSwiftExampleTests.swift
└── test_data
├── decoding.csv
├── encoding.csv
├── shortCodeTests.csv
├── syncData.sh
└── validityTests.csv
/.dockerignore:
--------------------------------------------------------------------------------
1 | .DS_Store
2 | .build
3 | Packages
4 | Carthage
5 | xcuserdata/
6 | build
7 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | .DS_Store
2 | /.build
3 | /Packages
4 | Carthage
5 | xcuserdata/
6 | build/
7 |
8 |
--------------------------------------------------------------------------------
/.travis.yml:
--------------------------------------------------------------------------------
1 | # Travis CI config for AppAuth
2 | # Use the `wwtd` gem to test locally.
3 | language: objective-c
4 | osx_image: xcode10.2
5 | # Tests iOS, macOS and tvOS: both static library and framework schemes.
6 | env:
7 | # To generate this list, use `xcodebuild -showsdks` to get possible SDK values, and platforms.
8 | # Use `instruments -s devices` to get the device name.
9 | - SCHEME=OpenLocationCode_iOS DESTINATION="'platform=iOS Simulator,name=iPhone X,OS=12.2'" SDK=iphonesimulator12.2
10 | - SCHEME=OpenLocationCode_macOS DESTINATION="'platform=macOS,arch=x86_64'" SDK=macosx10.14
11 | - SCHEME=OpenLocationCode_tvOS DESTINATION="'platform=tvOS Simulator,name=Apple TV,OS=12.2'" SDK=appletvsimulator12.2
12 | before_script:
13 | - sudo gem install xcpretty
14 | script:
15 | # Breaking down this command:
16 | # eval is used here, otherwise environment variables are not present.
17 | # `set -o pipefail && ` is so that the return code isn't gobbled by xcpretty (per https://github.com/supermarin/xcpretty#usage)
18 | # then it's standard xcodebuild | xcpretty.
19 | - eval "set -o pipefail && xcodebuild -project OpenLocationCode.xcodeproj -scheme $SCHEME -sdk $SDK -destination $DESTINATION -enableCodeCoverage YES GCC_INSTRUMENT_PROGRAM_FLOW_ARCS=YES GCC_GENERATE_TEST_COVERAGE_FILES=YES OTHERCFLAGS='-Werror' test | xcpretty"
20 | - eval "swift --version; swift test"
21 | after_success:
22 | - bash <(curl -s https://codecov.io/bash)
23 |
24 |
--------------------------------------------------------------------------------
/CONTRIBUTING.md:
--------------------------------------------------------------------------------
1 | # Contributing to Open Location Code
2 |
3 | The Open Location Code project strongly encourages technical contributions.
4 |
5 | We hope you'll become an ongoing participant in our open source community but we also welcome one-off contributions for the issues you're particularly passionate about.
6 |
7 | - [Filing issues](#filing-issues)
8 | * [Bugs](#bugs)
9 | * [Suggestions](#suggestions)
10 | - [Contributing code](#contributing-code)
11 | - [Contributing a new implementation](#contributing-a-new-implementation)
12 | - [Contributor License Agreement](#contributor-license-agreement)
13 | - [Ongoing participation](#ongoing-participation)
14 | * [Discussion channels](#discussion-channels)
15 |
16 | ## Filing issues
17 |
18 | ### Bugs
19 |
20 | If you find a bug in the Swift library, please [file an issue](https://github.com/google/open-location-code-swift/issues/new).
21 |
22 | Issues with the OLC standard, or other implementations, please
23 | [file an issue in the main repo](https://github.com/google/open-location-code/issues/new).
24 | Members of the community are regularly monitoring issues and will try to fix open bugs quickly.
25 |
26 | The best bug reports provide a detailed description of the issue, step-by-step instructions for predictably reproducing the issue, and possibly even a working example that demonstrates the issue.
27 |
28 | Please note that questions about how to use Open Location Code or other general questions should be asked on the [Open Location Code Google Group](https://groups.google.com/forum/#!forum/open-location-code)
29 | instead of filing an issue here.
30 |
31 | ### Suggestions
32 |
33 | The Open Location Code project is meant to evolve with feedback. The project and its users appreciate your thoughts on ways to improve the design or features or creative ways to use the codes.
34 |
35 | To make a suggestion [file an issue](https://github.com/google/open-location-code/issues/new).
36 |
37 | If you are intending to implement, please see the [Contributing code](#contributing-code) section below for next steps.
38 |
39 | If you are adding Open Location Codes to your project, please contact the [Open Location Code Google Group](https://groups.google.com/forum/#!forum/open-location-code) so we can suggest how you can make the most of the codes.
40 |
41 | ## Contributing code
42 |
43 | The Open Location Code project accepts and greatly appreciates code contributions!
44 |
45 | If you are contributing code to the project consider [joining the Open Location Code project on GitHub](https://goo.gl/forms/T65peVtfQfEoDWeD3).
46 |
47 | A few things to note:
48 |
49 | * The Open Location Code project follows the [fork & pull](https://help.github.com/articles/using-pull-requests/#fork--pull) model for accepting contributions.
50 | * We follow [Google's Python Style Guide](https://google.github.io/styleguide/pyguide.html). More generally make sure to follow the same comment and coding style as the rest of the project.
51 | * Include [tests](TESTING.md) when contributing code. There are tests that you can use as examples.
52 |
53 | ## Contributing a new implementation
54 |
55 | Follow this process for contributing a new implementation:
56 |
57 | * Look at the existing implementations, to get an idea of the usage and how much work is involved.
58 | * If you copy the code structure and algorithms from an existing implementation, you'll have a much shorter review cycle.
59 | * [Create a new GitHub issue](https://github.com/google/open-location-code/issues/new) to start discussion of the new feature.
60 | * Follow the guidelines for [Contributing code](#contributing-code) described above.
61 |
62 | ## Contributor License Agreement
63 |
64 | The Open Location Code project hosted at GitHub requires all contributors to sign a Contributor License Agreement ([individual](https://developers.google.com/open-source/cla/individual) or [corporation](https://developers.google.com/open-source/cla/corporate)) in order to protect contributors, users and Google in issues of intellectual property.
65 |
66 | When you create a Pull Request a check will be run to ensure that you have signed the CLA. Make sure that you sign the CLA with the same email address you associate with your commits (likely via the `user.email` Git config as described on GitHub's [Set up Git](https://help.github.com/articles/set-up-git/) page).
67 |
68 | ## Ongoing participation
69 |
70 | We actively encourage ongoing participation by community members.
71 |
72 | ### Discussion channels
73 |
74 | Technical issues, designs, etc. are discussed on [GitHub issues](https://github.com/google/open-location-code-swift/issues) and [pull requests](https://github.com/google/open-location-code-swift/pulls),
75 | or the [Open Location Code Google Group](https://groups.google.com/forum/#!forum/open-location-code).
76 |
77 |
--------------------------------------------------------------------------------
/Dockerfile:
--------------------------------------------------------------------------------
1 | # Build and test Open Location Code for Swift in Linux.
2 | FROM swift:5.0
3 | RUN mkdir /OpenLocationCode
4 | WORKDIR /OpenLocationCode
5 | ADD . /OpenLocationCode
6 | RUN swift --version
7 | RUN swift build
8 | RUN swift test
9 |
--------------------------------------------------------------------------------
/Framework/Info.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | CFBundleDevelopmentRegion
6 | en
7 | CFBundleExecutable
8 | $(EXECUTABLE_NAME)
9 | CFBundleIdentifier
10 | $(PRODUCT_BUNDLE_IDENTIFIER)
11 | CFBundleInfoDictionaryVersion
12 | 6.0
13 | CFBundleName
14 | $(PRODUCT_NAME)
15 | CFBundlePackageType
16 | FMWK
17 | CFBundleShortVersionString
18 | 1.0
19 | CFBundleVersion
20 | $(CURRENT_PROJECT_VERSION)
21 | NSPrincipalClass
22 |
23 |
24 |
25 |
--------------------------------------------------------------------------------
/Framework/OpenLocationCode.h:
--------------------------------------------------------------------------------
1 | //===--- OpenLocationCode.h - Framework Header ----------------------------===//
2 | //
3 | // Copyright 2017 Google Inc.
4 | //
5 | // Licensed under the Apache License, Version 2.0 (the "License");
6 | // you may not use this file except in compliance with the License.
7 | // You may obtain a copy of the License at
8 | //
9 | // http://www.apache.org/licenses/LICENSE-2.0
10 | //
11 | // Unless required by applicable law or agreed to in writing, software
12 | // distributed under the License is distributed on an "AS IS" BASIS,
13 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | // See the License for the specific language governing permissions and
15 | // limitations under the License.
16 | //
17 | //===----------------------------------------------------------------------===//
18 |
19 | #import
20 |
21 | //! Project version number for OpenLocationCode.
22 | FOUNDATION_EXPORT double OpenLocationCodeVersionNumber;
23 |
24 | //! Project version string for OpenLocationCode.
25 | FOUNDATION_EXPORT const unsigned char OpenLocationCodeVersionString[];
26 |
27 | // In this header, you should import all the public headers of your framework
28 | // using statements like #import
29 |
--------------------------------------------------------------------------------
/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 | APPENDIX: How to apply the Apache License to your work.
180 |
181 | To apply the Apache License to your work, attach the following
182 | boilerplate notice, with the fields enclosed by brackets "[]"
183 | replaced with your own identifying information. (Don't include
184 | the brackets!) The text should be enclosed in the appropriate
185 | comment syntax for the file format. We also recommend that a
186 | file or class name and description of purpose be included on the
187 | same "printed page" as the copyright notice for easier
188 | identification within third-party archives.
189 |
190 | Copyright [yyyy] [name of copyright owner]
191 |
192 | Licensed under the Apache License, Version 2.0 (the "License");
193 | you may not use this file except in compliance with the License.
194 | You may obtain a copy of the License at
195 |
196 | http://www.apache.org/licenses/LICENSE-2.0
197 |
198 | Unless required by applicable law or agreed to in writing, software
199 | distributed under the License is distributed on an "AS IS" BASIS,
200 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
201 | See the License for the specific language governing permissions and
202 | limitations under the License.
203 |
--------------------------------------------------------------------------------
/OpenLocationCode.xcodeproj/project.pbxproj:
--------------------------------------------------------------------------------
1 | // !$*UTF8*$!
2 | {
3 | archiveVersion = 1;
4 | classes = {
5 | };
6 | objectVersion = 46;
7 | objects = {
8 |
9 | /* Begin PBXBuildFile section */
10 | BE05A95B1F2964A600DEB62E /* OpenLocationCode.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = BE05A9521F2964A600DEB62E /* OpenLocationCode.framework */; };
11 | BE05A9771F2964CC00DEB62E /* OpenLocationCode.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = BE05A96E1F2964CC00DEB62E /* OpenLocationCode.framework */; };
12 | BE05A9D81F29686900DEB62E /* OpenLocationCode.h in Headers */ = {isa = PBXBuildFile; fileRef = BE9C7A731F23C9F30067DAC8 /* OpenLocationCode.h */; settings = {ATTRIBUTES = (Public, ); }; };
13 | BE05A9D91F29686C00DEB62E /* OpenLocationCode.h in Headers */ = {isa = PBXBuildFile; fileRef = BE9C7A731F23C9F30067DAC8 /* OpenLocationCode.h */; settings = {ATTRIBUTES = (Public, ); }; };
14 | BE05A9DA1F29687000DEB62E /* OpenLocationCode.h in Headers */ = {isa = PBXBuildFile; fileRef = BE9C7A731F23C9F30067DAC8 /* OpenLocationCode.h */; settings = {ATTRIBUTES = (Public, ); }; };
15 | BE05A9DB1F29687B00DEB62E /* OpenLocationCodeCoreTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = BE9C7A7E1F23C9F30067DAC8 /* OpenLocationCodeCoreTests.swift */; };
16 | BE05A9DC1F29687B00DEB62E /* OpenLocationCodeAdditionalTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = BEB0EF4C1F26401E0079AF6E /* OpenLocationCodeAdditionalTests.swift */; };
17 | BE05A9DD1F29687B00DEB62E /* OpenLocationCodeObjCExampleTests.m in Sources */ = {isa = PBXBuildFile; fileRef = BEE5DAC41F25820B003BB31E /* OpenLocationCodeObjCExampleTests.m */; };
18 | BE05A9DE1F29687B00DEB62E /* OpenLocationCodeSwiftExampleTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = BEB0EF4A1F263D3C0079AF6E /* OpenLocationCodeSwiftExampleTests.swift */; };
19 | BE05A9DF1F29687C00DEB62E /* OpenLocationCodeCoreTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = BE9C7A7E1F23C9F30067DAC8 /* OpenLocationCodeCoreTests.swift */; };
20 | BE05A9E01F29687C00DEB62E /* OpenLocationCodeAdditionalTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = BEB0EF4C1F26401E0079AF6E /* OpenLocationCodeAdditionalTests.swift */; };
21 | BE05A9E11F29687C00DEB62E /* OpenLocationCodeObjCExampleTests.m in Sources */ = {isa = PBXBuildFile; fileRef = BEE5DAC41F25820B003BB31E /* OpenLocationCodeObjCExampleTests.m */; };
22 | BE05A9E21F29687C00DEB62E /* OpenLocationCodeSwiftExampleTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = BEB0EF4A1F263D3C0079AF6E /* OpenLocationCodeSwiftExampleTests.swift */; };
23 | BE05A9E71F296ACA00DEB62E /* shortCodeTests.csv in Resources */ = {isa = PBXBuildFile; fileRef = BE710F731F24F13200E5B525 /* shortCodeTests.csv */; };
24 | BE05A9E81F296ACA00DEB62E /* validityTests.csv in Resources */ = {isa = PBXBuildFile; fileRef = BE710F741F24F13200E5B525 /* validityTests.csv */; };
25 | BE05A9EA1F296ACB00DEB62E /* shortCodeTests.csv in Resources */ = {isa = PBXBuildFile; fileRef = BE710F731F24F13200E5B525 /* shortCodeTests.csv */; };
26 | BE05A9EB1F296ACB00DEB62E /* validityTests.csv in Resources */ = {isa = PBXBuildFile; fileRef = BE710F741F24F13200E5B525 /* validityTests.csv */; };
27 | BE300EC41F2D0820003AAEFE /* OpenLocationCodeObjCBridge.swift in Sources */ = {isa = PBXBuildFile; fileRef = BE300EC31F2D0820003AAEFE /* OpenLocationCodeObjCBridge.swift */; };
28 | BE300EC51F2D091D003AAEFE /* OpenLocationCodeObjCBridge.swift in Sources */ = {isa = PBXBuildFile; fileRef = BE300EC31F2D0820003AAEFE /* OpenLocationCodeObjCBridge.swift */; };
29 | BE300EC61F2D091E003AAEFE /* OpenLocationCodeObjCBridge.swift in Sources */ = {isa = PBXBuildFile; fileRef = BE300EC31F2D0820003AAEFE /* OpenLocationCodeObjCBridge.swift */; };
30 | BE300EC71F2D091E003AAEFE /* OpenLocationCodeObjCBridge.swift in Sources */ = {isa = PBXBuildFile; fileRef = BE300EC31F2D0820003AAEFE /* OpenLocationCodeObjCBridge.swift */; };
31 | BE710F761F24F13E00E5B525 /* shortCodeTests.csv in Resources */ = {isa = PBXBuildFile; fileRef = BE710F731F24F13200E5B525 /* shortCodeTests.csv */; };
32 | BE710F771F24F14100E5B525 /* validityTests.csv in Resources */ = {isa = PBXBuildFile; fileRef = BE710F741F24F13200E5B525 /* validityTests.csv */; };
33 | BE9C7A7A1F23C9F30067DAC8 /* OpenLocationCode.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = BE9C7A701F23C9F30067DAC8 /* OpenLocationCode.framework */; };
34 | BE9C7A7F1F23C9F30067DAC8 /* OpenLocationCodeCoreTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = BE9C7A7E1F23C9F30067DAC8 /* OpenLocationCodeCoreTests.swift */; };
35 | BE9C7A811F23C9F30067DAC8 /* OpenLocationCode.h in Headers */ = {isa = PBXBuildFile; fileRef = BE9C7A731F23C9F30067DAC8 /* OpenLocationCode.h */; settings = {ATTRIBUTES = (Public, ); }; };
36 | BEAC9B391F2C24C7009ABB32 /* OpenLocationCode.swift in Sources */ = {isa = PBXBuildFile; fileRef = BEAC9B381F2C24C7009ABB32 /* OpenLocationCode.swift */; };
37 | BEAC9B3A1F2C24C7009ABB32 /* OpenLocationCode.swift in Sources */ = {isa = PBXBuildFile; fileRef = BEAC9B381F2C24C7009ABB32 /* OpenLocationCode.swift */; };
38 | BEAC9B3B1F2C24C7009ABB32 /* OpenLocationCode.swift in Sources */ = {isa = PBXBuildFile; fileRef = BEAC9B381F2C24C7009ABB32 /* OpenLocationCode.swift */; };
39 | BEAC9B3C1F2C24C7009ABB32 /* OpenLocationCode.swift in Sources */ = {isa = PBXBuildFile; fileRef = BEAC9B381F2C24C7009ABB32 /* OpenLocationCode.swift */; };
40 | BEAF3E1C2273837300FA6A39 /* encoding.csv in Resources */ = {isa = PBXBuildFile; fileRef = BEAF3E1A2273837200FA6A39 /* encoding.csv */; };
41 | BEAF3E1D2273837300FA6A39 /* encoding.csv in Resources */ = {isa = PBXBuildFile; fileRef = BEAF3E1A2273837200FA6A39 /* encoding.csv */; };
42 | BEAF3E1E2273837300FA6A39 /* encoding.csv in Resources */ = {isa = PBXBuildFile; fileRef = BEAF3E1A2273837200FA6A39 /* encoding.csv */; };
43 | BEAF3E1F2273837300FA6A39 /* decoding.csv in Resources */ = {isa = PBXBuildFile; fileRef = BEAF3E1B2273837300FA6A39 /* decoding.csv */; };
44 | BEAF3E202273837300FA6A39 /* decoding.csv in Resources */ = {isa = PBXBuildFile; fileRef = BEAF3E1B2273837300FA6A39 /* decoding.csv */; };
45 | BEAF3E212273837300FA6A39 /* decoding.csv in Resources */ = {isa = PBXBuildFile; fileRef = BEAF3E1B2273837300FA6A39 /* decoding.csv */; };
46 | BEB0EF4B1F263D3C0079AF6E /* OpenLocationCodeSwiftExampleTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = BEB0EF4A1F263D3C0079AF6E /* OpenLocationCodeSwiftExampleTests.swift */; };
47 | BEB0EF4D1F26401E0079AF6E /* OpenLocationCodeAdditionalTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = BEB0EF4C1F26401E0079AF6E /* OpenLocationCodeAdditionalTests.swift */; };
48 | BEE5DAC51F25820B003BB31E /* OpenLocationCodeObjCExampleTests.m in Sources */ = {isa = PBXBuildFile; fileRef = BEE5DAC41F25820B003BB31E /* OpenLocationCodeObjCExampleTests.m */; };
49 | /* End PBXBuildFile section */
50 |
51 | /* Begin PBXContainerItemProxy section */
52 | BE05A95C1F2964A600DEB62E /* PBXContainerItemProxy */ = {
53 | isa = PBXContainerItemProxy;
54 | containerPortal = BE9C7A671F23C9F30067DAC8 /* Project object */;
55 | proxyType = 1;
56 | remoteGlobalIDString = BE05A9511F2964A600DEB62E;
57 | remoteInfo = OpenLocationCode_tvOS;
58 | };
59 | BE05A9781F2964CC00DEB62E /* PBXContainerItemProxy */ = {
60 | isa = PBXContainerItemProxy;
61 | containerPortal = BE9C7A671F23C9F30067DAC8 /* Project object */;
62 | proxyType = 1;
63 | remoteGlobalIDString = BE05A96D1F2964CC00DEB62E;
64 | remoteInfo = OpenLocationCode_macOS;
65 | };
66 | BE9C7A7B1F23C9F30067DAC8 /* PBXContainerItemProxy */ = {
67 | isa = PBXContainerItemProxy;
68 | containerPortal = BE9C7A671F23C9F30067DAC8 /* Project object */;
69 | proxyType = 1;
70 | remoteGlobalIDString = BE9C7A6F1F23C9F30067DAC8;
71 | remoteInfo = OpenLocationCode;
72 | };
73 | /* End PBXContainerItemProxy section */
74 |
75 | /* Begin PBXFileReference section */
76 | BE05A9451F29648000DEB62E /* OpenLocationCode.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = OpenLocationCode.framework; sourceTree = BUILT_PRODUCTS_DIR; };
77 | BE05A9521F2964A600DEB62E /* OpenLocationCode.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = OpenLocationCode.framework; sourceTree = BUILT_PRODUCTS_DIR; };
78 | BE05A95A1F2964A600DEB62E /* OpenLocationCode_tvOSTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = OpenLocationCode_tvOSTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; };
79 | BE05A96E1F2964CC00DEB62E /* OpenLocationCode.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = OpenLocationCode.framework; sourceTree = BUILT_PRODUCTS_DIR; };
80 | BE05A9761F2964CC00DEB62E /* OpenLocationCode_macOSTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = OpenLocationCode_macOSTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; };
81 | BE300EC31F2D0820003AAEFE /* OpenLocationCodeObjCBridge.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = OpenLocationCodeObjCBridge.swift; sourceTree = ""; };
82 | BE710F731F24F13200E5B525 /* shortCodeTests.csv */ = {isa = PBXFileReference; lastKnownFileType = text; path = shortCodeTests.csv; sourceTree = ""; };
83 | BE710F741F24F13200E5B525 /* validityTests.csv */ = {isa = PBXFileReference; lastKnownFileType = text; path = validityTests.csv; sourceTree = ""; };
84 | BE9C7A701F23C9F30067DAC8 /* OpenLocationCode.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = OpenLocationCode.framework; sourceTree = BUILT_PRODUCTS_DIR; };
85 | BE9C7A731F23C9F30067DAC8 /* OpenLocationCode.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = OpenLocationCode.h; sourceTree = ""; };
86 | BE9C7A741F23C9F30067DAC8 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; };
87 | BE9C7A791F23C9F30067DAC8 /* OpenLocationCodeTests_iOS.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = OpenLocationCodeTests_iOS.xctest; sourceTree = BUILT_PRODUCTS_DIR; };
88 | BE9C7A7E1F23C9F30067DAC8 /* OpenLocationCodeCoreTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; name = OpenLocationCodeCoreTests.swift; path = OpenLocationCodeTests/OpenLocationCodeCoreTests.swift; sourceTree = ""; };
89 | BE9C7A801F23C9F30067DAC8 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; };
90 | BEAC9B381F2C24C7009ABB32 /* OpenLocationCode.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = OpenLocationCode.swift; sourceTree = ""; };
91 | BEAF3E1A2273837200FA6A39 /* encoding.csv */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = encoding.csv; sourceTree = ""; };
92 | BEAF3E1B2273837300FA6A39 /* decoding.csv */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = decoding.csv; sourceTree = ""; };
93 | BEB0EF4A1F263D3C0079AF6E /* OpenLocationCodeSwiftExampleTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = OpenLocationCodeSwiftExampleTests.swift; path = OpenLocationCodeTests/OpenLocationCodeSwiftExampleTests.swift; sourceTree = ""; };
94 | BEB0EF4C1F26401E0079AF6E /* OpenLocationCodeAdditionalTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = OpenLocationCodeAdditionalTests.swift; path = OpenLocationCodeTests/OpenLocationCodeAdditionalTests.swift; sourceTree = ""; };
95 | BEE5DAC41F25820B003BB31E /* OpenLocationCodeObjCExampleTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = OpenLocationCodeObjCExampleTests.m; path = OpenLocationCodeObjCTests/OpenLocationCodeObjCExampleTests.m; sourceTree = ""; };
96 | /* End PBXFileReference section */
97 |
98 | /* Begin PBXFrameworksBuildPhase section */
99 | BE05A9411F29648000DEB62E /* Frameworks */ = {
100 | isa = PBXFrameworksBuildPhase;
101 | buildActionMask = 2147483647;
102 | files = (
103 | );
104 | runOnlyForDeploymentPostprocessing = 0;
105 | };
106 | BE05A94E1F2964A600DEB62E /* Frameworks */ = {
107 | isa = PBXFrameworksBuildPhase;
108 | buildActionMask = 2147483647;
109 | files = (
110 | );
111 | runOnlyForDeploymentPostprocessing = 0;
112 | };
113 | BE05A9571F2964A600DEB62E /* Frameworks */ = {
114 | isa = PBXFrameworksBuildPhase;
115 | buildActionMask = 2147483647;
116 | files = (
117 | BE05A95B1F2964A600DEB62E /* OpenLocationCode.framework in Frameworks */,
118 | );
119 | runOnlyForDeploymentPostprocessing = 0;
120 | };
121 | BE05A96A1F2964CC00DEB62E /* Frameworks */ = {
122 | isa = PBXFrameworksBuildPhase;
123 | buildActionMask = 2147483647;
124 | files = (
125 | );
126 | runOnlyForDeploymentPostprocessing = 0;
127 | };
128 | BE05A9731F2964CC00DEB62E /* Frameworks */ = {
129 | isa = PBXFrameworksBuildPhase;
130 | buildActionMask = 2147483647;
131 | files = (
132 | BE05A9771F2964CC00DEB62E /* OpenLocationCode.framework in Frameworks */,
133 | );
134 | runOnlyForDeploymentPostprocessing = 0;
135 | };
136 | BE9C7A6C1F23C9F30067DAC8 /* Frameworks */ = {
137 | isa = PBXFrameworksBuildPhase;
138 | buildActionMask = 2147483647;
139 | files = (
140 | );
141 | runOnlyForDeploymentPostprocessing = 0;
142 | };
143 | BE9C7A761F23C9F30067DAC8 /* Frameworks */ = {
144 | isa = PBXFrameworksBuildPhase;
145 | buildActionMask = 2147483647;
146 | files = (
147 | BE9C7A7A1F23C9F30067DAC8 /* OpenLocationCode.framework in Frameworks */,
148 | );
149 | runOnlyForDeploymentPostprocessing = 0;
150 | };
151 | /* End PBXFrameworksBuildPhase section */
152 |
153 | /* Begin PBXGroup section */
154 | BE710F711F24F13200E5B525 /* test_data */ = {
155 | isa = PBXGroup;
156 | children = (
157 | BEAF3E1B2273837300FA6A39 /* decoding.csv */,
158 | BEAF3E1A2273837200FA6A39 /* encoding.csv */,
159 | BE710F731F24F13200E5B525 /* shortCodeTests.csv */,
160 | BE710F741F24F13200E5B525 /* validityTests.csv */,
161 | );
162 | name = test_data;
163 | path = ../test_data;
164 | sourceTree = "";
165 | };
166 | BE9C7A661F23C9F30067DAC8 = {
167 | isa = PBXGroup;
168 | children = (
169 | BEB0EF471F26373C0079AF6E /* Source */,
170 | BE9C7A721F23C9F30067DAC8 /* Framework */,
171 | BE9C7A7D1F23C9F30067DAC8 /* Tests */,
172 | BE9C7A711F23C9F30067DAC8 /* Products */,
173 | );
174 | sourceTree = "";
175 | };
176 | BE9C7A711F23C9F30067DAC8 /* Products */ = {
177 | isa = PBXGroup;
178 | children = (
179 | BE9C7A701F23C9F30067DAC8 /* OpenLocationCode.framework */,
180 | BE9C7A791F23C9F30067DAC8 /* OpenLocationCodeTests_iOS.xctest */,
181 | BE05A9451F29648000DEB62E /* OpenLocationCode.framework */,
182 | BE05A9521F2964A600DEB62E /* OpenLocationCode.framework */,
183 | BE05A95A1F2964A600DEB62E /* OpenLocationCode_tvOSTests.xctest */,
184 | BE05A96E1F2964CC00DEB62E /* OpenLocationCode.framework */,
185 | BE05A9761F2964CC00DEB62E /* OpenLocationCode_macOSTests.xctest */,
186 | );
187 | name = Products;
188 | sourceTree = "";
189 | };
190 | BE9C7A721F23C9F30067DAC8 /* Framework */ = {
191 | isa = PBXGroup;
192 | children = (
193 | BE9C7A741F23C9F30067DAC8 /* Info.plist */,
194 | BE9C7A731F23C9F30067DAC8 /* OpenLocationCode.h */,
195 | );
196 | path = Framework;
197 | sourceTree = "";
198 | };
199 | BE9C7A7D1F23C9F30067DAC8 /* Tests */ = {
200 | isa = PBXGroup;
201 | children = (
202 | BE9C7A801F23C9F30067DAC8 /* Info.plist */,
203 | BE710F711F24F13200E5B525 /* test_data */,
204 | BE9C7A7E1F23C9F30067DAC8 /* OpenLocationCodeCoreTests.swift */,
205 | BEB0EF4C1F26401E0079AF6E /* OpenLocationCodeAdditionalTests.swift */,
206 | BEE5DAC41F25820B003BB31E /* OpenLocationCodeObjCExampleTests.m */,
207 | BEB0EF4A1F263D3C0079AF6E /* OpenLocationCodeSwiftExampleTests.swift */,
208 | );
209 | path = Tests;
210 | sourceTree = "";
211 | };
212 | BEB0EF471F26373C0079AF6E /* Source */ = {
213 | isa = PBXGroup;
214 | children = (
215 | BEAC9B381F2C24C7009ABB32 /* OpenLocationCode.swift */,
216 | BE300EC31F2D0820003AAEFE /* OpenLocationCodeObjCBridge.swift */,
217 | );
218 | path = Source;
219 | sourceTree = "";
220 | };
221 | /* End PBXGroup section */
222 |
223 | /* Begin PBXHeadersBuildPhase section */
224 | BE05A9421F29648000DEB62E /* Headers */ = {
225 | isa = PBXHeadersBuildPhase;
226 | buildActionMask = 2147483647;
227 | files = (
228 | BE05A9D81F29686900DEB62E /* OpenLocationCode.h in Headers */,
229 | );
230 | runOnlyForDeploymentPostprocessing = 0;
231 | };
232 | BE05A94F1F2964A600DEB62E /* Headers */ = {
233 | isa = PBXHeadersBuildPhase;
234 | buildActionMask = 2147483647;
235 | files = (
236 | BE05A9D91F29686C00DEB62E /* OpenLocationCode.h in Headers */,
237 | );
238 | runOnlyForDeploymentPostprocessing = 0;
239 | };
240 | BE05A96B1F2964CC00DEB62E /* Headers */ = {
241 | isa = PBXHeadersBuildPhase;
242 | buildActionMask = 2147483647;
243 | files = (
244 | BE05A9DA1F29687000DEB62E /* OpenLocationCode.h in Headers */,
245 | );
246 | runOnlyForDeploymentPostprocessing = 0;
247 | };
248 | BE9C7A6D1F23C9F30067DAC8 /* Headers */ = {
249 | isa = PBXHeadersBuildPhase;
250 | buildActionMask = 2147483647;
251 | files = (
252 | BE9C7A811F23C9F30067DAC8 /* OpenLocationCode.h in Headers */,
253 | );
254 | runOnlyForDeploymentPostprocessing = 0;
255 | };
256 | /* End PBXHeadersBuildPhase section */
257 |
258 | /* Begin PBXNativeTarget section */
259 | BE05A9441F29648000DEB62E /* OpenLocationCode_watchOS */ = {
260 | isa = PBXNativeTarget;
261 | buildConfigurationList = BE05A94C1F29648000DEB62E /* Build configuration list for PBXNativeTarget "OpenLocationCode_watchOS" */;
262 | buildPhases = (
263 | BE05A9401F29648000DEB62E /* Sources */,
264 | BE05A9411F29648000DEB62E /* Frameworks */,
265 | BE05A9421F29648000DEB62E /* Headers */,
266 | BE05A9431F29648000DEB62E /* Resources */,
267 | );
268 | buildRules = (
269 | );
270 | dependencies = (
271 | );
272 | name = OpenLocationCode_watchOS;
273 | productName = OpenLocationCode_watchOS;
274 | productReference = BE05A9451F29648000DEB62E /* OpenLocationCode.framework */;
275 | productType = "com.apple.product-type.framework";
276 | };
277 | BE05A9511F2964A600DEB62E /* OpenLocationCode_tvOS */ = {
278 | isa = PBXNativeTarget;
279 | buildConfigurationList = BE05A9631F2964A700DEB62E /* Build configuration list for PBXNativeTarget "OpenLocationCode_tvOS" */;
280 | buildPhases = (
281 | BE05A94D1F2964A600DEB62E /* Sources */,
282 | BE05A94E1F2964A600DEB62E /* Frameworks */,
283 | BE05A94F1F2964A600DEB62E /* Headers */,
284 | BE05A9501F2964A600DEB62E /* Resources */,
285 | );
286 | buildRules = (
287 | );
288 | dependencies = (
289 | );
290 | name = OpenLocationCode_tvOS;
291 | productName = OpenLocationCode_tvOS;
292 | productReference = BE05A9521F2964A600DEB62E /* OpenLocationCode.framework */;
293 | productType = "com.apple.product-type.framework";
294 | };
295 | BE05A9591F2964A600DEB62E /* OpenLocationCode_tvOSTests */ = {
296 | isa = PBXNativeTarget;
297 | buildConfigurationList = BE05A9661F2964A700DEB62E /* Build configuration list for PBXNativeTarget "OpenLocationCode_tvOSTests" */;
298 | buildPhases = (
299 | BE05A9561F2964A600DEB62E /* Sources */,
300 | BE05A9571F2964A600DEB62E /* Frameworks */,
301 | BE05A9581F2964A600DEB62E /* Resources */,
302 | );
303 | buildRules = (
304 | );
305 | dependencies = (
306 | BE05A95D1F2964A600DEB62E /* PBXTargetDependency */,
307 | );
308 | name = OpenLocationCode_tvOSTests;
309 | productName = OpenLocationCode_tvOSTests;
310 | productReference = BE05A95A1F2964A600DEB62E /* OpenLocationCode_tvOSTests.xctest */;
311 | productType = "com.apple.product-type.bundle.unit-test";
312 | };
313 | BE05A96D1F2964CC00DEB62E /* OpenLocationCode_macOS */ = {
314 | isa = PBXNativeTarget;
315 | buildConfigurationList = BE05A97F1F2964CC00DEB62E /* Build configuration list for PBXNativeTarget "OpenLocationCode_macOS" */;
316 | buildPhases = (
317 | BE05A9691F2964CC00DEB62E /* Sources */,
318 | BE05A96A1F2964CC00DEB62E /* Frameworks */,
319 | BE05A96B1F2964CC00DEB62E /* Headers */,
320 | BE05A96C1F2964CC00DEB62E /* Resources */,
321 | );
322 | buildRules = (
323 | );
324 | dependencies = (
325 | );
326 | name = OpenLocationCode_macOS;
327 | productName = OpenLocationCode_macOS;
328 | productReference = BE05A96E1F2964CC00DEB62E /* OpenLocationCode.framework */;
329 | productType = "com.apple.product-type.framework";
330 | };
331 | BE05A9751F2964CC00DEB62E /* OpenLocationCode_macOSTests */ = {
332 | isa = PBXNativeTarget;
333 | buildConfigurationList = BE05A9821F2964CC00DEB62E /* Build configuration list for PBXNativeTarget "OpenLocationCode_macOSTests" */;
334 | buildPhases = (
335 | BE05A9721F2964CC00DEB62E /* Sources */,
336 | BE05A9731F2964CC00DEB62E /* Frameworks */,
337 | BE05A9741F2964CC00DEB62E /* Resources */,
338 | );
339 | buildRules = (
340 | );
341 | dependencies = (
342 | BE05A9791F2964CC00DEB62E /* PBXTargetDependency */,
343 | );
344 | name = OpenLocationCode_macOSTests;
345 | productName = OpenLocationCode_macOSTests;
346 | productReference = BE05A9761F2964CC00DEB62E /* OpenLocationCode_macOSTests.xctest */;
347 | productType = "com.apple.product-type.bundle.unit-test";
348 | };
349 | BE9C7A6F1F23C9F30067DAC8 /* OpenLocationCode */ = {
350 | isa = PBXNativeTarget;
351 | buildConfigurationList = BE9C7A841F23C9F30067DAC8 /* Build configuration list for PBXNativeTarget "OpenLocationCode" */;
352 | buildPhases = (
353 | BE9C7A6B1F23C9F30067DAC8 /* Sources */,
354 | BE9C7A6C1F23C9F30067DAC8 /* Frameworks */,
355 | BE9C7A6D1F23C9F30067DAC8 /* Headers */,
356 | BE9C7A6E1F23C9F30067DAC8 /* Resources */,
357 | );
358 | buildRules = (
359 | );
360 | dependencies = (
361 | );
362 | name = OpenLocationCode;
363 | productName = OpenLocationCode;
364 | productReference = BE9C7A701F23C9F30067DAC8 /* OpenLocationCode.framework */;
365 | productType = "com.apple.product-type.framework";
366 | };
367 | BE9C7A781F23C9F30067DAC8 /* OpenLocationCodeTests */ = {
368 | isa = PBXNativeTarget;
369 | buildConfigurationList = BE9C7A871F23C9F30067DAC8 /* Build configuration list for PBXNativeTarget "OpenLocationCodeTests" */;
370 | buildPhases = (
371 | BE9C7A751F23C9F30067DAC8 /* Sources */,
372 | BE9C7A761F23C9F30067DAC8 /* Frameworks */,
373 | BE9C7A771F23C9F30067DAC8 /* Resources */,
374 | );
375 | buildRules = (
376 | );
377 | dependencies = (
378 | BE9C7A7C1F23C9F30067DAC8 /* PBXTargetDependency */,
379 | );
380 | name = OpenLocationCodeTests;
381 | productName = OpenLocationCodeTests;
382 | productReference = BE9C7A791F23C9F30067DAC8 /* OpenLocationCodeTests_iOS.xctest */;
383 | productType = "com.apple.product-type.bundle.unit-test";
384 | };
385 | /* End PBXNativeTarget section */
386 |
387 | /* Begin PBXProject section */
388 | BE9C7A671F23C9F30067DAC8 /* Project object */ = {
389 | isa = PBXProject;
390 | attributes = {
391 | LastSwiftUpdateCheck = 0830;
392 | LastUpgradeCheck = 1020;
393 | TargetAttributes = {
394 | BE05A9441F29648000DEB62E = {
395 | CreatedOnToolsVersion = 8.3.3;
396 | ProvisioningStyle = Automatic;
397 | };
398 | BE05A9511F2964A600DEB62E = {
399 | CreatedOnToolsVersion = 8.3.3;
400 | ProvisioningStyle = Automatic;
401 | };
402 | BE05A9591F2964A600DEB62E = {
403 | CreatedOnToolsVersion = 8.3.3;
404 | ProvisioningStyle = Automatic;
405 | };
406 | BE05A96D1F2964CC00DEB62E = {
407 | CreatedOnToolsVersion = 8.3.3;
408 | ProvisioningStyle = Automatic;
409 | };
410 | BE05A9751F2964CC00DEB62E = {
411 | CreatedOnToolsVersion = 8.3.3;
412 | ProvisioningStyle = Automatic;
413 | };
414 | BE9C7A6F1F23C9F30067DAC8 = {
415 | CreatedOnToolsVersion = 8.3.3;
416 | LastSwiftMigration = 1020;
417 | ProvisioningStyle = Automatic;
418 | };
419 | BE9C7A781F23C9F30067DAC8 = {
420 | CreatedOnToolsVersion = 8.3.3;
421 | LastSwiftMigration = 1020;
422 | ProvisioningStyle = Automatic;
423 | };
424 | };
425 | };
426 | buildConfigurationList = BE9C7A6A1F23C9F30067DAC8 /* Build configuration list for PBXProject "OpenLocationCode" */;
427 | compatibilityVersion = "Xcode 3.2";
428 | developmentRegion = en;
429 | hasScannedForEncodings = 0;
430 | knownRegions = (
431 | en,
432 | Base,
433 | );
434 | mainGroup = BE9C7A661F23C9F30067DAC8;
435 | productRefGroup = BE9C7A711F23C9F30067DAC8 /* Products */;
436 | projectDirPath = "";
437 | projectRoot = "";
438 | targets = (
439 | BE9C7A6F1F23C9F30067DAC8 /* OpenLocationCode */,
440 | BE9C7A781F23C9F30067DAC8 /* OpenLocationCodeTests */,
441 | BE05A9441F29648000DEB62E /* OpenLocationCode_watchOS */,
442 | BE05A9511F2964A600DEB62E /* OpenLocationCode_tvOS */,
443 | BE05A9591F2964A600DEB62E /* OpenLocationCode_tvOSTests */,
444 | BE05A96D1F2964CC00DEB62E /* OpenLocationCode_macOS */,
445 | BE05A9751F2964CC00DEB62E /* OpenLocationCode_macOSTests */,
446 | );
447 | };
448 | /* End PBXProject section */
449 |
450 | /* Begin PBXResourcesBuildPhase section */
451 | BE05A9431F29648000DEB62E /* Resources */ = {
452 | isa = PBXResourcesBuildPhase;
453 | buildActionMask = 2147483647;
454 | files = (
455 | );
456 | runOnlyForDeploymentPostprocessing = 0;
457 | };
458 | BE05A9501F2964A600DEB62E /* Resources */ = {
459 | isa = PBXResourcesBuildPhase;
460 | buildActionMask = 2147483647;
461 | files = (
462 | );
463 | runOnlyForDeploymentPostprocessing = 0;
464 | };
465 | BE05A9581F2964A600DEB62E /* Resources */ = {
466 | isa = PBXResourcesBuildPhase;
467 | buildActionMask = 2147483647;
468 | files = (
469 | BE05A9E71F296ACA00DEB62E /* shortCodeTests.csv in Resources */,
470 | BEAF3E202273837300FA6A39 /* decoding.csv in Resources */,
471 | BEAF3E1D2273837300FA6A39 /* encoding.csv in Resources */,
472 | BE05A9E81F296ACA00DEB62E /* validityTests.csv in Resources */,
473 | );
474 | runOnlyForDeploymentPostprocessing = 0;
475 | };
476 | BE05A96C1F2964CC00DEB62E /* Resources */ = {
477 | isa = PBXResourcesBuildPhase;
478 | buildActionMask = 2147483647;
479 | files = (
480 | );
481 | runOnlyForDeploymentPostprocessing = 0;
482 | };
483 | BE05A9741F2964CC00DEB62E /* Resources */ = {
484 | isa = PBXResourcesBuildPhase;
485 | buildActionMask = 2147483647;
486 | files = (
487 | BE05A9EA1F296ACB00DEB62E /* shortCodeTests.csv in Resources */,
488 | BEAF3E212273837300FA6A39 /* decoding.csv in Resources */,
489 | BEAF3E1E2273837300FA6A39 /* encoding.csv in Resources */,
490 | BE05A9EB1F296ACB00DEB62E /* validityTests.csv in Resources */,
491 | );
492 | runOnlyForDeploymentPostprocessing = 0;
493 | };
494 | BE9C7A6E1F23C9F30067DAC8 /* Resources */ = {
495 | isa = PBXResourcesBuildPhase;
496 | buildActionMask = 2147483647;
497 | files = (
498 | );
499 | runOnlyForDeploymentPostprocessing = 0;
500 | };
501 | BE9C7A771F23C9F30067DAC8 /* Resources */ = {
502 | isa = PBXResourcesBuildPhase;
503 | buildActionMask = 2147483647;
504 | files = (
505 | BE710F761F24F13E00E5B525 /* shortCodeTests.csv in Resources */,
506 | BEAF3E1F2273837300FA6A39 /* decoding.csv in Resources */,
507 | BEAF3E1C2273837300FA6A39 /* encoding.csv in Resources */,
508 | BE710F771F24F14100E5B525 /* validityTests.csv in Resources */,
509 | );
510 | runOnlyForDeploymentPostprocessing = 0;
511 | };
512 | /* End PBXResourcesBuildPhase section */
513 |
514 | /* Begin PBXSourcesBuildPhase section */
515 | BE05A9401F29648000DEB62E /* Sources */ = {
516 | isa = PBXSourcesBuildPhase;
517 | buildActionMask = 2147483647;
518 | files = (
519 | BE300EC51F2D091D003AAEFE /* OpenLocationCodeObjCBridge.swift in Sources */,
520 | BEAC9B3A1F2C24C7009ABB32 /* OpenLocationCode.swift in Sources */,
521 | );
522 | runOnlyForDeploymentPostprocessing = 0;
523 | };
524 | BE05A94D1F2964A600DEB62E /* Sources */ = {
525 | isa = PBXSourcesBuildPhase;
526 | buildActionMask = 2147483647;
527 | files = (
528 | BE300EC61F2D091E003AAEFE /* OpenLocationCodeObjCBridge.swift in Sources */,
529 | BEAC9B3B1F2C24C7009ABB32 /* OpenLocationCode.swift in Sources */,
530 | );
531 | runOnlyForDeploymentPostprocessing = 0;
532 | };
533 | BE05A9561F2964A600DEB62E /* Sources */ = {
534 | isa = PBXSourcesBuildPhase;
535 | buildActionMask = 2147483647;
536 | files = (
537 | BE05A9DD1F29687B00DEB62E /* OpenLocationCodeObjCExampleTests.m in Sources */,
538 | BE05A9DE1F29687B00DEB62E /* OpenLocationCodeSwiftExampleTests.swift in Sources */,
539 | BE05A9DC1F29687B00DEB62E /* OpenLocationCodeAdditionalTests.swift in Sources */,
540 | BE05A9DB1F29687B00DEB62E /* OpenLocationCodeCoreTests.swift in Sources */,
541 | );
542 | runOnlyForDeploymentPostprocessing = 0;
543 | };
544 | BE05A9691F2964CC00DEB62E /* Sources */ = {
545 | isa = PBXSourcesBuildPhase;
546 | buildActionMask = 2147483647;
547 | files = (
548 | BE300EC71F2D091E003AAEFE /* OpenLocationCodeObjCBridge.swift in Sources */,
549 | BEAC9B3C1F2C24C7009ABB32 /* OpenLocationCode.swift in Sources */,
550 | );
551 | runOnlyForDeploymentPostprocessing = 0;
552 | };
553 | BE05A9721F2964CC00DEB62E /* Sources */ = {
554 | isa = PBXSourcesBuildPhase;
555 | buildActionMask = 2147483647;
556 | files = (
557 | BE05A9E11F29687C00DEB62E /* OpenLocationCodeObjCExampleTests.m in Sources */,
558 | BE05A9E21F29687C00DEB62E /* OpenLocationCodeSwiftExampleTests.swift in Sources */,
559 | BE05A9E01F29687C00DEB62E /* OpenLocationCodeAdditionalTests.swift in Sources */,
560 | BE05A9DF1F29687C00DEB62E /* OpenLocationCodeCoreTests.swift in Sources */,
561 | );
562 | runOnlyForDeploymentPostprocessing = 0;
563 | };
564 | BE9C7A6B1F23C9F30067DAC8 /* Sources */ = {
565 | isa = PBXSourcesBuildPhase;
566 | buildActionMask = 2147483647;
567 | files = (
568 | BE300EC41F2D0820003AAEFE /* OpenLocationCodeObjCBridge.swift in Sources */,
569 | BEAC9B391F2C24C7009ABB32 /* OpenLocationCode.swift in Sources */,
570 | );
571 | runOnlyForDeploymentPostprocessing = 0;
572 | };
573 | BE9C7A751F23C9F30067DAC8 /* Sources */ = {
574 | isa = PBXSourcesBuildPhase;
575 | buildActionMask = 2147483647;
576 | files = (
577 | BEB0EF4B1F263D3C0079AF6E /* OpenLocationCodeSwiftExampleTests.swift in Sources */,
578 | BE9C7A7F1F23C9F30067DAC8 /* OpenLocationCodeCoreTests.swift in Sources */,
579 | BEB0EF4D1F26401E0079AF6E /* OpenLocationCodeAdditionalTests.swift in Sources */,
580 | BEE5DAC51F25820B003BB31E /* OpenLocationCodeObjCExampleTests.m in Sources */,
581 | );
582 | runOnlyForDeploymentPostprocessing = 0;
583 | };
584 | /* End PBXSourcesBuildPhase section */
585 |
586 | /* Begin PBXTargetDependency section */
587 | BE05A95D1F2964A600DEB62E /* PBXTargetDependency */ = {
588 | isa = PBXTargetDependency;
589 | target = BE05A9511F2964A600DEB62E /* OpenLocationCode_tvOS */;
590 | targetProxy = BE05A95C1F2964A600DEB62E /* PBXContainerItemProxy */;
591 | };
592 | BE05A9791F2964CC00DEB62E /* PBXTargetDependency */ = {
593 | isa = PBXTargetDependency;
594 | target = BE05A96D1F2964CC00DEB62E /* OpenLocationCode_macOS */;
595 | targetProxy = BE05A9781F2964CC00DEB62E /* PBXContainerItemProxy */;
596 | };
597 | BE9C7A7C1F23C9F30067DAC8 /* PBXTargetDependency */ = {
598 | isa = PBXTargetDependency;
599 | target = BE9C7A6F1F23C9F30067DAC8 /* OpenLocationCode */;
600 | targetProxy = BE9C7A7B1F23C9F30067DAC8 /* PBXContainerItemProxy */;
601 | };
602 | /* End PBXTargetDependency section */
603 |
604 | /* Begin XCBuildConfiguration section */
605 | BE05A94A1F29648000DEB62E /* Debug */ = {
606 | isa = XCBuildConfiguration;
607 | buildSettings = {
608 | APPLICATION_EXTENSION_API_ONLY = YES;
609 | CODE_SIGN_IDENTITY = "";
610 | DEFINES_MODULE = YES;
611 | DYLIB_COMPATIBILITY_VERSION = 1;
612 | DYLIB_CURRENT_VERSION = 1;
613 | DYLIB_INSTALL_NAME_BASE = "@rpath";
614 | INFOPLIST_FILE = Framework/Info.plist;
615 | INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
616 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
617 | PRODUCT_BUNDLE_IDENTIFIER = "com.google.OpenLocationCode-watchOS";
618 | PRODUCT_NAME = OpenLocationCode;
619 | SDKROOT = watchos;
620 | SKIP_INSTALL = YES;
621 | TARGETED_DEVICE_FAMILY = 4;
622 | WATCHOS_DEPLOYMENT_TARGET = 3.2;
623 | };
624 | name = Debug;
625 | };
626 | BE05A94B1F29648000DEB62E /* Release */ = {
627 | isa = XCBuildConfiguration;
628 | buildSettings = {
629 | APPLICATION_EXTENSION_API_ONLY = YES;
630 | CODE_SIGN_IDENTITY = "";
631 | DEFINES_MODULE = YES;
632 | DYLIB_COMPATIBILITY_VERSION = 1;
633 | DYLIB_CURRENT_VERSION = 1;
634 | DYLIB_INSTALL_NAME_BASE = "@rpath";
635 | INFOPLIST_FILE = Framework/Info.plist;
636 | INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
637 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
638 | PRODUCT_BUNDLE_IDENTIFIER = "com.google.OpenLocationCode-watchOS";
639 | PRODUCT_NAME = OpenLocationCode;
640 | SDKROOT = watchos;
641 | SKIP_INSTALL = YES;
642 | TARGETED_DEVICE_FAMILY = 4;
643 | WATCHOS_DEPLOYMENT_TARGET = 3.2;
644 | };
645 | name = Release;
646 | };
647 | BE05A9641F2964A700DEB62E /* Debug */ = {
648 | isa = XCBuildConfiguration;
649 | buildSettings = {
650 | CODE_SIGN_IDENTITY = "";
651 | DEFINES_MODULE = YES;
652 | DYLIB_COMPATIBILITY_VERSION = 1;
653 | DYLIB_CURRENT_VERSION = 1;
654 | DYLIB_INSTALL_NAME_BASE = "@rpath";
655 | INFOPLIST_FILE = Framework/Info.plist;
656 | INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
657 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
658 | PRODUCT_BUNDLE_IDENTIFIER = "com.google.OpenLocationCode-tvOS";
659 | PRODUCT_NAME = OpenLocationCode;
660 | SDKROOT = appletvos;
661 | SKIP_INSTALL = YES;
662 | TARGETED_DEVICE_FAMILY = 3;
663 | TVOS_DEPLOYMENT_TARGET = 10.2;
664 | };
665 | name = Debug;
666 | };
667 | BE05A9651F2964A700DEB62E /* Release */ = {
668 | isa = XCBuildConfiguration;
669 | buildSettings = {
670 | CODE_SIGN_IDENTITY = "";
671 | DEFINES_MODULE = YES;
672 | DYLIB_COMPATIBILITY_VERSION = 1;
673 | DYLIB_CURRENT_VERSION = 1;
674 | DYLIB_INSTALL_NAME_BASE = "@rpath";
675 | INFOPLIST_FILE = Framework/Info.plist;
676 | INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
677 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
678 | PRODUCT_BUNDLE_IDENTIFIER = "com.google.OpenLocationCode-tvOS";
679 | PRODUCT_NAME = OpenLocationCode;
680 | SDKROOT = appletvos;
681 | SKIP_INSTALL = YES;
682 | TARGETED_DEVICE_FAMILY = 3;
683 | TVOS_DEPLOYMENT_TARGET = 10.2;
684 | };
685 | name = Release;
686 | };
687 | BE05A9671F2964A700DEB62E /* Debug */ = {
688 | isa = XCBuildConfiguration;
689 | buildSettings = {
690 | ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES;
691 | INFOPLIST_FILE = Tests/Info.plist;
692 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
693 | PRODUCT_BUNDLE_IDENTIFIER = "com.google.OpenLocationCode-tvOSTests";
694 | PRODUCT_NAME = "$(TARGET_NAME)";
695 | SDKROOT = appletvos;
696 | TVOS_DEPLOYMENT_TARGET = 10.2;
697 | };
698 | name = Debug;
699 | };
700 | BE05A9681F2964A700DEB62E /* Release */ = {
701 | isa = XCBuildConfiguration;
702 | buildSettings = {
703 | ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES;
704 | INFOPLIST_FILE = Tests/Info.plist;
705 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
706 | PRODUCT_BUNDLE_IDENTIFIER = "com.google.OpenLocationCode-tvOSTests";
707 | PRODUCT_NAME = "$(TARGET_NAME)";
708 | SDKROOT = appletvos;
709 | TVOS_DEPLOYMENT_TARGET = 10.2;
710 | };
711 | name = Release;
712 | };
713 | BE05A9801F2964CC00DEB62E /* Debug */ = {
714 | isa = XCBuildConfiguration;
715 | buildSettings = {
716 | CODE_SIGN_IDENTITY = "-";
717 | COMBINE_HIDPI_IMAGES = YES;
718 | DEFINES_MODULE = YES;
719 | DYLIB_COMPATIBILITY_VERSION = 1;
720 | DYLIB_CURRENT_VERSION = 1;
721 | DYLIB_INSTALL_NAME_BASE = "@rpath";
722 | FRAMEWORK_VERSION = A;
723 | INFOPLIST_FILE = Framework/Info.plist;
724 | INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
725 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @loader_path/Frameworks";
726 | MACOSX_DEPLOYMENT_TARGET = 10.12;
727 | PRODUCT_BUNDLE_IDENTIFIER = "com.google.OpenLocationCode-macOS";
728 | PRODUCT_NAME = OpenLocationCode;
729 | SDKROOT = macosx;
730 | SKIP_INSTALL = YES;
731 | };
732 | name = Debug;
733 | };
734 | BE05A9811F2964CC00DEB62E /* Release */ = {
735 | isa = XCBuildConfiguration;
736 | buildSettings = {
737 | CODE_SIGN_IDENTITY = "-";
738 | COMBINE_HIDPI_IMAGES = YES;
739 | DEFINES_MODULE = YES;
740 | DYLIB_COMPATIBILITY_VERSION = 1;
741 | DYLIB_CURRENT_VERSION = 1;
742 | DYLIB_INSTALL_NAME_BASE = "@rpath";
743 | FRAMEWORK_VERSION = A;
744 | INFOPLIST_FILE = Framework/Info.plist;
745 | INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
746 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @loader_path/Frameworks";
747 | MACOSX_DEPLOYMENT_TARGET = 10.12;
748 | PRODUCT_BUNDLE_IDENTIFIER = "com.google.OpenLocationCode-macOS";
749 | PRODUCT_NAME = OpenLocationCode;
750 | SDKROOT = macosx;
751 | SKIP_INSTALL = YES;
752 | };
753 | name = Release;
754 | };
755 | BE05A9831F2964CC00DEB62E /* Debug */ = {
756 | isa = XCBuildConfiguration;
757 | buildSettings = {
758 | ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES;
759 | CODE_SIGN_IDENTITY = "-";
760 | COMBINE_HIDPI_IMAGES = YES;
761 | INFOPLIST_FILE = Tests/Info.plist;
762 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @loader_path/../Frameworks";
763 | MACOSX_DEPLOYMENT_TARGET = 10.12;
764 | PRODUCT_BUNDLE_IDENTIFIER = "com.google.OpenLocationCode-macOSTests";
765 | PRODUCT_NAME = "$(TARGET_NAME)";
766 | SDKROOT = macosx;
767 | };
768 | name = Debug;
769 | };
770 | BE05A9841F2964CC00DEB62E /* Release */ = {
771 | isa = XCBuildConfiguration;
772 | buildSettings = {
773 | ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES;
774 | CODE_SIGN_IDENTITY = "-";
775 | COMBINE_HIDPI_IMAGES = YES;
776 | INFOPLIST_FILE = Tests/Info.plist;
777 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @loader_path/../Frameworks";
778 | MACOSX_DEPLOYMENT_TARGET = 10.12;
779 | PRODUCT_BUNDLE_IDENTIFIER = "com.google.OpenLocationCode-macOSTests";
780 | PRODUCT_NAME = "$(TARGET_NAME)";
781 | SDKROOT = macosx;
782 | };
783 | name = Release;
784 | };
785 | BE9C7A821F23C9F30067DAC8 /* Debug */ = {
786 | isa = XCBuildConfiguration;
787 | buildSettings = {
788 | ALWAYS_SEARCH_USER_PATHS = NO;
789 | CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES;
790 | CLANG_ANALYZER_NONNULL = YES;
791 | CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE;
792 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
793 | CLANG_CXX_LIBRARY = "libc++";
794 | CLANG_ENABLE_MODULES = YES;
795 | CLANG_ENABLE_OBJC_ARC = YES;
796 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
797 | CLANG_WARN_BOOL_CONVERSION = YES;
798 | CLANG_WARN_COMMA = YES;
799 | CLANG_WARN_CONSTANT_CONVERSION = YES;
800 | CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
801 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
802 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
803 | CLANG_WARN_EMPTY_BODY = YES;
804 | CLANG_WARN_ENUM_CONVERSION = YES;
805 | CLANG_WARN_INFINITE_RECURSION = YES;
806 | CLANG_WARN_INT_CONVERSION = YES;
807 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
808 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
809 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
810 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
811 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
812 | CLANG_WARN_STRICT_PROTOTYPES = YES;
813 | CLANG_WARN_SUSPICIOUS_MOVE = YES;
814 | CLANG_WARN_UNREACHABLE_CODE = YES;
815 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
816 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
817 | COPY_PHASE_STRIP = NO;
818 | CURRENT_PROJECT_VERSION = 1;
819 | DEBUG_INFORMATION_FORMAT = dwarf;
820 | ENABLE_STRICT_OBJC_MSGSEND = YES;
821 | ENABLE_TESTABILITY = YES;
822 | GCC_C_LANGUAGE_STANDARD = gnu99;
823 | GCC_DYNAMIC_NO_PIC = NO;
824 | GCC_NO_COMMON_BLOCKS = YES;
825 | GCC_OPTIMIZATION_LEVEL = 0;
826 | GCC_PREPROCESSOR_DEFINITIONS = (
827 | "DEBUG=1",
828 | "$(inherited)",
829 | );
830 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
831 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
832 | GCC_WARN_UNDECLARED_SELECTOR = YES;
833 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
834 | GCC_WARN_UNUSED_FUNCTION = YES;
835 | GCC_WARN_UNUSED_VARIABLE = YES;
836 | IPHONEOS_DEPLOYMENT_TARGET = 10.3;
837 | MTL_ENABLE_DEBUG_INFO = YES;
838 | ONLY_ACTIVE_ARCH = YES;
839 | SDKROOT = iphoneos;
840 | SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG;
841 | SWIFT_OPTIMIZATION_LEVEL = "-Onone";
842 | SWIFT_VERSION = 5.0;
843 | TARGETED_DEVICE_FAMILY = "1,2";
844 | VERSIONING_SYSTEM = "apple-generic";
845 | VERSION_INFO_PREFIX = "";
846 | };
847 | name = Debug;
848 | };
849 | BE9C7A831F23C9F30067DAC8 /* Release */ = {
850 | isa = XCBuildConfiguration;
851 | buildSettings = {
852 | ALWAYS_SEARCH_USER_PATHS = NO;
853 | CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES;
854 | CLANG_ANALYZER_NONNULL = YES;
855 | CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE;
856 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
857 | CLANG_CXX_LIBRARY = "libc++";
858 | CLANG_ENABLE_MODULES = YES;
859 | CLANG_ENABLE_OBJC_ARC = YES;
860 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
861 | CLANG_WARN_BOOL_CONVERSION = YES;
862 | CLANG_WARN_COMMA = YES;
863 | CLANG_WARN_CONSTANT_CONVERSION = YES;
864 | CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
865 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
866 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
867 | CLANG_WARN_EMPTY_BODY = YES;
868 | CLANG_WARN_ENUM_CONVERSION = YES;
869 | CLANG_WARN_INFINITE_RECURSION = YES;
870 | CLANG_WARN_INT_CONVERSION = YES;
871 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
872 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
873 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
874 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
875 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
876 | CLANG_WARN_STRICT_PROTOTYPES = YES;
877 | CLANG_WARN_SUSPICIOUS_MOVE = YES;
878 | CLANG_WARN_UNREACHABLE_CODE = YES;
879 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
880 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
881 | COPY_PHASE_STRIP = NO;
882 | CURRENT_PROJECT_VERSION = 1;
883 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
884 | ENABLE_NS_ASSERTIONS = NO;
885 | ENABLE_STRICT_OBJC_MSGSEND = YES;
886 | GCC_C_LANGUAGE_STANDARD = gnu99;
887 | GCC_NO_COMMON_BLOCKS = YES;
888 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
889 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
890 | GCC_WARN_UNDECLARED_SELECTOR = YES;
891 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
892 | GCC_WARN_UNUSED_FUNCTION = YES;
893 | GCC_WARN_UNUSED_VARIABLE = YES;
894 | IPHONEOS_DEPLOYMENT_TARGET = 10.3;
895 | MTL_ENABLE_DEBUG_INFO = NO;
896 | SDKROOT = iphoneos;
897 | SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
898 | SWIFT_VERSION = 5.0;
899 | TARGETED_DEVICE_FAMILY = "1,2";
900 | VALIDATE_PRODUCT = YES;
901 | VERSIONING_SYSTEM = "apple-generic";
902 | VERSION_INFO_PREFIX = "";
903 | };
904 | name = Release;
905 | };
906 | BE9C7A851F23C9F30067DAC8 /* Debug */ = {
907 | isa = XCBuildConfiguration;
908 | buildSettings = {
909 | CLANG_ENABLE_MODULES = YES;
910 | CODE_SIGN_IDENTITY = "";
911 | DEFINES_MODULE = YES;
912 | DYLIB_COMPATIBILITY_VERSION = 1;
913 | DYLIB_CURRENT_VERSION = 1;
914 | DYLIB_INSTALL_NAME_BASE = "@rpath";
915 | INFOPLIST_FILE = Framework/Info.plist;
916 | INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
917 | IPHONEOS_DEPLOYMENT_TARGET = 8.0;
918 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
919 | PRODUCT_BUNDLE_IDENTIFIER = com.google.OpenLocationCode;
920 | PRODUCT_NAME = OpenLocationCode;
921 | SKIP_INSTALL = YES;
922 | SWIFT_OPTIMIZATION_LEVEL = "-Onone";
923 | };
924 | name = Debug;
925 | };
926 | BE9C7A861F23C9F30067DAC8 /* Release */ = {
927 | isa = XCBuildConfiguration;
928 | buildSettings = {
929 | CLANG_ENABLE_MODULES = YES;
930 | CODE_SIGN_IDENTITY = "";
931 | DEFINES_MODULE = YES;
932 | DYLIB_COMPATIBILITY_VERSION = 1;
933 | DYLIB_CURRENT_VERSION = 1;
934 | DYLIB_INSTALL_NAME_BASE = "@rpath";
935 | INFOPLIST_FILE = Framework/Info.plist;
936 | INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
937 | IPHONEOS_DEPLOYMENT_TARGET = 8.0;
938 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
939 | PRODUCT_BUNDLE_IDENTIFIER = com.google.OpenLocationCode;
940 | PRODUCT_NAME = OpenLocationCode;
941 | SKIP_INSTALL = YES;
942 | };
943 | name = Release;
944 | };
945 | BE9C7A881F23C9F30067DAC8 /* Debug */ = {
946 | isa = XCBuildConfiguration;
947 | buildSettings = {
948 | ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES;
949 | CLANG_ENABLE_MODULES = YES;
950 | INFOPLIST_FILE = Tests/Info.plist;
951 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
952 | PRODUCT_BUNDLE_IDENTIFIER = com.google.OpenLocationCodeTests;
953 | PRODUCT_NAME = OpenLocationCodeTests_iOS;
954 | SWIFT_OPTIMIZATION_LEVEL = "-Onone";
955 | };
956 | name = Debug;
957 | };
958 | BE9C7A891F23C9F30067DAC8 /* Release */ = {
959 | isa = XCBuildConfiguration;
960 | buildSettings = {
961 | ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES;
962 | CLANG_ENABLE_MODULES = YES;
963 | INFOPLIST_FILE = Tests/Info.plist;
964 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
965 | PRODUCT_BUNDLE_IDENTIFIER = com.google.OpenLocationCodeTests;
966 | PRODUCT_NAME = OpenLocationCodeTests_iOS;
967 | };
968 | name = Release;
969 | };
970 | /* End XCBuildConfiguration section */
971 |
972 | /* Begin XCConfigurationList section */
973 | BE05A94C1F29648000DEB62E /* Build configuration list for PBXNativeTarget "OpenLocationCode_watchOS" */ = {
974 | isa = XCConfigurationList;
975 | buildConfigurations = (
976 | BE05A94A1F29648000DEB62E /* Debug */,
977 | BE05A94B1F29648000DEB62E /* Release */,
978 | );
979 | defaultConfigurationIsVisible = 0;
980 | defaultConfigurationName = Release;
981 | };
982 | BE05A9631F2964A700DEB62E /* Build configuration list for PBXNativeTarget "OpenLocationCode_tvOS" */ = {
983 | isa = XCConfigurationList;
984 | buildConfigurations = (
985 | BE05A9641F2964A700DEB62E /* Debug */,
986 | BE05A9651F2964A700DEB62E /* Release */,
987 | );
988 | defaultConfigurationIsVisible = 0;
989 | defaultConfigurationName = Release;
990 | };
991 | BE05A9661F2964A700DEB62E /* Build configuration list for PBXNativeTarget "OpenLocationCode_tvOSTests" */ = {
992 | isa = XCConfigurationList;
993 | buildConfigurations = (
994 | BE05A9671F2964A700DEB62E /* Debug */,
995 | BE05A9681F2964A700DEB62E /* Release */,
996 | );
997 | defaultConfigurationIsVisible = 0;
998 | defaultConfigurationName = Release;
999 | };
1000 | BE05A97F1F2964CC00DEB62E /* Build configuration list for PBXNativeTarget "OpenLocationCode_macOS" */ = {
1001 | isa = XCConfigurationList;
1002 | buildConfigurations = (
1003 | BE05A9801F2964CC00DEB62E /* Debug */,
1004 | BE05A9811F2964CC00DEB62E /* Release */,
1005 | );
1006 | defaultConfigurationIsVisible = 0;
1007 | defaultConfigurationName = Release;
1008 | };
1009 | BE05A9821F2964CC00DEB62E /* Build configuration list for PBXNativeTarget "OpenLocationCode_macOSTests" */ = {
1010 | isa = XCConfigurationList;
1011 | buildConfigurations = (
1012 | BE05A9831F2964CC00DEB62E /* Debug */,
1013 | BE05A9841F2964CC00DEB62E /* Release */,
1014 | );
1015 | defaultConfigurationIsVisible = 0;
1016 | defaultConfigurationName = Release;
1017 | };
1018 | BE9C7A6A1F23C9F30067DAC8 /* Build configuration list for PBXProject "OpenLocationCode" */ = {
1019 | isa = XCConfigurationList;
1020 | buildConfigurations = (
1021 | BE9C7A821F23C9F30067DAC8 /* Debug */,
1022 | BE9C7A831F23C9F30067DAC8 /* Release */,
1023 | );
1024 | defaultConfigurationIsVisible = 0;
1025 | defaultConfigurationName = Release;
1026 | };
1027 | BE9C7A841F23C9F30067DAC8 /* Build configuration list for PBXNativeTarget "OpenLocationCode" */ = {
1028 | isa = XCConfigurationList;
1029 | buildConfigurations = (
1030 | BE9C7A851F23C9F30067DAC8 /* Debug */,
1031 | BE9C7A861F23C9F30067DAC8 /* Release */,
1032 | );
1033 | defaultConfigurationIsVisible = 0;
1034 | defaultConfigurationName = Release;
1035 | };
1036 | BE9C7A871F23C9F30067DAC8 /* Build configuration list for PBXNativeTarget "OpenLocationCodeTests" */ = {
1037 | isa = XCConfigurationList;
1038 | buildConfigurations = (
1039 | BE9C7A881F23C9F30067DAC8 /* Debug */,
1040 | BE9C7A891F23C9F30067DAC8 /* Release */,
1041 | );
1042 | defaultConfigurationIsVisible = 0;
1043 | defaultConfigurationName = Release;
1044 | };
1045 | /* End XCConfigurationList section */
1046 | };
1047 | rootObject = BE9C7A671F23C9F30067DAC8 /* Project object */;
1048 | }
1049 |
--------------------------------------------------------------------------------
/OpenLocationCode.xcodeproj/project.xcworkspace/contents.xcworkspacedata:
--------------------------------------------------------------------------------
1 |
2 |
4 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/OpenLocationCode.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | IDEDidComputeMac32BitWarning
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/OpenLocationCode.xcodeproj/xcshareddata/xcschemes/OpenLocationCode_iOS.xcscheme:
--------------------------------------------------------------------------------
1 |
2 |
5 |
8 |
9 |
15 |
21 |
22 |
23 |
24 |
25 |
30 |
31 |
33 |
39 |
40 |
41 |
42 |
43 |
49 |
50 |
51 |
52 |
53 |
54 |
64 |
65 |
71 |
72 |
73 |
74 |
75 |
76 |
82 |
83 |
89 |
90 |
91 |
92 |
94 |
95 |
98 |
99 |
100 |
--------------------------------------------------------------------------------
/OpenLocationCode.xcodeproj/xcshareddata/xcschemes/OpenLocationCode_macOS.xcscheme:
--------------------------------------------------------------------------------
1 |
2 |
5 |
8 |
9 |
15 |
21 |
22 |
23 |
24 |
25 |
30 |
31 |
33 |
39 |
40 |
41 |
42 |
43 |
49 |
50 |
51 |
52 |
53 |
54 |
64 |
65 |
71 |
72 |
73 |
74 |
75 |
76 |
82 |
83 |
89 |
90 |
91 |
92 |
94 |
95 |
98 |
99 |
100 |
--------------------------------------------------------------------------------
/OpenLocationCode.xcodeproj/xcshareddata/xcschemes/OpenLocationCode_tvOS.xcscheme:
--------------------------------------------------------------------------------
1 |
2 |
5 |
8 |
9 |
15 |
21 |
22 |
23 |
24 |
25 |
30 |
31 |
33 |
39 |
40 |
41 |
42 |
43 |
49 |
50 |
51 |
52 |
53 |
54 |
64 |
65 |
71 |
72 |
73 |
74 |
75 |
76 |
82 |
83 |
89 |
90 |
91 |
92 |
94 |
95 |
98 |
99 |
100 |
--------------------------------------------------------------------------------
/OpenLocationCode.xcodeproj/xcshareddata/xcschemes/OpenLocationCode_watchOS.xcscheme:
--------------------------------------------------------------------------------
1 |
2 |
5 |
8 |
9 |
15 |
21 |
22 |
23 |
24 |
25 |
30 |
31 |
32 |
33 |
34 |
35 |
45 |
46 |
52 |
53 |
54 |
55 |
56 |
57 |
63 |
64 |
70 |
71 |
72 |
73 |
75 |
76 |
79 |
80 |
81 |
--------------------------------------------------------------------------------
/OpenLocationCodeFramework.podspec:
--------------------------------------------------------------------------------
1 | Pod::Spec.new do |s|
2 |
3 | s.name = "OpenLocationCodeFramework"
4 | s.module_name = "OpenLocationCode"
5 | s.version = "3.0.0"
6 | s.summary = "Open Location Code conversion library for Swift and Objective-C"
7 |
8 | s.description = <<-DESC
9 |
10 | Open Location Codes are short, 10-11 character codes that can be used
11 | instead of street addresses. The codes can be generated and decoded offline,
12 | and use a reduced character set that minimises the chance of codes including
13 | words.
14 |
15 | This Pod supports Swift and Objective-C projects on iOS, macOS, tvOS,
16 | and watchOS.
17 |
18 | DESC
19 |
20 | s.homepage = "http://openlocationcode.com"
21 | s.license = "Apache License, Version 2.0"
22 | s.authors = { "William Denniss" => "wdenniss@google.com",
23 | }
24 |
25 | s.platforms = { :ios => "8.0", :osx => "10.9", :watchos => "2.0", :tvos => "9.0" }
26 |
27 | s.source = { :git => "https://github.com/google/open-location-code-swift.git", :tag => s.version }
28 |
29 | s.pod_target_xcconfig = {
30 | # Treat warnings as errors.
31 | 'GCC_TREAT_WARNINGS_AS_ERRORS' => 'YES',
32 | }
33 |
34 | s.swift_version = '5.0'
35 | s.source_files = "Source/*.swift"
36 | s.requires_arc = true
37 | end
38 |
--------------------------------------------------------------------------------
/Package.swift:
--------------------------------------------------------------------------------
1 | // swift-tools-version:4.2
2 |
3 | //===-- OpenLocationCodeTests.swift - Tests for OpenLocationCode.swift ----===//
4 | //
5 | // Copyright 2017 Google Inc.
6 | //
7 | // Licensed under the Apache License, Version 2.0 (the "License");
8 | // you may not use this file except in compliance with the License.
9 | // You may obtain a copy of the License at
10 | //
11 | // http://www.apache.org/licenses/LICENSE-2.0
12 | //
13 | // Unless required by applicable law or agreed to in writing, software
14 | // distributed under the License is distributed on an "AS IS" BASIS,
15 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 | // See the License for the specific language governing permissions and
17 | // limitations under the License.
18 | //
19 | //===----------------------------------------------------------------------===//
20 | //
21 | // Package description for the OpenLocationCode Swift module.
22 | //
23 | //===----------------------------------------------------------------------===//
24 |
25 | import PackageDescription
26 |
27 | let packages = Package(
28 | name: "OpenLocationCode",
29 |
30 | products: [
31 | .library(
32 | name: "OpenLocationCode",
33 | targets: ["OpenLocationCode"]
34 | ),
35 | ],
36 | targets: [
37 | .target(
38 | name: "OpenLocationCode",
39 | path: ".",
40 | exclude: ["Source/OpenLocationCodeObjCBridge.swift", "Framework", "Tests", "test_data"],
41 | sources: ["Source"]
42 | ),
43 | .testTarget(
44 | name: "OpenLocationCodeTests",
45 | dependencies: ["OpenLocationCode"],
46 | exclude: ["OpenLocationCodeObjCTests"]
47 | )
48 | ]
49 | )
50 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # Open Location Code for Swift and Objective-C
2 | [](https://travis-ci.org/google/open-location-code-swift)
3 | [](https://github.com/Carthage/Carthage)
4 |
5 | Convert between decimal degree coordinates and Open Location Codes. Shorten
6 | and recover Open Location Codes for a given reference location.
7 |
8 | This repository is the Swift implementation of Open Location Code.
9 | It supports Swift and Objective-C projects on iOS, macOS, tvOS and
10 | watchOS, and Swift projects on Linux. The
11 | [master repository](https://github.com/google/open-location-code)
12 | has Open Location Code support for many other languages.
13 |
14 | ## About Open Location Codes
15 |
16 | [Open Location Codes](http://openlocationcode.com/) are short, 10-11 character
17 | codes that can be used instead of street addresses. The codes can be generated
18 | and decoded offline, and use a reduced character set that minimises the chance
19 | of codes including words.
20 |
21 | Codes are able to be shortened relative to a nearby location. This means
22 | that in many cases, only four to seven characters of the code are needed.
23 | To recover the original code, the same location is not required, as long as
24 | a nearby location is provided.
25 |
26 | Codes represent rectangular areas rather than points, and the longer the
27 | code, the smaller the area. A 10 character code represents a 13.5x13.5
28 | meter area (at the equator. An 11 character code represents approximately
29 | a 2.8x3.5 meter area.
30 |
31 | Two encoding algorithms are used. The first 10 characters are pairs of
32 | characters, one for latitude and one for latitude, using base 20. Each pair
33 | reduces the area of the code by a factor of 400. Only even code lengths are
34 | sensible, since an odd-numbered length would have sides in a ratio of 20:1.
35 | At position 11, the algorithm changes so that each character selects one
36 | position from a 4x5 grid. This allows single-character refinements.
37 |
38 | ## Supported Environments
39 |
40 | This library is provided as a Swift and Objective-C Cocoa Framework
41 | for iOS, macOS, tvOS and watchOS, and as a pure Swift module
42 | for macOS and Linux.
43 |
44 | ## Swift Versions
45 |
46 | * Versions 3.x of Open Location Code for Swift are designed for Swift 5.0.
47 | * Versions 2.x of Open Location Code for Swift are designed for Swift 4.0.
48 | * Versions 1.x of Open Location Code for Swift were designed for Swift 3.2,
49 | but are no longer maintained.
50 |
51 | ## Building
52 |
53 | ### Cocoa Framework
54 |
55 | To build the Framework:
56 | ```bash
57 | xcodebuild -project OpenLocationCode.xcodeproj -scheme OpenLocationCode_iOS -configuration Release
58 | xcodebuild -project OpenLocationCode.xcodeproj -scheme OpenLocationCode_macOS -configuration Release
59 | xcodebuild -project OpenLocationCode.xcodeproj -scheme OpenLocationCode_tvOS -configuration Release
60 | xcodebuild -project OpenLocationCode.xcodeproj -scheme OpenLocationCode_watchOS -configuration Release
61 | ```
62 |
63 | Or, if you have [Carthage](https://github.com/Carthage/Carthage) installed:
64 | ```bash
65 | carthage build --no-skip-current
66 | ```
67 |
68 | Testing the framework:
69 | ```bash
70 | xcodebuild test -project OpenLocationCode.xcodeproj -scheme OpenLocationCode_macOS -destination 'platform=OS X,arch=x86_64'
71 | ```
72 |
73 | ### Swift Module
74 |
75 | To build the pure Swift module:
76 | ```bash
77 | swift build
78 | ```
79 |
80 | Testing the pure Swift module:
81 | ```bash
82 | swift test
83 | ```
84 |
85 | A Dockerfile is included to build and run the pure Swift module in
86 | a Linux container:
87 | ```bash
88 | docker build .
89 | ```
90 |
91 | ## Swift Code Example
92 |
93 | ```swift
94 | import OpenLocationCode
95 |
96 | // Encode a location with default code length.
97 | if let code = OpenLocationCode.encode(latitude: 37.421908,
98 | longitude: -122.084681) {
99 | print("Open Location Code: \(code)")
100 | }
101 |
102 | // Encode a location with specific code length.
103 | if let code10Digit = OpenLocationCode.encode(latitude: 37.421908,
104 | longitude: -122.084681,
105 | codeLength: 10) {
106 | print("Open Location Code: \(code10Digit)")
107 | }
108 |
109 | // Decode a full code:
110 | if let coord = OpenLocationCode.decode("849VCWC8+Q48") {
111 | print("Center is \(coord.latitudeCenter), \(coord.longitudeCenter)")
112 | }
113 |
114 | // Attempt to trim the first characters from a code:
115 | if let shortCode = OpenLocationCode.shorten(code: "849VCWC8+Q48",
116 | latitude: 37.4,
117 | longitude: -122.0) {
118 | print("Short code: \(shortCode)")
119 | }
120 |
121 | // Recover the full code from a short code:
122 | if let fullCode = OpenLocationCode.recoverNearest(shortcode: "CWC8+Q48",
123 | referenceLatitude: 37.4,
124 | referenceLongitude: -122.0) {
125 | print("Recovered full code: \(fullCode)")
126 | }
127 | ```
128 |
129 | ## Objective-C Code Example
130 |
131 | ```objc
132 | @import OpenLocationCode;
133 |
134 | // ...
135 |
136 | // Encode a location with default code length.
137 | NSString *code = [OLCConverter encodeLatitude:37.421908
138 | longitude:-122.084681];
139 | NSLog(@"Open Location Code: %@", code);
140 |
141 | // Encode a location with specific code length.
142 | NSString *code10Digit = [OLCConverter encodeLatitude:37.421908
143 | longitude:-122.084681
144 | codeLength:10];
145 | NSLog(@"Open Location Code: %@", code10Digit);
146 |
147 | // Decode a full code:
148 | OLCArea *coord = [OLCConverter decode:@"849VCWC8+Q48"];
149 | NSLog(@"Center is %.6f, %.6f", coord.latitudeCenter, coord.longitudeCenter);
150 |
151 | // Attempt to trim the first characters from a code:
152 | NSString *shortCode = [OLCConverter shortenCode:@"849VCWC8+Q48"
153 | latitude:37.4
154 | longitude:-122.0];
155 | NSLog(@"Short Code: %@", shortCode);
156 |
157 | // Recover the full code from a short code:
158 | NSString *recoveredCode = [OLCConverter recoverNearestWithShortcode:@"CWC8+Q48"
159 | referenceLatitude:37.4
160 | referenceLongitude:-122.1];
161 | NSLog(@"Recovered Full Code: %@", recoveredCode);
162 | ```
163 |
164 | ## Testing the CI Locally
165 |
166 | To run the Travis CI tests locally, install:
167 |
168 | ```
169 | gem install wwtd
170 | gem install xcpretty
171 | ```
172 |
173 | And run:
174 | ```
175 | wwtd
176 | ```
177 |
178 | Your version of Xcode and macOS will need to match the Travis `osx_image`
179 | [configuration](https://docs.travis-ci.com/user/reference/osx/#macos-version).
180 |
--------------------------------------------------------------------------------
/Source/OpenLocationCode.swift:
--------------------------------------------------------------------------------
1 | //===--- OpenLocationCode.swift - Open Location Code encoding/decoding-----===//
2 | //
3 | // Copyright 2017 Google Inc.
4 | //
5 | // Licensed under the Apache License, Version 2.0 (the "License");
6 | // you may not use this file except in compliance with the License.
7 | // You may obtain a copy of the License at
8 | //
9 | // http://www.apache.org/licenses/LICENSE-2.0
10 | //
11 | // Unless required by applicable law or agreed to in writing, software
12 | // distributed under the License is distributed on an "AS IS" BASIS,
13 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | // See the License for the specific language governing permissions and
15 | // limitations under the License.
16 | //
17 | //===----------------------------------------------------------------------===//
18 | //
19 | // Convert between decimal degree coordinates and Open Location Codes. Shorten
20 | // and recover Open Location Codes for a given reference location.
21 | //
22 | // Authored by William Denniss. Ported from openlocationcode.py.
23 | //
24 | //===----------------------------------------------------------------------===//
25 |
26 | import Foundation
27 |
28 | /// A separator used to break the code into two parts to aid memorability.
29 | let kSeparator: Character = "+"
30 |
31 | /// String representation of kSeparator.
32 | let kSeparatorString = String(kSeparator)
33 |
34 | /// The number of characters to place before the separator.
35 | let kSeparatorPosition = 8
36 |
37 | /// The character used to pad codes.
38 | let kPaddingCharacter: Character = "0"
39 |
40 | /// String representation of kPaddingCharacter.
41 | let kPaddingCharacterString = String(kPaddingCharacter)
42 |
43 | /// The character set used to encode the values.
44 | let kCodeAlphabet = "23456789CFGHJMPQRVWX"
45 |
46 | /// CharacterSet representation of kCodeAlphabet.
47 | let kCodeAlphabetCharset = CharacterSet.init(charactersIn: kCodeAlphabet)
48 |
49 | /// The base to use to convert numbers to/from.
50 | let kEncodingBase:UInt32 = UInt32(kCodeAlphabet.count)
51 |
52 | /// The maximum value for latitude in degrees.
53 | let kLatitudeMax = 90.0
54 |
55 | /// The maximum value for longitude in degrees.
56 | let kLongitudeMax = 180.0
57 |
58 | /// Maximum code length using lat/lng pair encoding. The area of such a
59 | /// code is approximately 13x13 meters (at the equator), and should be suitable
60 | /// for identifying buildings. This excludes prefix and separator characters.
61 | let kPairCodeLength = 10
62 |
63 | /// The resolution values in degrees for each position in the lat/lng pair
64 | /// encoding. These give the place value of each position, and therefore the
65 | /// dimensions of the resulting area. Each value is the previous, divided
66 | /// by the base (kCodeAlphabet.length).
67 | let kPairResolutions = [20.0, 1.0, 0.05, 0.0025, 0.000125]
68 |
69 | /// Number of columns in the grid refinement method.
70 | let kGridColumns:Int = 4;
71 |
72 | /// Number of rows in the grid refinement method.
73 | let kGridRows:Int = 5;
74 |
75 | /// Size of the initial grid in degrees.
76 | let kGridSizeDegrees = 0.000125
77 |
78 | /// Minimum length of a code that can be shortened.
79 | let kMinTrimmableCodeLen = 6
80 |
81 | /// Space/padding characters. Unioned with kCodeAlphabet, forms the
82 | /// complete valid charset for Open Location Codes.
83 | let kLegalCharacters = CharacterSet.init(charactersIn: "23456789CFGHJMPQRVWX+0")
84 |
85 | /// Default length of encoded Open Location Codes (not including + symbol).
86 | public let kDefaultFullCodeLength = 11
87 |
88 | /// The maximum significant digits in a plus code.
89 | let kMaxCodeLength = 15
90 |
91 | /// Default truncation amount for short codes.
92 | public let kDefaultShortCodeTruncation = 4
93 |
94 | /// Minimum amount to truncate a short code if it will be truncated.
95 | /// Avoids creating short codes that are not really worth the shortening (i.e.
96 | /// chars saved doesn't make up for need to resolve).
97 | let kMinShortCodeTruncation = 4
98 |
99 | /// Coordinates of a decoded Open Location Code.
100 | /// The coordinates include the latitude and longitude of the lower left and
101 | /// upper right corners and the center of the bounding box for the area the
102 | /// code represents.
103 | public struct OpenLocationCodeArea {
104 | /// The latitude of the SW corner in degrees.
105 | public let latitudeLo: Double
106 | /// The longitude of the SW corner in degrees.
107 | public let longitudeLo: Double
108 | /// The latitude of the NE corner in degrees.
109 | public let latitudeHi: Double
110 | /// The longitude of the NE corner in degrees.
111 | public let longitudeHi: Double
112 | /// The number of significant characters that were in the code.
113 | /// This excludes the separator.
114 | public let codeLength: Int
115 | /// The latitude of the center in degrees.
116 | public let latitudeCenter: Double
117 | /// latitude_center: The latitude of the center in degrees.
118 | public let longitudeCenter: Double
119 |
120 | /// - Parameter latitudeLo: The latitude of the SW corner in degrees.
121 | /// - Parameter longitudeLo: The longitude of the SW corner in degrees.
122 | /// - Parameter latitudeHi: The latitude of the NE corner in degrees.
123 | /// - Parameter longitudeHi: The longitude of the NE corner in degrees.
124 | /// - Parameter codeLength: The number of significant characters that were in
125 | /// the code.
126 | init(latitudeLo: Double,
127 | longitudeLo: Double,
128 | latitudeHi: Double,
129 | longitudeHi: Double,
130 | codeLength: Int) {
131 | self.latitudeLo = latitudeLo
132 | self.longitudeLo = longitudeLo
133 | self.latitudeHi = latitudeHi
134 | self.longitudeHi = longitudeHi
135 | self.codeLength = codeLength
136 | self.latitudeCenter = min(latitudeLo + (latitudeHi - latitudeLo) / 2,
137 | kLatitudeMax)
138 | self.longitudeCenter = min(longitudeLo + (longitudeHi - longitudeLo) / 2,
139 | kLongitudeMax)
140 | }
141 |
142 | // Returns lat/lng coordinate array representing the area's center point.
143 | func latlng() -> Array{
144 | return [self.latitudeCenter, self.longitudeCenter]
145 | }
146 | }
147 |
148 | /// Convert between decimal degree coordinates and plus codes. Shorten and
149 | /// recover plus codes for a given reference location.
150 | ///
151 | /// Open Location Codes are short, 10-11 character codes that can be used
152 | /// instead of street addresses. The codes can be generated and decoded offline,
153 | /// and use a reduced character set that minimises the chance of codes including
154 | /// words.
155 | ///
156 | /// Codes are able to be shortened relative to a nearby location. This means
157 | /// that in many cases, only four to seven characters of the code are needed.
158 | /// To recover the original code, the same location is not required, as long as
159 | /// a nearby location is provided.
160 | ///
161 | /// Codes represent rectangular areas rather than points, and the longer the
162 | /// code, the smaller the area. A 10 character code represents a 13.5x13.5
163 | /// meter area (at the equator. An 11 character code represents approximately
164 | /// a 2.8x3.5 meter area.
165 | ///
166 | /// Two encoding algorithms are used. The first 10 characters are pairs of
167 | /// characters, one for latitude and one for longitude, using base 20. Each pair
168 | /// reduces the area of the code by a factor of 400. Only even code lengths are
169 | /// sensible, since an odd-numbered length would have sides in a ratio of 20:1.
170 | ///
171 | /// At position 11, the algorithm changes so that each character selects one
172 | /// position from a 4x5 grid. This allows single-character refinements.
173 | ///
174 | /// # Swift Example
175 | /// ```
176 | /// import OpenLocationCode
177 | ///
178 | /// // ...
179 | ///
180 | /// // Encode a location with default code length.
181 | /// if let code = OpenLocationCode.encode(latitude: 37.421908,
182 | /// longitude: -122.084681) {
183 | /// print("Open Location Code: \(code)")
184 | /// }
185 | ///
186 | /// // Encode a location with specific code length.
187 | /// if let code10Digit = OpenLocationCode.encode(latitude: 37.421908,
188 | /// longitude: -122.084681,
189 | /// codeLength: 10) {
190 | /// print("Open Location Code: \(code10Digit)")
191 | /// }
192 | ///
193 | /// // Decode a full code:
194 | /// if let coord = OpenLocationCode.decode("849VCWC8+Q48") {
195 | /// print("Center is \(coord.latitudeCenter), \(coord.longitudeCenter)")
196 | /// }
197 | ///
198 | /// // Attempt to trim the first characters from a code:
199 | /// if let shortCode = OpenLocationCode.shorten(code: "849VCWC8+Q48",
200 | /// latitude: 37.4,
201 | /// longitude: -122.0) {
202 | /// print("Short code: \(shortCode)")
203 | /// }
204 | ///
205 | /// // Recover the full code from a short code:
206 | /// if let fullCode = OpenLocationCode.recoverNearest(shortcode: "CWC8+Q48",
207 | /// referenceLatitude: 37.4,
208 | /// referenceLongitude: -122.0) {
209 | /// print("Recovered full code: \(fullCode)")
210 | /// }
211 | /// ```
212 | /// # Objective-C Examples
213 | /// ```
214 | /// @import OpenLocationCode;
215 | ///
216 | /// // ...
217 | ///
218 | /// // Encode a location with default code length.
219 | /// NSString *code = [OLCConverter encodeLatitude:37.421908
220 | /// longitude:-122.084681];
221 | /// NSLog(@"Open Location Code: %@", code);
222 | ///
223 | /// // Encode a location with specific code length.
224 | /// NSString *code10Digit = [OLCConverter encodeLatitude:37.421908
225 | /// longitude:-122.084681
226 | /// codeLength:10];
227 | /// NSLog(@"Open Location Code: %@", code10Digit);
228 | ///
229 | /// // Decode a full code:
230 | /// OLCArea *coord = [OLCConverter decode:@"849VCWC8+Q48"];
231 | /// NSLog(@"Center is %.6f, %.6f", coord.latitudeCenter, coord.longitudeCenter);
232 | ///
233 | /// // Attempt to trim the first characters from a code:
234 | /// NSString *shortCode = [OLCConverter shortenCode:@"849VCWC8+Q48"
235 | /// latitude:37.4
236 | /// longitude:-122.0];
237 | /// NSLog(@"Short Code: %@", shortCode);
238 | ///
239 | /// // Recover the full code from a short code:
240 | /// NSString *recoveredCode = [OLCConverter recoverNearestWithShortcode:@"CWC8+Q48"
241 | /// referenceLatitude:37.4
242 | /// referenceLongitude:-122.1];
243 | /// NSLog(@"Recovered Full Code: %@", recoveredCode);
244 | /// ```
245 | ///
246 | public class OpenLocationCode {
247 | /// Determines if a code is valid.
248 | /// To be valid, all characters must be from the Open Location Code character
249 | /// set with at most one separator. The separator can be in any even-numbered
250 | /// position up to the eighth digit.
251 | ///
252 | /// - Parameter code: The Open Location Code to test.
253 | /// - Returns: true if the code is a valid Open Location Code.
254 | public static func isValid(code: String) -> Bool {
255 |
256 | // The separator is required.
257 | let sep = code.find(kSeparatorString)
258 | if ((code.filter{$0 == kSeparator} as String).count) > 1 {
259 | return false
260 | }
261 | // Is it the only character?
262 | if code.utf8.count == 1 {
263 | return false;
264 | }
265 | // Is it in an illegal position?
266 | if sep == -1 || sep > kSeparatorPosition || sep % 2 == 1 {
267 | return false
268 | }
269 | // We can have an even number of padding characters before the separator,
270 | // but then it must be the final character.
271 | let pad = code.find(kPaddingCharacterString)
272 | if pad != -1 {
273 | // Not allowed to start with them!
274 | if pad == 0 {
275 | return false
276 | }
277 |
278 | // There can only be one group and it must have even length.
279 | let rpad = code.rfind(kPaddingCharacterString) + 1
280 | let pads = code.substring(from:pad, to: rpad)
281 | let padCharCount = (pads.filter{$0 == kPaddingCharacter} as String).count
282 | if pads.count % 2 == 1
283 | || padCharCount != pads.count {
284 | return false
285 | }
286 | // Padded codes must end with a separator, make sure it does.
287 | let padrange = code.range(of: kSeparatorString,
288 | options: String.CompareOptions.backwards)!
289 | if padrange.upperBound != code.endIndex {
290 | return false
291 | }
292 | }
293 | // If there are characters after the separator, make sure there isn't just
294 | // one of them (not legal).
295 | if code.count - sep - 1 == 1 {
296 | return false
297 | }
298 | // Check the code contains only valid characters.
299 | let invalidChars = kLegalCharacters.inverted
300 | if code.uppercased().rangeOfCharacter(from: invalidChars) != nil {
301 | return false
302 | }
303 | return true
304 | }
305 |
306 | /// Determines if a code is a valid short code.
307 | /// A short Open Location Code is a sequence created by removing four or more
308 | /// digits from an Open Location Code. It must include a separator
309 | /// character.
310 | ///
311 | /// - Parameter code: The Open Location Code to test.
312 | /// - Returns: true if the code is a short Open Location Code.
313 | public static func isShort(code: String) -> Bool {
314 | // Check it's valid.
315 | if !isValid(code: code) {
316 | return false
317 | }
318 | // If there are less characters than expected before the SEPARATOR.
319 | let sep = code.find(kSeparatorString)
320 | if sep >= 0 && sep < kSeparatorPosition {
321 | return true
322 | }
323 | return false
324 | }
325 |
326 | // Determines if a code is a valid full Open Location Code.
327 | // Not all possible combinations of Open Location Code characters decode to
328 | // valid latitude and longitude values. This checks that a code is valid
329 | // and also that the latitude and longitude values are legal. If the prefix
330 | // character is present, it must be the first character. If the separator
331 | // character is present, it must be after four characters.
332 | ///
333 | /// - Parameter code: The Open Location Code to test.
334 | /// - Returns: true if the code is a full Open Location Code.
335 | public static func isFull(code: String) -> Bool {
336 |
337 | if !isValid(code: code) {
338 | return false
339 | }
340 |
341 | // If it's short, it's not full
342 | if isShort(code: code) {
343 | return false
344 | }
345 |
346 | // Work out what the first latitude character indicates for latitude.
347 | let firstChar = code.uppercased()[0] // returns Character 'o'
348 | let firstLatValue =
349 | Double(kCodeAlphabet.find(String(firstChar))) * Double(kEncodingBase)
350 |
351 | if firstLatValue >= Double(kLatitudeMax) * 2 {
352 | // The code would decode to a latitude of >= 90 degrees.
353 | return false
354 | }
355 |
356 | if code.count > 1 {
357 | // Work out what the first longitude character indicates for longitude.
358 | let firstChar = code.uppercased()[1] // returns Character 'o'
359 | let firstLngValue =
360 | Double(kCodeAlphabet.find(String(firstChar))) * Double(kEncodingBase)
361 |
362 | if firstLngValue >= Double(kLongitudeMax) * 2 {
363 | // The code would decode to a longitude of >= 180 degrees.
364 | return false
365 | }
366 | }
367 | return true
368 | }
369 |
370 | /// Clip a latitude into the range -90 to 90.
371 | ///
372 | /// - Parameter latitude: A latitude in signed decimal degrees.
373 | internal static func clipLatitude(_ latitude: Double) -> Double {
374 | return min(90.0, max(-90.0, latitude))
375 | }
376 |
377 | /// Compute the latitude precision value for a given code length. Lengths <=
378 | /// 10 have the same precision for latitude and longitude, but lengths > 10
379 | /// have different precisions due to the grid method having fewer columns than
380 | /// rows.
381 | internal static func computeLatitudePrecision(_ codeLength: Int) -> Double {
382 | if codeLength <= 10 {
383 | return pow(Double(20), Double(codeLength / -2 + 2))
384 | }
385 | return pow(20.0, -3.0)
386 | / pow(Double(kGridRows), Double(codeLength - 10))
387 | }
388 |
389 | /// Normalize a longitude into the range -180 to 180, not including 180.
390 | ///
391 | /// - Parameter longitude: A longitude in signed decimal degrees.
392 | internal static func normalizeLongitude(_ longitude: Double) -> Double {
393 | var longitude = longitude
394 | while longitude < -180 {
395 | longitude += 360
396 | }
397 | while longitude >= 180 {
398 | longitude -= 360
399 | }
400 | return longitude
401 | }
402 |
403 | /// Encode a location into a sequence of OLC lat/lng pairs.
404 | /// This uses pairs of characters (longitude and latitude in that order) to
405 | /// represent each step in a 20x20 grid. Each code, therefore, has 1/400th
406 | /// the area of the previous code.
407 | ///
408 | /// - Parameter latitude: A latitude in signed decimal degrees.
409 | /// - Parameter longitude: A longitude in signed decimal degrees.
410 | /// - Parameter codeLength: The number of significant digits in the output
411 | /// code, not including any separator characters.
412 | internal static func encodePairs(latitude: Double,
413 | longitude: Double,
414 | codeLength: Int) -> String {
415 |
416 | var code: String = ""
417 | // Adjust latitude and longitude so they fall into positive ranges.
418 | var adjustedLatitude = latitude + kLatitudeMax
419 | var adjustedLongitude = longitude + kLongitudeMax
420 | // Count digits - can't use string length because it may include a separator
421 | // character.
422 | var digitCount = 0
423 | while digitCount < codeLength {
424 | // Provides the value of digits in this place in decimal degrees.
425 | let placeValue = kPairResolutions[digitCount / 2]
426 | // Do the latitude - gets the digit for this place and subtracts that for
427 | // the next digit.
428 | var digitValue:Int = Int(adjustedLatitude / placeValue)
429 | adjustedLatitude -= Double(digitValue) * placeValue
430 | code += String(kCodeAlphabet[digitValue])
431 | digitCount += 1
432 | // And do the longitude - gets the digit for this place and subtracts that
433 | // for the next digit.
434 | digitValue = Int(adjustedLongitude / placeValue)
435 | adjustedLongitude -= Double(digitValue) * placeValue
436 | code += String(kCodeAlphabet[digitValue])
437 | digitCount += 1
438 | // Should we add a separator here?
439 | if digitCount == kSeparatorPosition && digitCount < codeLength {
440 | code += String(kSeparator)
441 | }
442 | }
443 | while code.count < kSeparatorPosition {
444 | code += "0"
445 | }
446 | if code.count == kSeparatorPosition {
447 | code += String(kSeparator)
448 | }
449 | return code
450 | }
451 |
452 | /// Encode a location using the grid refinement method into an OLC string.
453 | /// The grid refinement method divides the area into a grid of 4x5, and uses a
454 | /// single character to refine the area. This allows default accuracy OLC
455 | /// codes to be refined with just a single character.
456 | ///
457 | /// - Parameter latitude: A latitude in signed decimal degrees.
458 | /// - Parameter longitude: A longitude in signed decimal degrees.
459 | /// - Parameter codeLength: The number of characters required.
460 | /// - Returns: Open Location Code representing the given grid.
461 | public static func encodeGrid(latitude: Double,
462 | longitude: Double,
463 | codeLength: Int) -> String {
464 | var code: String = ""
465 | var latPlaceValue = kGridSizeDegrees
466 | var lngPlaceValue = kGridSizeDegrees
467 | // Adjust latitude and longitude so they fall into positive ranges and
468 | // get the offset for the required places.
469 | var adjustedLatitude = latitude + kLatitudeMax
470 | var adjustedLongitude = longitude + kLongitudeMax
471 | // To avoid problems with floating point, get rid of the degrees.
472 | adjustedLatitude = adjustedLatitude.truncatingRemainder(dividingBy: 1)
473 | adjustedLongitude = adjustedLongitude.truncatingRemainder(dividingBy: 1)
474 | adjustedLatitude = adjustedLatitude.truncatingRemainder(dividingBy: latPlaceValue)
475 | adjustedLongitude = adjustedLongitude.truncatingRemainder(dividingBy: lngPlaceValue)
476 |
477 | for _ in (0.. 14 are sub-centimetre and so
496 | /// 11 or 12 are probably the limit of useful codes.
497 | ///
498 | /// - Parameter latitude: A latitude in signed decimal degrees. Will be
499 | /// clipped to the range -90 to 90.
500 | /// - Parameter longitude: A longitude in signed decimal degrees. Will be
501 | /// normalised to the range -180 to 180.
502 | /// - Parameter codeLength: The number of significant digits in the output
503 | /// code, not including any separator characters. Possible values are;
504 | /// `2`, `4`, `6`, `8`, `10`, `11`, `12`, `13`, `14`, and `15`. Values
505 | /// above `15` are accepted, but treated as `15`. Lower values
506 | /// indicate a larger area, higher values a more precise area.
507 | /// You can also shorten a code after encoding for codes used with a
508 | /// reference point (e.g. your current location, a city, etc).
509 | /// - Returns: Open Location Code for the given coordinate.
510 | public static func encode(latitude: Double,
511 | longitude: Double,
512 | codeLength: Int = kDefaultFullCodeLength)
513 | -> String? {
514 | if codeLength < 2
515 | || (codeLength < kPairCodeLength && codeLength % 2 == 1) {
516 | // 'Invalid Open Location Code length - '
517 | return nil
518 | }
519 | var codeLength = codeLength
520 | codeLength = min(codeLength, kMaxCodeLength)
521 |
522 | // Ensure that latitude and longitude are valid.
523 | var latitude = clipLatitude(latitude)
524 | let longitude = normalizeLongitude(longitude)
525 |
526 | // Latitude 90 needs to be adjusted to be just less, so the returned code
527 | // can also be decoded.
528 | if latitude == 90 {
529 | latitude = latitude - Double(computeLatitudePrecision(codeLength))
530 | }
531 | var code = encodePairs(latitude: latitude,
532 | longitude: longitude,
533 | codeLength: min(codeLength, kPairCodeLength))
534 | // If the requested length indicates we want grid refined codes.
535 | if codeLength > kPairCodeLength {
536 | code = code + encodeGrid(latitude: latitude,
537 | longitude: longitude,
538 | codeLength: codeLength - kPairCodeLength)
539 | }
540 | return code
541 | }
542 |
543 | /// Decode an OLC code made up of lat/lng pairs.
544 | /// This decodes an OLC code made up of alternating latitude and longitude
545 | /// characters, encoded using base 20.
546 | ///
547 | /// - Parameter code: A valid OLC code, presumed to be full, but with the
548 | /// separator removed.
549 | internal static func decodePairs(_ code: String) -> OpenLocationCodeArea? {
550 |
551 | // Get the latitude and longitude values. These will need correcting from
552 | // positive ranges.
553 | let latitude = decodePairsSequence(code: code, offset: 0)!
554 | let longitude = decodePairsSequence(code: code, offset: 1)!
555 | // Correct the values and set them into the CodeArea object.
556 | return OpenLocationCodeArea(latitudeLo: latitude[0] - kLatitudeMax,
557 | longitudeLo: longitude[0] - kLongitudeMax,
558 | latitudeHi: latitude[1] - kLatitudeMax,
559 | longitudeHi: longitude[1] - kLongitudeMax,
560 | codeLength: code.count)
561 | }
562 |
563 | /// Decode either a latitude or longitude sequence.
564 | /// This decodes the latitude or longitude sequence of a lat/lng pair
565 | // encoding. Starting at the character at position offset, every second
566 | /// character is decoded and the value returned.
567 | ///
568 | /// - Parameter code: A valid OLC code, presumed to be full, with the
569 | /// separator removed.
570 | /// - Parameter offset: The character to start from.
571 | /// - Returns: A pair of the low and high values. The low value comes from
572 | /// decoding the
573 | /// characters. The high value is the low value plus the resolution of the
574 | /// last position. Both values are offset into positive ranges and will need
575 | /// to be corrected before use.
576 | internal static func decodePairsSequence(code: String,
577 | offset: Int) -> Array? {
578 | var i = 0
579 | var value = 0.0
580 | while (i * 2 + offset < code.count) {
581 | let pos = kCodeAlphabet.find(String(code[i * 2 + offset]))
582 | let value3 = Double(pos) * kPairResolutions[i]
583 | value += value3
584 | i += 1
585 | }
586 | return [value, value + kPairResolutions[i - 1]]
587 | }
588 |
589 | /// Decode the grid refinement portion of an OLC code.
590 | /// This decodes an OLC code using the grid refinement method.
591 | ///
592 | /// - Parameter code: A valid OLC code sequence that is only the grid
593 | /// refinement portion. This is the portion of a code starting at position
594 | /// 11.
595 | internal static func decodeGrid(_ code: String) -> OpenLocationCodeArea? {
596 |
597 | var latitudeLo = 0.0
598 | var longitudeLo = 0.0
599 | var latPlaceValue = kGridSizeDegrees
600 | var lngPlaceValue = kGridSizeDegrees
601 | var i = 0
602 | while i < code.count {
603 | let codeIndex = kCodeAlphabet.find(String(code[i]))
604 | let row = codeIndex / kGridColumns
605 | let col = codeIndex % kGridColumns
606 | latPlaceValue /= Double(kGridRows)
607 | lngPlaceValue /= Double(kGridColumns)
608 | latitudeLo += Double(row) * latPlaceValue
609 | longitudeLo += Double(col) * lngPlaceValue
610 | i += 1
611 | }
612 | return OpenLocationCodeArea(latitudeLo: latitudeLo,
613 | longitudeLo: longitudeLo,
614 | latitudeHi: latitudeLo + latPlaceValue,
615 | longitudeHi: longitudeLo + lngPlaceValue,
616 | codeLength: code.count);
617 | }
618 |
619 | /// Decodes an Open Location Code into the location coordinates.
620 | /// Returns a OpenLocationCodeArea object that includes the coordinates of the
621 | /// bounding box - the lower left, center and upper right.
622 | ///
623 | /// - Parameter code: The Open Location Code to decode.
624 | /// - Returns: A CodeArea object that provides the latitude and longitude of
625 | /// two of the corners of the area, the center, and the length of the
626 | /// original code.
627 | public static func decode(_ code: String) -> OpenLocationCodeArea? {
628 | var code = code
629 | if !isFull(code: code) {
630 | return nil
631 | }
632 | // Strip out separator character (we've already established the code is
633 | // valid so the maximum is one), padding characters and convert to upper
634 | // case.
635 | code = code.uppercased()
636 | code = String(code.filter {
637 | kCodeAlphabetCharset.contains(String($0).unicodeScalars.first!)
638 | })
639 | // Constrain to max digits (NB. plus symbol already removed).
640 | if (code.length > kMaxCodeLength) {
641 | code = code.substring(to:kMaxCodeLength)
642 | }
643 |
644 | // Decode the lat/lng pair component.
645 | let codeArea = decodePairs(code[0.. RRRR.RRSSSS
671 | /// SSSSS -> RRRR.RRSSSSS
672 | /// SSSSSS -> RRRR.SSSSSS
673 | /// SSSSSSS -> RRRR.SSSSSSS
674 | /// ```
675 | ///
676 | /// Note that short codes with an odd number of characters will have their
677 | /// last character decoded using the grid refinement algorithm.
678 | ///
679 | /// - Parameter shortcode: A valid short OLC character sequence.
680 | /// - Parameter referenceLatitude: The latitude (in signed decimal degrees) to
681 | /// use to find the nearest matching full code.
682 | /// - Parameter referenceLongitude: The longitude (in signed decimal degrees)
683 | /// to use to find the nearest matching full code.
684 | /// - Returns: The nearest full Open Location Code to the reference location
685 | /// that matches the short code. If the passed code was not a valid short
686 | /// code, but was a valid full code, it is returned with proper capitalization
687 | /// but otherwise unchanged.
688 | public static func recoverNearest(shortcode: String,
689 | referenceLatitude: Double,
690 | referenceLongitude: Double) -> String? {
691 |
692 | var referenceLatitude = referenceLatitude;
693 | var referenceLongitude = referenceLongitude;
694 |
695 | // Passed short code is actually a full code.
696 | if isFull(code: shortcode) {
697 | return shortcode.uppercased()
698 | }
699 | // Passed short code is not valid.
700 | if !isShort(code: shortcode) {
701 | return nil
702 | }
703 | // Ensure that latitude and longitude are valid.
704 | referenceLatitude = clipLatitude(referenceLatitude)
705 | referenceLongitude = normalizeLongitude(referenceLongitude)
706 | // Clean up the passed code.
707 | let shortcode = shortcode.uppercased()
708 | // Compute the number of digits we need to recover.
709 | let paddingLength = kSeparatorPosition - shortcode.find(kSeparatorString)
710 | // The resolution (height and width) of the padded area in degrees.
711 | let resolution: Double = pow(20, Double(2 - (paddingLength / 2)))
712 | // Distance from the center to an edge (in degrees).
713 | let halfResolution: Double = resolution / 2.0
714 | // Encodes the reference location, uses it to fill in the gaps of the
715 | // given short code, creating a full code, then decodes it.
716 | guard let encodedReferencePoint =
717 | encode(latitude: referenceLatitude, longitude: referenceLongitude)
718 | else {
719 | return nil
720 | }
721 | let expandedCode = encodedReferencePoint[0..= -kLatitudeMax {
733 | // If the proposed code is more than half a cell north of the reference
734 | // location, it's too far, and the best match will be one cell south.
735 | latitudeCenter -= resolution
736 | } else if referenceLatitude - halfResolution > latitudeCenter
737 | && latitudeCenter + resolution <= kLatitudeMax {
738 | // If the proposed code is more than half a cell south of the reference
739 | // location, it's too far, and the best match will be one cell north.
740 | latitudeCenter += resolution
741 | }
742 | // Adjust longitude if necessary.
743 | if referenceLongitude + halfResolution < longitudeCenter {
744 | longitudeCenter -= resolution
745 | } else if referenceLongitude - halfResolution > longitudeCenter {
746 | longitudeCenter += resolution
747 | }
748 |
749 | return encode(latitude: latitudeCenter,
750 | longitude: longitudeCenter,
751 | codeLength: codeArea.codeLength)
752 | }
753 |
754 | /// Remove characters from the start of an OLC code.
755 | /// This uses a reference location to determine how many initial characters
756 | /// can be removed from the OLC code. The number of characters that can be
757 | /// removed depends on the distance between the code center and the reference
758 | /// location.
759 | /// The minimum number of characters that will be removed is four. If more
760 | /// than four characters can be removed, the additional characters will be
761 | /// replaced with the padding character. At most eight characters will be
762 | /// removed. The reference location must be within 50% of the maximum range.
763 | /// This ensures that the shortened code will be able to be recovered using
764 | /// slightly different locations.
765 | ///
766 | /// - Parameter code: A full, valid code to shorten.
767 | /// - Parameter latitude: A latitude, in signed decimal degrees, to use as the
768 | /// reference point.
769 | /// - Parameter longitude: A longitude, in signed decimal degrees, to use as
770 | /// the reference point.
771 | /// - Parameter maximumTruncation: The maximum number of characters to remove.
772 | /// - Returns: Either the original code, if the reference location was not
773 | /// close enough, or the original.
774 | public static func shorten(code: String,
775 | latitude: Double,
776 | longitude: Double,
777 | maximumTruncation: Int = kDefaultShortCodeTruncation)
778 | -> String? {
779 | if !isFull(code: code) {
780 | // Passed code is not valid and full
781 | return nil
782 | }
783 | if code.find(kPaddingCharacterString) != -1 {
784 | // Cannot shorten padded codes
785 | return nil
786 | }
787 | let code = code.uppercased()
788 | let codeArea = decode(code)
789 | if codeArea!.codeLength < kMinTrimmableCodeLen {
790 | // Code length must be at least kMinTrimmableCodeLen
791 | return nil
792 | }
793 | // Ensure that latitude and longitude are valid.
794 | let latitude = clipLatitude(latitude)
795 | let longitude = normalizeLongitude(longitude)
796 | // How close are the latitude and longitude to the code center.
797 | let coderange = max(abs(codeArea!.latitudeCenter - latitude),
798 | abs(codeArea!.longitudeCenter - longitude))
799 |
800 | for i in stride(from: kPairResolutions.count - kMinShortCodeTruncation/2,
801 | to: 0,
802 | by: -1) {
803 | // Check if we're close enough to shorten. The range must be less than 1/2
804 | // the resolution to shorten at all, and we want to allow some safety, so
805 | // use 0.3 instead of 0.5 as a multiplier.
806 | if coderange < (kPairResolutions[i] * 0.3) {
807 | let shortenby = min(maximumTruncation, (i+1)*2)
808 | // Trim it.
809 | let shortcode = code.substring(from: shortenby)
810 | return shortcode
811 | }
812 | }
813 | return code
814 | }
815 | }
816 |
817 | /// Several extensions to String for character manipulation.
818 | extension String {
819 |
820 | var length: Int {
821 | return self.count
822 | }
823 |
824 | subscript (i: Int) -> Character {
825 | let start = index(self.startIndex, offsetBy: i)
826 | return self[start]
827 | }
828 |
829 | func substring(from: Int) -> String {
830 | return self[min(from, length) ..< length]
831 | }
832 |
833 | func substring(to: Int) -> String {
834 | return self[0 ..< max(0, to)]
835 | }
836 |
837 | subscript (r: Range) -> String {
838 | let lower = max(0, min(length, r.lowerBound))
839 | let upper = min(length, max(0, r.upperBound))
840 | let range = Range(uncheckedBounds: (lower: lower, upper: upper))
841 | let start = index(startIndex, offsetBy: range.lowerBound)
842 | let end = index(start, offsetBy: range.upperBound - range.lowerBound)
843 | return String(self[start ..< end])
844 | }
845 |
846 | /// Returns index of the first instance of the string, or -1 if not found.
847 | func find(_ needle: String) -> Int {
848 | let range = self.range(of: needle)
849 | if range != nil {
850 | return self.distance(from: self.startIndex, to: range!.lowerBound)
851 | }
852 | return -1
853 | }
854 |
855 | /// Returns index of the last instance of the string, or -1 if not found.
856 | func rfind(_ needle: String) -> Int {
857 | let range = self.range(of: needle, options: String.CompareOptions.backwards)
858 | if range != nil {
859 | return self.distance(from: self.startIndex, to: range!.lowerBound)
860 | }
861 | return -1
862 | }
863 |
864 | func substring(from: Int, to: Int) -> String {
865 | let start = self.index(self.startIndex, offsetBy: from)
866 | let end = self.index(self.startIndex, offsetBy: to)
867 | let range = start.. Bool {
146 | return OpenLocationCode.isValid(code: code)
147 | }
148 |
149 | /// Determines if a code is a valid short code.
150 | /// A short Open Location Code is a sequence created by removing four or more
151 | /// digits from an Open Location Code. It must include a separator
152 | /// character.
153 | ///
154 | /// - Parameter code: The Open Location Code to test.
155 | /// - Returns: true if the code is a short Open Location Code.
156 | @objc(isShortCode:)
157 | public static func isShort(code: String) -> Bool {
158 | return OpenLocationCode.isShort(code: code)
159 |
160 | }
161 |
162 | // Determines if a code is a valid full Open Location Code.
163 | // Not all possible combinations of Open Location Code characters decode to
164 | // valid latitude and longitude values. This checks that a code is valid
165 | // and also that the latitude and longitude values are legal. If the prefix
166 | // character is present, it must be the first character. If the separator
167 | // character is present, it must be after four characters.
168 | ///
169 | /// - Parameter code: The Open Location Code to test.
170 | /// - Returns: true if the code is a full Open Location Code.
171 | @objc(isFullCode:)
172 | public static func isFull(code: String) -> Bool {
173 | return OpenLocationCode.isFull(code: code)
174 |
175 | }
176 | /// Encode a location using the grid refinement method into an OLC string.
177 | /// The grid refinement method divides the area into a grid of 4x5, and uses a
178 | /// single character to refine the area. This allows default accuracy OLC
179 | /// codes to be refined with just a single character.
180 | ///
181 | /// - Parameter latitude: A latitude in signed decimal degrees.
182 | /// - Parameter longitude: A longitude in signed decimal degrees.
183 | /// - Parameter codeLength: The number of characters required.
184 | /// - Returns: Open Location Code representing the given grid.
185 | @objc(encodeGridForLatitude:longitude:codeLength:)
186 | public static func encodeGrid(latitude: Double,
187 | longitude: Double,
188 | codeLength: Int) -> String {
189 | return OpenLocationCode.encodeGrid(latitude:latitude,
190 | longitude:longitude,
191 | codeLength:codeLength)
192 | }
193 |
194 | /// Encode a location into an Open Location Code.
195 | /// Produces a code of the specified length, or the default length if no
196 | /// length is provided.
197 | /// The length determines the accuracy of the code. The default length is
198 | /// 10 characters, returning a code of approximately 13.5x13.5 meters. Longer
199 | /// codes represent smaller areas, but lengths > 14 are sub-centimetre and so
200 | /// 11 or 12 are probably the limit of useful codes.
201 | ///
202 | /// - Parameter latitude: A latitude in signed decimal degrees. Will be
203 | /// clipped to the range -90 to 90.
204 | /// - Parameter longitude: A longitude in signed decimal degrees. Will be
205 | /// normalised to the range -180 to 180.
206 | /// - Parameter codeLength: The number of significant digits in the output
207 | /// code, not including any separator characters. Possible values are;
208 | /// `2`, `4`, `6`, `8`, `10`, `11`, `12`, `13` and above. Lower values
209 | /// indicate a larger area, higher values a more precise area.
210 | /// You can also shorten a code after encoding for codes used with a
211 | /// reference point (e.g. your current location, a city, etc).
212 | ///
213 | /// - Returns: Open Location Code for the given coordinate.
214 | @objc(encodeLatitude:longitude:codeLength:)
215 | public static func encode(latitude: Double,
216 | longitude: Double,
217 | codeLength: Int) -> String? {
218 | return OpenLocationCode.encode(latitude:latitude, longitude:longitude,
219 | codeLength:codeLength)
220 |
221 | }
222 |
223 | /// Encode a location into an Open Location Code.
224 | /// Produces a code of the specified length, or the default length if no
225 | /// length is provided.
226 | /// The length determines the accuracy of the code. The default length is
227 | /// 10 characters, returning a code of approximately 13.5x13.5 meters. Longer
228 | /// codes represent smaller areas, but lengths > 14 are sub-centimetre and so
229 | /// 11 or 12 are probably the limit of useful codes.
230 | ///
231 | /// - Parameter latitude: A latitude in signed decimal degrees. Will be
232 | /// clipped to the range -90 to 90.
233 | /// - Parameter longitude: A longitude in signed decimal degrees. Will be
234 | /// normalised to the range -180 to 180.
235 | ///
236 | /// - Returns: Open Location Code for the given coordinate.
237 | @objc(encodeLatitude:longitude:)
238 | public static func encode(latitude: Double,
239 | longitude: Double) -> String? {
240 | return OpenLocationCode.encode(latitude:latitude, longitude:longitude)
241 |
242 | }
243 |
244 | /// Decodes an Open Location Code into the location coordinates.
245 | /// Returns a OpenLocationCodeArea object that includes the coordinates of the
246 | /// bounding box - the lower left, center and upper right.
247 | ///
248 | /// - Parameter code: The Open Location Code to decode.
249 | /// - Returns: A CodeArea object that provides the latitude and longitude of
250 | /// two of the corners of the area, the center, and the length of the
251 | /// original code.
252 | @objc public static func decode(_ code: String) -> OLCArea? {
253 | guard let area = OpenLocationCode.decode(code) else {
254 | return nil
255 | }
256 | return OLCArea.init(area)
257 | }
258 |
259 | /// Recover the nearest matching code to a specified location.
260 | /// Given a short Open Location Code of between four and seven characters,
261 | /// this recovers the nearest matching full code to the specified location.
262 | /// The number of characters that will be prepended to the short code, depends
263 | /// on the length of the short code and whether it starts with the separator.
264 | /// If it starts with the separator, four characters will be prepended. If it
265 | /// does not, the characters that will be prepended to the short code, where S
266 | /// is the supplied short code and R are the computed characters, are as
267 | /// follows:
268 | /// ```
269 | /// SSSS -> RRRR.RRSSSS
270 | /// SSSSS -> RRRR.RRSSSSS
271 | /// SSSSSS -> RRRR.SSSSSS
272 | /// SSSSSSS -> RRRR.SSSSSSS
273 | /// ```
274 | ///
275 | /// Note that short codes with an odd number of characters will have their
276 | /// last character decoded using the grid refinement algorithm.
277 | ///
278 | /// - Parameter shortcode: A valid short OLC character sequence.
279 | /// - Parameter referenceLatitude: The latitude (in signed decimal degrees) to
280 | /// use to find the nearest matching full code.
281 | /// - Parameter referenceLongitude: The longitude (in signed decimal degrees)
282 | /// to use to find the nearest matching full code.
283 | /// - Returns: The nearest full Open Location Code to the reference location
284 | /// that matches the short code. If the passed code was not a valid short
285 | /// code, but was a valid full code, it is returned unchanged.
286 | @objc public static func recoverNearest(shortcode: String,
287 | referenceLatitude: Double,
288 | referenceLongitude: Double) -> String? {
289 | return OpenLocationCode.recoverNearest(shortcode:shortcode,
290 | referenceLatitude:referenceLatitude,
291 | referenceLongitude:referenceLongitude)
292 | }
293 |
294 | /// Remove characters from the start of an OLC code.
295 | /// This uses a reference location to determine how many initial characters
296 | /// can be removed from the OLC code. The number of characters that can be
297 | /// removed depends on the distance between the code center and the reference
298 | /// location.
299 | /// The minimum number of characters that will be removed is four. If more
300 | /// than four characters can be removed, the additional characters will be
301 | /// replaced with the padding character. At most eight characters will be
302 | /// removed. The reference location must be within 50% of the maximum range.
303 | /// This ensures that the shortened code will be able to be recovered using
304 | /// slightly different locations.
305 | ///
306 | /// - Parameter code: A full, valid code to shorten.
307 | /// - Parameter latitude: A latitude, in signed decimal degrees, to use as the
308 | /// reference point.
309 | /// - Parameter longitude: A longitude, in signed decimal degrees, to use as
310 | /// the reference point.
311 | /// - Parameter maximumTruncation: The maximum number of characters to remove.
312 | /// - Returns: Either the original code, if the reference location was not
313 | /// close enough, or the original.
314 | @objc(shortenCode:latitude:longitude:maximumTruncation:)
315 | public static func shorten(code: String,
316 | latitude: Double,
317 | longitude: Double,
318 | maximumTruncation: Int) -> String? {
319 | return OpenLocationCode.shorten(code:code,
320 | latitude:latitude,
321 | longitude:longitude,
322 | maximumTruncation:maximumTruncation)
323 | }
324 |
325 | /// Remove characters from the start of an OLC code.
326 | /// This uses a reference location to determine how many initial characters
327 | /// can be removed from the OLC code. The number of characters that can be
328 | /// removed depends on the distance between the code center and the reference
329 | /// location.
330 | /// The minimum number of characters that will be removed is four. If more
331 | /// than four characters can be removed, the additional characters will be
332 | /// replaced with the padding character. At most eight characters will be
333 | /// removed. The reference location must be within 50% of the maximum range.
334 | /// This ensures that the shortened code will be able to be recovered using
335 | /// slightly different locations.
336 | ///
337 | /// - Parameter code: A full, valid code to shorten.
338 | /// - Parameter latitude: A latitude, in signed decimal degrees, to use as the
339 | /// reference point.
340 | /// - Parameter longitude: A longitude, in signed decimal degrees, to use as
341 | /// the reference point.
342 | /// - Returns: Either the original code, if the reference location was not
343 | /// close enough, or the original.
344 | @objc(shortenCode:latitude:longitude:)
345 | public static func shorten(code: String,
346 | latitude: Double,
347 | longitude: Double) -> String? {
348 | return OpenLocationCode.shorten(code:code,
349 | latitude:latitude,
350 | longitude:longitude)
351 | }
352 | }
353 |
354 | /// Coordinates of a decoded Open Location Code.
355 | /// The coordinates include the latitude and longitude of the lower left and
356 | /// upper right corners and the center of the bounding box for the area the
357 | /// code represents.
358 | @objc public class OLCArea: NSObject {
359 | /// The latitude of the SW corner in degrees.
360 | @objc public var latitudeLo: Double = 0
361 | /// The longitude of the SW corner in degrees.
362 | @objc public var longitudeLo: Double = 0
363 | /// The latitude of the NE corner in degrees.
364 | @objc public var latitudeHi: Double = 0
365 | /// The longitude of the NE corner in degrees.
366 | @objc public var longitudeHi: Double = 0
367 | /// The number of significant characters that were in the code.
368 | /// This excludes the separator.
369 | @objc public var codeLength: Int = 0
370 | /// The latitude of the center in degrees.
371 | @objc public var latitudeCenter: Double = 0
372 | /// latitude_center: The latitude of the center in degrees.
373 | @objc public var longitudeCenter: Double = 0
374 |
375 | /// - Parameter latitudeLo: The latitude of the SW corner in degrees.
376 | /// - Parameter longitudeLo: The longitude of the SW corner in degrees.
377 | /// - Parameter latitudeHi: The latitude of the NE corner in degrees.
378 | /// - Parameter longitudeHi: The longitude of the NE corner in degrees.
379 | /// - Parameter codeLength: The number of significant characters that were in
380 | /// the code.
381 | @objc init(latitudeLo: Double,
382 | longitudeLo: Double,
383 | latitudeHi: Double,
384 | longitudeHi: Double,
385 | codeLength: Int) {
386 | self.latitudeLo = latitudeLo
387 | self.longitudeLo = longitudeLo
388 | self.latitudeHi = latitudeHi
389 | self.longitudeHi = longitudeHi
390 | self.codeLength = codeLength
391 | self.latitudeCenter = min(latitudeLo + (latitudeHi - latitudeLo) / 2,
392 | kLatitudeMax)
393 | self.longitudeCenter = min(longitudeLo + (longitudeHi - longitudeLo) / 2,
394 | kLongitudeMax)
395 | }
396 | init(_ area: OpenLocationCodeArea) {
397 | self.latitudeLo = area.latitudeLo
398 | self.longitudeLo = area.longitudeLo
399 | self.latitudeHi = area.latitudeHi
400 | self.longitudeHi = area.longitudeHi
401 | self.codeLength = area.codeLength
402 | self.latitudeCenter = area.latitudeCenter
403 | self.longitudeCenter = area.longitudeCenter
404 | }
405 |
406 | // Returns lat/lng coordinate array representing the area's center point.
407 | @objc func latlng() -> Array{
408 | return [self.latitudeCenter, self.longitudeCenter]
409 | }
410 | }
411 |
412 | #endif
413 |
--------------------------------------------------------------------------------
/Tests/Info.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | CFBundleDevelopmentRegion
6 | en
7 | CFBundleExecutable
8 | $(EXECUTABLE_NAME)
9 | CFBundleIdentifier
10 | $(PRODUCT_BUNDLE_IDENTIFIER)
11 | CFBundleInfoDictionaryVersion
12 | 6.0
13 | CFBundleName
14 | $(PRODUCT_NAME)
15 | CFBundlePackageType
16 | BNDL
17 | CFBundleShortVersionString
18 | 1.0
19 | CFBundleVersion
20 | 1
21 |
22 |
23 |
--------------------------------------------------------------------------------
/Tests/LinuxMain.swift:
--------------------------------------------------------------------------------
1 | //===-- OpenLocationCodeTests.swift - Tests for OpenLocationCode.swift ----===//
2 | //
3 | // Copyright 2017 Google Inc.
4 | //
5 | // Licensed under the Apache License, Version 2.0 (the "License");
6 | // you may not use this file except in compliance with the License.
7 | // You may obtain a copy of the License at
8 | //
9 | // http://www.apache.org/licenses/LICENSE-2.0
10 | //
11 | // Unless required by applicable law or agreed to in writing, software
12 | // distributed under the License is distributed on an "AS IS" BASIS,
13 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | // See the License for the specific language governing permissions and
15 | // limitations under the License.
16 | //
17 | //===----------------------------------------------------------------------===//
18 | //
19 | // Declares list of tests for the Linux version of Swift.
20 | //
21 | //===----------------------------------------------------------------------===//
22 |
23 | import XCTest
24 | @testable import OpenLocationCodeTests
25 |
26 | XCTMain([
27 | testCase(ValidityTests.allTests),
28 | testCase(OpenLocationCodeSwiftExampleTests.allTests),
29 | testCase(EncodingTests.allTests),
30 | testCase(DecodingTests.allTests),
31 | testCase(ShortenTests.allTests),
32 | testCase(OpenLocationCodeAdditionalTests.allTests),
33 | ])
34 |
--------------------------------------------------------------------------------
/Tests/OpenLocationCodeObjCTests/OpenLocationCodeObjCExampleTests.m:
--------------------------------------------------------------------------------
1 | //===-- OpenLocationCodeObjCTests.m - Tests for OpenLocationCode.swift ----===//
2 | //
3 | // Copyright 2017 Google Inc.
4 | //
5 | // Licensed under the Apache License, Version 2.0 (the "License");
6 | // you may not use this file except in compliance with the License.
7 | // You may obtain a copy of the License at
8 | //
9 | // http://www.apache.org/licenses/LICENSE-2.0
10 | //
11 | // Unless required by applicable law or agreed to in writing, software
12 | // distributed under the License is distributed on an "AS IS" BASIS,
13 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | // See the License for the specific language governing permissions and
15 | // limitations under the License.
16 | //
17 | //===----------------------------------------------------------------------===//
18 | //
19 | // Objective-C tests. Verifies that the library is accessible from ObjC and
20 | // that the included library samples function correctly.
21 | //
22 | // Authored by William Denniss.
23 | //
24 | //===----------------------------------------------------------------------===//
25 |
26 | #import
27 | @import OpenLocationCode;
28 |
29 | @interface OpenLocationCodeObjCTests : XCTestCase
30 | @end
31 |
32 | @implementation OpenLocationCodeObjCTests
33 |
34 | /* Tests the Objective-C library README examples.
35 | */
36 | - (void)testObjCExamples {
37 | // Encode a location with default code length.
38 | NSString *code = [OLCConverter encodeLatitude:37.421908
39 | longitude:-122.084681];
40 | NSLog(@"Open Location Code: %@", code);
41 |
42 | // Encode a location with specific code length.
43 | NSString *code10Digit = [OLCConverter encodeLatitude:37.421908
44 | longitude:-122.084681
45 | codeLength:10];
46 | NSLog(@"Open Location Code: %@", code10Digit);
47 |
48 | // Decode a full code:
49 | OLCArea *coord = [OLCConverter decode:@"849VCWC8+Q48"];
50 | NSLog(@"Center is %.6f, %.6f", coord.latitudeCenter, coord.longitudeCenter);
51 |
52 | // Attempt to trim the first characters from a code:
53 | NSString *shortCode = [OLCConverter shortenCode:@"849VCWC8+Q48"
54 | latitude:37.4
55 | longitude:-122.0];
56 | NSLog(@"Short Code: %@", shortCode);
57 |
58 | // Recover the full code from a short code:
59 | NSString *recoveredCode = [OLCConverter recoverNearestWithShortcode:@"CWC8+Q48"
60 | referenceLatitude:37.4
61 | referenceLongitude:-122.1];
62 | NSLog(@"Recovered Full Code: %@", recoveredCode);
63 |
64 | XCTAssertNotNil(code);
65 | XCTAssertNotNil(code10Digit);
66 | XCTAssertNotNil(coord);
67 | XCTAssertNotNil(shortCode);
68 | XCTAssertNotNil(recoveredCode);
69 | }
70 |
71 | @end
72 |
--------------------------------------------------------------------------------
/Tests/OpenLocationCodeTests/OpenLocationCodeAdditionalTests.swift:
--------------------------------------------------------------------------------
1 | //===-- OpenLocationCodeTests.swift - Tests for OpenLocationCode.swift ----===//
2 | //
3 | // Copyright 2017 Google Inc.
4 | //
5 | // Licensed under the Apache License, Version 2.0 (the "License");
6 | // you may not use this file except in compliance with the License.
7 | // You may obtain a copy of the License at
8 | //
9 | // http://www.apache.org/licenses/LICENSE-2.0
10 | //
11 | // Unless required by applicable law or agreed to in writing, software
12 | // distributed under the License is distributed on an "AS IS" BASIS,
13 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | // See the License for the specific language governing permissions and
15 | // limitations under the License.
16 | //
17 | //===----------------------------------------------------------------------===//
18 | //
19 | // Tests various API claims and functionality not covered by the core tests.
20 | //
21 | // Authored by William Denniss.
22 | //
23 | //===----------------------------------------------------------------------===//
24 |
25 | import XCTest
26 | import Foundation
27 | @testable import OpenLocationCode
28 |
29 | /// Tests various API claims and functionality not covered by the core tests.
30 | class OpenLocationCodeAdditionalTests: XCTestCase {
31 |
32 | /// Tests that the documented possible code lengths behave as expected.
33 | func testEncodeLengthValidity() {
34 | // Even lengths between 2 and 10 inclusive are valid.
35 | for length in [2, 4, 6, 8, 10] {
36 | let code = OpenLocationCode.encode(latitude: 47.365590,
37 | longitude: 8.524997,
38 | codeLength: length)
39 | XCTAssertNotNil(code, "\(length)")
40 | }
41 | // All lengths above 10 are valid.
42 | for length in 11..<100 {
43 | let code = OpenLocationCode.encode(latitude: 47.365590,
44 | longitude: 8.524997,
45 | codeLength: length)
46 | XCTAssertNotNil(code, "\(length)")
47 | }
48 | // All lengths before 2, and odd numbers before 10 are invalid.
49 | for length in [-100, -3, -2, -1, 0, 1, 3, 5, 7, 9] {
50 | let code = OpenLocationCode.encode(latitude: 47.365590,
51 | longitude: 8.524997,
52 | codeLength: length)
53 | XCTAssertNil(code, "\(length)")
54 | }
55 | }
56 |
57 | /// Tests that the documented possible code lengths behave as expected.
58 | func testShortenLimit() {
59 | let shortcode = OpenLocationCode.shorten(code: "9C3W9QCJ+2VX",
60 | latitude: 51.3708675,
61 | longitude: -1.217765625,
62 | maximumTruncation: 6)
63 | XCTAssertEqual(shortcode, "CJ+2VX")
64 | let shortcode2 = OpenLocationCode.shorten(code: "9C3W9QCJ+2VX",
65 | latitude: 51.3708675,
66 | longitude: -1.217765625,
67 | maximumTruncation: 2)
68 | XCTAssertEqual(shortcode2, "3W9QCJ+2VX")
69 | let citycode = OpenLocationCode.shorten(code: "9C3W9QCJ+2VX",
70 | latitude: 51.3708675,
71 | longitude: -1.217765625)
72 | XCTAssertEqual(citycode, "9QCJ+2VX")
73 | }
74 |
75 | /// Tests the encoding behavior of codes exceeding the maximum
76 | /// number of digits. Codes are limited to 15 significant digits.
77 | func testMaxLength_Encoding() {
78 | for length in [15, 16, 17, 100000] {
79 | let code = OpenLocationCode.encode(latitude: 37.539669125,
80 | longitude: -122.375069125,
81 | codeLength: length)!
82 | XCTAssertEqual(code, "849VGJQF+VX7QR4M")
83 | }
84 | }
85 |
86 | /// Tests the decoding behavior of codes exceeding the maximum
87 | /// number of digits. Significant digits after 15 are ignored.
88 | func testMaxLength_Decoding() {
89 | // Codes of 15 digits (not including plus) and higher should be equal
90 | let maxCharCode = "849VGJQF+VX7QR4M"
91 | let coord1 = OpenLocationCode.decode(maxCharCode)!
92 | let coord2 = OpenLocationCode.decode(maxCharCode + "7QR4M")!
93 | XCTAssertEqual(coord1.latitudeCenter, coord2.latitudeCenter)
94 | XCTAssertEqual(coord1.longitudeCenter, coord2.longitudeCenter)
95 | }
96 |
97 | /// Tests the validity checking behavior of codes exceeding the maximum
98 | /// number of digits. Codes exceeding the maximum length but with only
99 | /// valid characters are still valid, those with invalid characters after
100 | /// the maximum length are invalid.
101 | func testMaxLength_Validity() {
102 | let maxCharCode = "849VGJQF+VX7QR4M" // a 15 digit code
103 | // Codes with valid characters after the max are still valid
104 | let maxCharCodeExceededValid = maxCharCode + "W"
105 | XCTAssertTrue(OpenLocationCode.isValid(code: maxCharCodeExceededValid));
106 | // Codes with invalid characters after the max are invalid
107 | let maxCharCodeExceededInvalid = maxCharCode + "U"
108 | XCTAssertFalse(OpenLocationCode.isValid(code: maxCharCodeExceededInvalid));
109 | }
110 |
111 | static var allTests = [
112 | ("testEncodeLengthValidity", testEncodeLengthValidity),
113 | ("testMaxLength_Encoding", testMaxLength_Encoding),
114 | ("testMaxLength_Decoding", testMaxLength_Decoding),
115 | ("testMaxLength_Validity", testMaxLength_Validity),
116 | ]
117 | }
118 |
--------------------------------------------------------------------------------
/Tests/OpenLocationCodeTests/OpenLocationCodeCoreTests.swift:
--------------------------------------------------------------------------------
1 | //===-- OpenLocationCodeTests.swift - Tests for OpenLocationCode.swift ----===//
2 | //
3 | // Copyright 2017 Google Inc.
4 | //
5 | // Licensed under the Apache License, Version 2.0 (the "License");
6 | // you may not use this file except in compliance with the License.
7 | // You may obtain a copy of the License at
8 | //
9 | // http://www.apache.org/licenses/LICENSE-2.0
10 | //
11 | // Unless required by applicable law or agreed to in writing, software
12 | // distributed under the License is distributed on an "AS IS" BASIS,
13 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | // See the License for the specific language governing permissions and
15 | // limitations under the License.
16 | //
17 | //===----------------------------------------------------------------------===//
18 | //
19 | // Unit tests for core functionality using the official CSV test data.
20 | //
21 | // Authored by William Denniss. Ported from openlocationcode_test.py.
22 | //
23 | //===----------------------------------------------------------------------===//
24 |
25 | import XCTest
26 | import Foundation
27 | @testable import OpenLocationCode
28 |
29 | /// OLC Test helpers.
30 | class OLCTestHelper {
31 | /// Loads CSV data from the test bundle and parses into an Array of
32 | /// Dictionaries using the given keys.
33 | ///
34 | /// - Parameter filename: the filename of the CSV file with no path or
35 | /// extension component
36 | /// - Parameter keys: the keys used to build the dictionary.
37 | /// - Returns: An array of each line of data represented as a dictionary
38 | /// with the given keys.
39 | static func loadData(filename: String,
40 | keys: Array)
41 | -> Array>? {
42 | var testData:Array> = []
43 | var csvData: String?
44 |
45 | // Tries to load CSV data from bundle.
46 | #if !os(Linux)
47 | let testBundle = Bundle(for: OLCTestHelper.self)
48 | if let path = testBundle.path(forResource: filename, ofType: "csv") {
49 | csvData = try? String(contentsOfFile: path)
50 | }
51 | #endif
52 | // Falls back to loading directly from the file.
53 | if csvData == nil {
54 | csvData = try? String(contentsOfFile: "test_data/\(filename).csv",
55 | encoding: .utf8)
56 | }
57 | // Parses data.
58 | guard let csv = csvData else {
59 | print("Unable to read \(filename).csv")
60 | XCTAssert(false)
61 | return nil
62 | }
63 | // Iterates each line.
64 | for(line) in csv.components(separatedBy: CharacterSet.newlines) {
65 | if line.hasPrefix("#") || line.count == 0 {
66 | continue
67 | }
68 | // Parses as a comma separated array.
69 | let lineData =
70 | line.components(separatedBy: CharacterSet.init(charactersIn: ","))
71 | // Converts to dict.
72 | var lineDict:Dictionary = [:]
73 | for i in 0 ..< keys.count {
74 | lineDict[keys[i]] = lineData[i]
75 | }
76 | testData += [lineDict]
77 | }
78 | return testData
79 | }
80 | }
81 |
82 | /// Tests the validity methods.
83 | class ValidityTests: XCTestCase {
84 | var testData:Array> = []
85 |
86 | override func setUp() {
87 | super.setUp()
88 | let keys = ["code","isValid","isShort","isFull"]
89 | testData = OLCTestHelper.loadData(filename: "validityTests", keys: keys)!
90 | XCTAssertNotNil(testData)
91 | XCTAssert(testData.count > 0)
92 | }
93 |
94 | /// Tests OpenLocationCode.isValid
95 | func testValidCodes() {
96 | for(td) in testData {
97 | XCTAssertEqual(OpenLocationCode.isValid(code: td["code"]!),
98 | Bool(td["isValid"]!)!)
99 | }
100 | }
101 |
102 | /// Tests OpenLocationCode.isFull
103 | func testFullCodes() {
104 | for(td) in testData {
105 | XCTAssertEqual(OpenLocationCode.isFull(code: td["code"]!),
106 | Bool(td["isFull"]!)!)
107 | }
108 | }
109 |
110 | /// Tests OpenLocationCode.isShort
111 | func testShortCodes() {
112 | for(td) in testData {
113 | XCTAssertEqual(OpenLocationCode.isShort(code: td["code"]!),
114 | Bool(td["isShort"]!)!)
115 | }
116 | }
117 |
118 | static var allTests = [
119 | ("testValidCodes", testValidCodes),
120 | ("testFullCodes", testFullCodes),
121 | ("testShortCodes", testShortCodes),
122 | ]
123 | }
124 |
125 | /// Tests the code shortening methods.
126 | class ShortenTests: XCTestCase {
127 | var testData:Array> = []
128 |
129 | override func setUp() {
130 | super.setUp()
131 | let keys = ["code","lat","lng","shortcode", "testtype"]
132 | testData = OLCTestHelper.loadData(filename: "shortCodeTests", keys: keys)!
133 | XCTAssertNotNil(testData)
134 | XCTAssert(testData.count > 0)
135 | }
136 |
137 | /// Tests OpenLocationCode.shorten
138 | func testFullToShort() {
139 | for(td) in testData {
140 | if td["testtype"] == "B" || td["testtype"] == "S" {
141 | let shortened = OpenLocationCode.shorten(code: td["code"]!,
142 | latitude: Double(td["lat"]!)!,
143 | longitude: Double(td["lng"]!)!,
144 | maximumTruncation: 8)!
145 | XCTAssertEqual(shortened, td["shortcode"]!)
146 | }
147 | if td["testtype"] == "B" || td["testtype"] == "R" {
148 | let recovered =
149 | OpenLocationCode.recoverNearest(shortcode: td["shortcode"]!,
150 | referenceLatitude: Double(td["lat"]!)!,
151 | referenceLongitude: Double(td["lng"]!)!)
152 | XCTAssertEqual(recovered, td["code"]!)
153 | }
154 | }
155 | }
156 |
157 | static var allTests = [
158 | ("testFullToShort", testFullToShort),
159 | ]
160 | }
161 |
162 | /// Tests encoding.
163 | class EncodingTests: XCTestCase {
164 | var testData:Array> = []
165 |
166 | override func setUp() {
167 | super.setUp()
168 | let keys = ["lat","lng","length","code"]
169 | testData = OLCTestHelper.loadData(filename: "encoding", keys: keys)!
170 | XCTAssertNotNil(testData)
171 | XCTAssert(testData.count > 0)
172 | }
173 |
174 | /// Tests OpenLocationCode.encode
175 | func testEncoding() {
176 | for(td) in testData {
177 | let encoded = OpenLocationCode.encode(latitude: Double(td["lat"]!)!,
178 | longitude: Double(td["lng"]!)!,
179 | codeLength: Int(td["length"]!)!)
180 | let code = td["code"]!
181 | XCTAssertEqual(encoded, code)
182 | }
183 | }
184 |
185 | static var allTests = [
186 | ("testEncoding", testEncoding),
187 | ]
188 | }
189 |
190 | /// Tests decoding.
191 | class DecodingTests: XCTestCase {
192 | var testData:Array> = []
193 |
194 | override func setUp() {
195 | super.setUp()
196 | let keys = ["code","length","latLo","lngLo","latHi","lngHi"]
197 | testData = OLCTestHelper.loadData(filename: "decoding", keys: keys)!
198 | XCTAssertNotNil(testData)
199 | XCTAssert(testData.count > 0)
200 | }
201 |
202 | /// Tests OpenLocationCode.decode
203 | func testDecoding() {
204 | let precision = pow(10.0,10.0)
205 |
206 | for(td) in testData {
207 | let decoded: OpenLocationCodeArea =
208 | OpenLocationCode.decode(td["code"]!)!
209 | XCTAssertEqual((decoded.latitudeLo * precision).rounded(),
210 | (Double(td["latLo"]!)! * precision).rounded(),
211 | "Failure with " + td["code"]!)
212 | XCTAssertEqual((decoded.longitudeLo * precision).rounded(),
213 | (Double(td["lngLo"]!)! * precision).rounded(),
214 | "Failure with " + td["code"]!)
215 | XCTAssertEqual((decoded.latitudeHi * precision).rounded(),
216 | (Double(td["latHi"]!)! * precision).rounded(),
217 | "Failure with " + td["code"]!)
218 | XCTAssertEqual((decoded.longitudeHi * precision).rounded(),
219 | (Double(td["lngHi"]!)! * precision).rounded(),
220 | "Failure with " + td["code"]!)
221 | }
222 | }
223 |
224 | static var allTests = [
225 | ("testDecoding", testDecoding),
226 | ]
227 | }
--------------------------------------------------------------------------------
/Tests/OpenLocationCodeTests/OpenLocationCodeSwiftExampleTests.swift:
--------------------------------------------------------------------------------
1 | //===-- OpenLocationCodeTests.swift - Tests for OpenLocationCode.swift ----===//
2 | //
3 | // Copyright 2017 Google Inc.
4 | //
5 | // Licensed under the Apache License, Version 2.0 (the "License");
6 | // you may not use this file except in compliance with the License.
7 | // You may obtain a copy of the License at
8 | //
9 | // http://www.apache.org/licenses/LICENSE-2.0
10 | //
11 | // Unless required by applicable law or agreed to in writing, software
12 | // distributed under the License is distributed on an "AS IS" BASIS,
13 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | // See the License for the specific language governing permissions and
15 | // limitations under the License.
16 | //
17 | //===----------------------------------------------------------------------===//
18 | //
19 | // Tests that verify the included Swift library samples function correctly.
20 | //
21 | // Authored by William Denniss.
22 | //
23 | //===----------------------------------------------------------------------===//
24 |
25 | import XCTest
26 | import Foundation
27 | @testable import OpenLocationCode
28 |
29 | class OpenLocationCodeSwiftExampleTests: XCTestCase {
30 |
31 | // Just runs the examples verbatium.
32 | func runExamples() {
33 |
34 | // Encode a location with default code length.
35 | if let code = OpenLocationCode.encode(latitude: 37.421908,
36 | longitude: -122.084681) {
37 | print("Open Location Code: \(code)")
38 | }
39 |
40 | // Encode a location with specific code length.
41 | if let code10Digit = OpenLocationCode.encode(latitude: 37.421908,
42 | longitude: -122.084681,
43 | codeLength: 10) {
44 | print("Open Location Code: \(code10Digit)")
45 | }
46 |
47 | // Decode a full code:
48 | if let coord = OpenLocationCode.decode("849VCWC8+Q48") {
49 | print("Center is \(coord.latitudeCenter), \(coord.longitudeCenter)")
50 | }
51 |
52 | // Attempt to trim the first characters from a code:
53 | if let shortCode = OpenLocationCode.shorten(code: "849VCWC8+Q48",
54 | latitude: 37.4,
55 | longitude: -122.0) {
56 | print("Short code: \(shortCode)")
57 | }
58 |
59 | // Recover the full code from a short code:
60 | if let fullCode = OpenLocationCode.recoverNearest(shortcode: "CWC8+Q48",
61 | referenceLatitude: 37.4,
62 | referenceLongitude: -122.0) {
63 | print("Recovered full code: \(fullCode)")
64 | }
65 | }
66 |
67 | /// Tests the Swift library README examples.
68 | func testExamples() {
69 | // Encode a location with default code length.
70 | let code = OpenLocationCode.encode(latitude: 37.421908,
71 | longitude: -122.084681)
72 | if let code = code {
73 | print("Open Location Code: \(code)")
74 | }
75 |
76 | // Encode a location with specific code length.
77 | let code10Digit = OpenLocationCode.encode(latitude: 37.421908,
78 | longitude: -122.084681,
79 | codeLength: 10)
80 | if let code10Digit = code10Digit {
81 | print("Open Location Code: \(code10Digit)")
82 | }
83 |
84 | // Decode a full code:
85 | let coord = OpenLocationCode.decode("849VCWC8+Q48")
86 | if let coord = coord {
87 | print("Center is \(coord.latitudeCenter), \(coord.longitudeCenter)")
88 | }
89 |
90 | // Attempt to trim the first characters from a code:
91 | let shortCode = OpenLocationCode.shorten(code: "849VCWC8+Q48",
92 | latitude: 37.4,
93 | longitude: -122.0)
94 | if let shortCode = shortCode {
95 | print("Short code: \(shortCode)")
96 | }
97 |
98 | // Recover the full code from a short code:
99 | let fullCode = OpenLocationCode.recoverNearest(shortcode: "CWC8+Q48",
100 | referenceLatitude: 37.4,
101 | referenceLongitude: -122.0)
102 | if let fullCode = fullCode {
103 | print("Recovered full code: \(fullCode)")
104 | }
105 |
106 | XCTAssertNotNil(code)
107 | XCTAssertNotNil(code10Digit)
108 | XCTAssertNotNil(coord)
109 | XCTAssertNotNil(shortCode)
110 | XCTAssertNotNil(fullCode)
111 | }
112 |
113 | static var allTests = [
114 | ("testExamples", testExamples),
115 | ]
116 | }
117 |
--------------------------------------------------------------------------------
/test_data/decoding.csv:
--------------------------------------------------------------------------------
1 | # Test decoding Open Location Codes.
2 | #
3 | # Provides test cases for decoding valid codes.
4 | #
5 | # Format:
6 | # code,length,latLo,lngLo,latHi,lngHi
7 | 7FG49Q00+,6,20.35,2.75,20.4,2.8
8 | 7FG49QCJ+2V,10,20.37,2.782125,20.370125,2.78225
9 | 7FG49QCJ+2VX,11,20.3701,2.78221875,20.370125,2.78225
10 | 7FG49QCJ+2VXGJ,13,20.370113,2.782234375,20.370114,2.78223632813
11 | 8FVC2222+22,10,47.0,8.0,47.000125,8.000125
12 | 4VCPPQGP+Q9,10,-41.273125,174.785875,-41.273,174.786
13 | 62G20000+,4,0.0,-180.0,1,-179
14 | 22220000+,4,-90,-180,-89,-179
15 | 7FG40000+,4,20.0,2.0,21.0,3.0
16 | 22222222+22,10,-90.0,-180.0,-89.999875,-179.999875
17 | 6VGX0000+,4,0,179,1,180
18 | 6FH32222+222,11,1,1,1.000025,1.00003125
19 | # Special cases over 90 latitude and 180 longitude
20 | CFX30000+,4,89,1,90,2
21 | CFX30000+,4,89,1,90,2
22 | 62H20000+,4,1,-180,2,-179
23 | 62H30000+,4,1,-179,2,-178
24 | CFX3X2X2+X2,10,89.9998750,1,90,1.0001250
25 | # Test non-precise latitude/longitude value
26 | 6FH56C22+22,10,1.2000000000000028,3.4000000000000057,1.2001249999999999,3.4001250000000027
27 |
--------------------------------------------------------------------------------
/test_data/encoding.csv:
--------------------------------------------------------------------------------
1 | # Test encoding Open Location Codes.
2 | #
3 | # Provides test cases for encoding latitude and longitude to codes.
4 | #
5 | # Format:
6 | # latitude,longitude,length,expected code (empty if the input should cause an error)
7 | 20.375,2.775,6,7FG49Q00+
8 | 20.3700625,2.7821875,10,7FG49QCJ+2V
9 | 20.3701125,2.782234375,11,7FG49QCJ+2VX
10 | 20.3701135,2.78223535156,13,7FG49QCJ+2VXGJ
11 | 47.0000625,8.0000625,10,8FVC2222+22
12 | -41.2730625,174.7859375,10,4VCPPQGP+Q9
13 | 0.5,-179.5,4,62G20000+
14 | -89.5,-179.5,4,22220000+
15 | 20.5,2.5,4,7FG40000+
16 | -89.9999375,-179.9999375,10,22222222+22
17 | 0.5,179.5,4,6VGX0000+
18 | 1,1,11,6FH32222+222
19 | # Special cases over 90 latitude and 180 longitude
20 | 90,1,4,CFX30000+
21 | 92,1,4,CFX30000+
22 | 1,180,4,62H20000+
23 | 1,181,4,62H30000+
24 | 90,1,10,CFX3X2X2+X2
25 | # Test non-precise latitude/longitude value
26 | 1.2,3.4,10,6FH56C22+22
27 |
--------------------------------------------------------------------------------
/test_data/shortCodeTests.csv:
--------------------------------------------------------------------------------
1 | # Test shortening and extending codes.
2 | #
3 | # Format:
4 | # full code,lat,lng,shortcode,test_type
5 | # test_type is R for recovery only, S for shorten only, or B for both.
6 | 9C3W9QCJ+2VX,51.3701125,-1.217765625,+2VX,B
7 | # Adjust so we can't trim by 8 (+/- .000755)
8 | 9C3W9QCJ+2VX,51.3708675,-1.217765625,CJ+2VX,B
9 | 9C3W9QCJ+2VX,51.3693575,-1.217765625,CJ+2VX,B
10 | 9C3W9QCJ+2VX,51.3701125,-1.218520625,CJ+2VX,B
11 | 9C3W9QCJ+2VX,51.3701125,-1.217010625,CJ+2VX,B
12 | # Adjust so we can't trim by 6 (+/- .0151)
13 | 9C3W9QCJ+2VX,51.3852125,-1.217765625,9QCJ+2VX,B
14 | 9C3W9QCJ+2VX,51.3550125,-1.217765625,9QCJ+2VX,B
15 | 9C3W9QCJ+2VX,51.3701125,-1.232865625,9QCJ+2VX,B
16 | 9C3W9QCJ+2VX,51.3701125,-1.202665625,9QCJ+2VX,B
17 | # Added to detect error in recoverNearest functionality
18 | 8FJFW222+,42.899,9.012,22+,B
19 | 796RXG22+,14.95125,-23.5001,22+,B
20 | # Reference location is in the 4 digit cell to the south.
21 | 8FVC2GGG+GG,46.976,8.526,2GGG+GG,B
22 | # Reference location is in the 4 digit cell to the north.
23 | 8FRCXGGG+GG,47.026,8.526,XGGG+GG,B
24 | # Reference location is in the 4 digit cell to the east.
25 | 8FR9GXGG+GG,46.526,8.026,GXGG+GG,B
26 | # Reference location is in the 4 digit cell to the west.
27 | 8FRCG2GG+GG,46.526,7.976,G2GG+GG,B
28 | # Added to detect errors recovering codes near the poles.
29 | # This tests recovery function, but these codes won't shorten.
30 | CFX22222+22,89.6,0.0,2222+22,R
31 | 2CXXXXXX+XX,-81.0,0.0,XXXXXX+XX,R
32 | # Recovered full codes should be the full code
33 | 8FRCG2GG+GG,46.526,7.976,8FRCG2GG+GG,R
34 | # Recovered full codes should be the uppercased full code
35 | 8FRCG2GG+GG,46.526,7.976,8frCG2GG+gG,R
36 |
--------------------------------------------------------------------------------
/test_data/syncData.sh:
--------------------------------------------------------------------------------
1 | # delete all CSV data, replace with that from the upstream project
2 | rm *.csv
3 | git clone https://github.com/google/open-location-code.git tmp-open-location-code
4 | cp tmp-open-location-code/test_data/*.csv .
5 | rm -rf tmp-open-location-code
--------------------------------------------------------------------------------
/test_data/validityTests.csv:
--------------------------------------------------------------------------------
1 | # Test data for validity tests.
2 | # Format of each line is:
3 | # code,isValid,isShort,isFull
4 | # Valid full codes:
5 | 8FWC2345+G6,true,false,true
6 | 8FWC2345+G6G,true,false,true
7 | 8fwc2345+,true,false,true
8 | 8FWCX400+,true,false,true
9 | # Valid short codes:
10 | WC2345+G6g,true,true,false
11 | 2345+G6,true,true,false
12 | 45+G6,true,true,false
13 | +G6,true,true,false
14 | # Invalid codes
15 | G+,false,false,false
16 | +,false,false,false
17 | 8FWC2345+G,false,false,false
18 | 8FWC2_45+G6,false,false,false
19 | 8FWC2η45+G6,false,false,false
20 | 8FWC2345+G6+,false,false,false
21 | 8FWC2345G6+,false,false,false
22 | 8FWC2300+G6,false,false,false
23 | WC2300+G6g,false,false,false
24 | WC2345+G,false,false,false
25 | WC2300+,false,false,false
26 |
--------------------------------------------------------------------------------