├── .gitignore ├── CHANGELOG.md ├── FUNDING.yml ├── LICENSE ├── README.md ├── app ├── .gitignore ├── build.gradle ├── proguard-rules.pro └── src │ └── main │ ├── AndroidManifest.xml │ ├── assets │ └── test.gpx │ ├── java │ └── io │ │ └── ticofab │ │ └── androidgpxparser │ │ └── GPXParserSampleActivity.java │ └── res │ ├── layout │ └── activity_main.xml │ ├── mipmap-hdpi │ └── ic_launcher.png │ ├── mipmap-mdpi │ └── ic_launcher.png │ ├── mipmap-xhdpi │ └── ic_launcher.png │ ├── mipmap-xxhdpi │ └── ic_launcher.png │ ├── values-w820dp │ └── dimens.xml │ └── values │ ├── dimens.xml │ ├── strings.xml │ └── styles.xml ├── build.gradle ├── downloads-until-may-2021.png ├── gradle.properties ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat ├── jitpack.yml ├── parser ├── .gitignore ├── build.gradle ├── proguard-rules.pro └── src │ ├── androidTest │ ├── assets │ │ ├── garminBaseCampExport-noclosingtag.gpx │ │ ├── garminBaseCampExport-truncated.gpx │ │ ├── garminBaseCampExport.gpx │ │ ├── metadata-full.gpx │ │ ├── metadata-minimal.gpx │ │ ├── shores-of-derwentwater.xml │ │ └── wadlbeisserExport.gpx │ └── java │ │ └── io │ │ └── ticofab │ │ └── androidgpxparser │ │ └── parser │ │ └── GPXParserTest.java │ └── main │ ├── AndroidManifest.xml │ └── java │ └── io │ └── ticofab │ └── androidgpxparser │ └── parser │ ├── GPXParser.java │ └── domain │ ├── Author.java │ ├── Bounds.java │ ├── Copyright.java │ ├── Email.java │ ├── Extensions.java │ ├── Gpx.java │ ├── Link.java │ ├── Metadata.java │ ├── Point.java │ ├── Route.java │ ├── RoutePoint.java │ ├── Track.java │ ├── TrackPoint.java │ ├── TrackSegment.java │ └── WayPoint.java └── settings.gradle /.gitignore: -------------------------------------------------------------------------------- 1 | # built application files 2 | build 3 | *.apk 4 | *.iml 5 | 6 | # files for the dex VM 7 | *.dex 8 | 9 | # Java class files 10 | *.class 11 | 12 | # generated files 13 | bin/ 14 | gen/ 15 | 16 | # Local configuration file (sdk path, etc) 17 | local.properties 18 | 19 | # Eclipse project files 20 | .classpath 21 | .project 22 | 23 | # Proguard folder generated by Eclipse 24 | proguard/ 25 | 26 | # Intellij project files 27 | *.iws 28 | .idea/* 29 | 30 | # Gradle directory 31 | .gradle 32 | 33 | # OS 34 | .DS_Store 35 | .idea/dictionaries 36 | -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Change Log 2 | 3 | ## 2.3.1 *(Feb 15th 2023)* 4 | 5 | * Enhances README - thanks [neevasethi](https://github.com/neevasethi)! 6 | * Updates to Gradle 8.0 and Android Gradle Plugin 7.4.1 7 | * Updates system dependencies (appcompat, annotations, testing dependencies). 8 | * Updated the Joda date library to the latest version (2.12.1.1). 9 | 10 | 11 | ## 2.3.0 *(Sep 2nd 2022)* 12 | 13 | * Adds `sym` and `cmt` parsing for waypoints. Solves [#48](https://github.com/ticofab/android-gpx-parser/issues/48) - thanks [gabrielezereik](https://github.com/gabrielezereik)! 14 | * Updates to the 7.2.2 version of the gradle plugin. 15 | * Updates system dependencies (appcompat). 16 | * Updated the Joda date library to the latest version (2.11.0.1). 17 | 18 | ## 2.2.0 *(Nov 25th 2021)* 19 | 20 | * Adds parsing of the `speed` extension. Solves [#40](https://github.com/ticofab/android-gpx-parser/issues/40). 21 | * Updates to the 7.0.3 version of the gradle plugin. 22 | * Updates system dependencies (appcompat, annotations). 23 | * Updated the Joda date library to the latest version (2.10.12.2). 24 | 25 | ## 2.0.1 *(Jul 10th 2021)* 26 | 27 | * Make the Joda library available to users without adding it explicitly (which fixes [#37](https://github.com/ticofab/android-gpx-parser/issues/37)) - thanks [Markus Deutsch](https://github.com/moopat)! 28 | * Remove the useless resource folder from the example app - thanks [Tom Sullivan](https://github.com/msbit)! 29 | * Updates the gradle plugin to 4.2.2 30 | 31 | ## 2.0.0 *(Apr 26th 2021)* 32 | 33 | Breaking change! Triggered by Bintray sunsetting JCenter, I seized the opportunity to 34 | * Remove the async version of the parser, which was using deprecated calls. 35 | * Bump up the minimum API level from 14 to 16. 36 | * Upgrade the Gradle plugin and all its machinery to the latest version. 37 | * Switch to the androidx libraries. 38 | * Move on from the deprecated InstrumentationRegistry. 39 | * Removed the useless test section of the example app. 40 | * Upgrade the Joda date library to the latest version. 41 | 42 | ## 1.6.0 *(Sep 16th 2019)* 43 | 44 | * Skipping the `extensions` tag from Metadata parsing - such tag is meant to include extra custom fields not mentioned in the GPX specs. Fixes [23](https://github.com/ticofab/android-gpx-parser/issues/23). 45 | * Added a first project using this library in production. Looking forward to add more! 46 | 47 | ## 1.5.0 *(Apr 18th 2019)* 48 | 49 | * Parsing full Metadata information - thanks [Taneli Korry](https://github.com/tkorri)! 50 | 51 | ## 1.4.0 *(Jan 1st 2019)* 52 | 53 | * Parsing Waypoint Type - thanks [Pygmalion69](https://github.com/Pygmalion69)! 54 | 55 | ## 1.3.0 *(Dec 8th 2018)* 56 | 57 | * Parsing GPX Metadata - thanks [StuStirling](https://github.com/StuStirling)! 58 | 59 | ## 1.2.0 *(July 2nd 2018)* 60 | 61 | * Parsing WayPoint description. 62 | 63 | ## 1.1.2 *(June 26th 2018)* 64 | 65 | * Fix to prevent endless loop in case of malformed GPX track (thanks to D. Elliot!) 66 | 67 | ## 1.1.1 *(March 15th 2018)* 68 | 69 | * Minor bug fixes, updated dependencies. 70 | 71 | ## 1.1.0 *(October 4th 2017)* 72 | 73 | * Added track and route attributes (which fixes [#14](https://github.com/ticofab/android-gpx-parser/issues/14)) - thanks [StuStirling](https://github.com/StuStirling)! 74 | 75 | ## 1.0.0 *(2017-04-11)* 76 | 77 | * Added track name to the parseable fields. 78 | 79 | ## 0.2.0 *(2017-02-03)* 80 | 81 | * Added support for routes and waypoints - thanks [mopfattn](https://github.com/mopfattn)! 82 | * Bumped plugins & dependencies 83 | 84 | ## 0.1.6 *(2016-19-12)* 85 | 86 | * Fixed [#2](https://github.com/ticofab/android-gpx-parser/issues/2) and [#3](https://github.com/ticofab/android-gpx-parser/issues/3) - thanks [StuStirling](https://github.com/StuStirling)! 87 | * Bumped plugins & dependencies 88 | 89 | ## 0.1.5 *(2016-06-05)* 90 | 91 | * Bumped plugins 92 | * Fix for uninitialized Joda Time 93 | 94 | ## 0.1.4 *(2016-24-01)* 95 | 96 | * Bumped plugins 97 | 98 | ## 0.1.3 *(2015-09-12)* 99 | 100 | * Removed Google Play Services dependency 101 | * Isolated taks and interface (breaking change) 102 | 103 | ## 0.1.1 *(2015-09-12)* 104 | 105 | * Initial release 106 | -------------------------------------------------------------------------------- /FUNDING.yml: -------------------------------------------------------------------------------- 1 | github: [ticofab] 2 | custom: ["https://www.paypal.me/ticofab", ticofab.io] 3 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | 178 | APPENDIX: How to apply the Apache License to your work. 179 | 180 | To apply the Apache License to your work, attach the following 181 | boilerplate notice, with the fields enclosed by brackets "{}" 182 | replaced with your own identifying information. (Don't include 183 | the brackets!) The text should be enclosed in the appropriate 184 | comment syntax for the file format. We also recommend that a 185 | file or class name and description of purpose be included on the 186 | same "printed page" as the copyright notice for easier 187 | identification within third-party archives. 188 | 189 | Copyright 2015 Fabio Tiriticco 190 | 191 | Licensed under the Apache License, Version 2.0 (the "License"); 192 | you may not use this file except in compliance with the License. 193 | You may obtain a copy of the License at 194 | 195 | http://www.apache.org/licenses/LICENSE-2.0 196 | 197 | Unless required by applicable law or agreed to in writing, software 198 | distributed under the License is distributed on an "AS IS" BASIS, 199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 200 | See the License for the specific language governing permissions and 201 | limitations under the License. -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | [![Android Arsenal](https://img.shields.io/badge/Android%20Arsenal-android--gpx--parser-green.svg?style=flat)](https://android-arsenal.com/details/1/2500) 2 | [![](https://jitpack.io/v/ticofab/android-gpx-parser.svg)](https://jitpack.io/#ticofab/android-gpx-parser) 3 | 4 | # Android GPX Parser 5 | 6 | # NOTICE: I am no longer maintaning this project. 7 | Almost ten years have passed since I started this, and I have no more time to stay up-to-date. 8 | I am looking for volounteers to take over this project. 9 | 10 | ## Table of Contents: 11 | 1. [Description](#description) 12 | 2. [Module Structures](#module-structure) 13 | 3. [Projects using this library](#projects-using-this-library) 14 | 4. [Download](#download) 15 | 5. [Dependencies](#dependencies) 16 | 6. [Usage](#usage) 17 | 7. [License](#license) 18 | 19 | ## Description 20 | A library to parse GPX files, built for Android. The reference schema is the [Topografix GPX 1.1](http://www.topografix.com/GPX/1/1/). 21 | In addition, it parses the `speed` extension, when provided as a `double` number. 22 | 23 | GPX is an XML file format to represent GPS data: coordinates, routes, waypoints, and more. 24 | 25 | Pull requests are welcome! Please check the [issues](https://github.com/ticofab/android-gpx-parser/issues) and open a pull request when done: you will have made the world a better place. 26 | 27 | ## Module Structure 28 | 29 | 1. App: an example usage of the library. 30 | 2. Parser: the library itself. 31 | 32 | ## Projects using this library: 33 | 34 | * [TomTom AmiGO](https://play.google.com/store/apps/details?id=com.tomtom.speedcams.android.map) 35 | * [WRPElevationChart](https://play.google.com/store/apps/details?id=de.wrpsoft.wrpelevationchartmaker&hl=de&gl=US) 36 | * [Maplocs Cycling Route Planner](https://play.google.com/store/apps/details?id=abhiank.maplocs) 37 | * [Boatspeed Sailing and Tracking](https://play.google.com/store/apps/details?id=de.herberlin.boatspeed&hl=de) 38 | * [Routes - GPX/KML Navigation & GPS Tracker](https://play.google.com/store/apps/details?id=de.flosdorf.routenavigation&hl=de) 39 | * [GPS Video Logger](https://play.google.com/store/apps/details?id=app.gps_video_logger) 40 | 41 | _To have your project listed here, please send me an email or open a PR._ 42 | 43 | ## Download 44 | 45 | Add the Jitpack repository to your root build file. The way you do this depends on the Gradle plugin you are using. 46 | 47 | If using Gradle plugin 7.0.0. or newer (default for new apps since Android Studio Artic Fox) 48 | ``` 49 | // in settings.gradle 50 | dependencyResolutionManagement { 51 | ... 52 | repositories { 53 | ... 54 | maven { url 'https://jitpack.io' } 55 | } 56 | } 57 | ``` 58 | 59 | For older verions of Gradle: 60 | ``` 61 | // in project-level build.gradle 62 | allprojects { 63 | repositories { 64 | maven { url 'https://jitpack.io' } 65 | } 66 | } 67 | ``` 68 | 69 | Finally, in your dependencies list 70 | 71 | ``` 72 | dependencies { 73 | implementation 'com.github.ticofab:android-gpx-parser:2.3.1' 74 | } 75 | ``` 76 | 77 | ## Dependencies 78 | 79 | The following is an open github repo that has date and time handling. Keep in mind that the following dependency also has dependencies of its own. 80 | 81 | * [Joda DateTime for Android](https://github.com/dlew/joda-time-android) 82 | 83 | ## Usage 84 | 85 | In Java: 86 | 87 | ```java 88 | GPXParser parser = new GPXParser(); // consider injection 89 | Gpx parsedGpx = null; 90 | try { 91 | InputStream in = getAssets().open("test.gpx"); 92 | parsedGpx = parser.parse(in); // consider using a background thread 93 | } catch (IOException | XmlPullParserException e) { 94 | // do something with this exception 95 | e.printStackTrace(); 96 | } 97 | if (parsedGpx == null) { 98 | // error parsing track 99 | } else { 100 | // do something with the parsed track 101 | // see included example app and tests 102 | } 103 | ``` 104 | 105 | In Kotlin: 106 | 107 | ```kotlin 108 | val parser = GPXParser() // consider injection 109 | try { 110 | val input: InputStream = getAssets().open("test.gpx") 111 | val parsedGpx: Gpx? = parser.parse(input) // consider using a background thread 112 | parsedGpx?.let { 113 | // do something with the parsed track 114 | // see included example app and tests 115 | } ?: { 116 | // error parsing track 117 | } 118 | } catch (e: IOException) { 119 | // do something with this exception 120 | e.printStackTrace() 121 | } catch (e: XmlPullParserException) { 122 | // do something with this exception 123 | e.printStackTrace() 124 | } 125 | ``` 126 | 127 | ## License 128 | 129 | Copyright 2015 - 2023 Fabio Tiriticco - Fabway 130 | 131 | Licensed under the Apache License, Version 2.0 (the "License"); 132 | you may not use this file except in compliance with the License. 133 | You may obtain a copy of the License at 134 | 135 | http://www.apache.org/licenses/LICENSE-2.0 136 | 137 | Unless required by applicable law or agreed to in writing, software 138 | distributed under the License is distributed on an "AS IS" BASIS, 139 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 140 | See the License for the specific language governing permissions and 141 | limitations under the License. 142 | -------------------------------------------------------------------------------- /app/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /app/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.application' 2 | 3 | android { 4 | compileSdk 33 5 | buildToolsVersion '33.0.0' 6 | 7 | defaultConfig { 8 | applicationId "io.ticofab.androidgpxparser" 9 | minSdkVersion 16 10 | targetSdkVersion 33 11 | versionCode 4 12 | versionName "2.3.1" 13 | } 14 | buildTypes { 15 | release { 16 | minifyEnabled false 17 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 18 | } 19 | } 20 | compileOptions { 21 | sourceCompatibility JavaVersion.VERSION_11 22 | targetCompatibility JavaVersion.VERSION_11 23 | } 24 | } 25 | 26 | dependencies { 27 | implementation fileTree(dir: 'libs', include: ['*.jar']) 28 | implementation 'androidx.appcompat:appcompat:1.6.1' 29 | 30 | // line used for local development 31 | implementation project(':parser') 32 | 33 | // this should be used in your app 34 | // implementation 'com.github.ticofab:android-gpx-parser:2.0.1' 35 | } 36 | -------------------------------------------------------------------------------- /app/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # By default, the flags in this file are appended to flags specified 3 | # in /Users/fabiotiriticco/Library/Android/sdk/tools/proguard/proguard-android.txt 4 | # You can edit the include path and order by changing the proguardFiles 5 | # directive in build.gradle. 6 | # 7 | # For more details, see 8 | # http://developer.android.com/guide/developing/tools/proguard.html 9 | 10 | # Add any project specific keep options here: 11 | 12 | # If your project uses WebView with JS, uncomment the following 13 | # and specify the fully qualified class name to the JavaScript interface 14 | # class: 15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 16 | # public *; 17 | #} 18 | -------------------------------------------------------------------------------- /app/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 10 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /app/src/main/java/io/ticofab/androidgpxparser/GPXParserSampleActivity.java: -------------------------------------------------------------------------------- 1 | package io.ticofab.androidgpxparser; 2 | 3 | import android.os.Bundle; 4 | import android.util.Log; 5 | 6 | import androidx.appcompat.app.AppCompatActivity; 7 | 8 | import org.xmlpull.v1.XmlPullParserException; 9 | 10 | import java.io.IOException; 11 | import java.io.InputStream; 12 | import java.util.List; 13 | 14 | import io.ticofab.androidgpxparser.parser.GPXParser; 15 | import io.ticofab.androidgpxparser.parser.domain.Extensions; 16 | import io.ticofab.androidgpxparser.parser.domain.Gpx; 17 | import io.ticofab.androidgpxparser.parser.domain.Track; 18 | import io.ticofab.androidgpxparser.parser.domain.TrackPoint; 19 | import io.ticofab.androidgpxparser.parser.domain.TrackSegment; 20 | import io.ticofab.androidgpxparser.parser.domain.WayPoint; 21 | 22 | public class GPXParserSampleActivity extends AppCompatActivity { 23 | 24 | static final String TAG = GPXParserSampleActivity.class.getSimpleName(); 25 | 26 | GPXParser mParser = new GPXParser(); // consider injection 27 | 28 | @Override 29 | protected void onCreate(Bundle savedInstanceState) { 30 | super.onCreate(savedInstanceState); 31 | setContentView(R.layout.activity_main); 32 | 33 | Gpx parsedGpx = null; 34 | try { 35 | InputStream in = getAssets().open("test.gpx"); 36 | parsedGpx = mParser.parse(in); // consider doing this on a background thread 37 | } catch (IOException | XmlPullParserException e) { 38 | e.printStackTrace(); 39 | } 40 | 41 | if (parsedGpx != null) { 42 | // log stuff 43 | List tracks = parsedGpx.getTracks(); 44 | for (int i = 0; i < tracks.size(); i++) { 45 | Track track = tracks.get(i); 46 | Log.d(TAG, "track " + i + ":"); 47 | List segments = track.getTrackSegments(); 48 | for (int j = 0; j < segments.size(); j++) { 49 | TrackSegment segment = segments.get(j); 50 | Log.d(TAG, " segment " + j + ":"); 51 | for (TrackPoint trackPoint : segment.getTrackPoints()) { 52 | String msg = " point: lat " + trackPoint.getLatitude() + ", lon " + trackPoint.getLongitude() + ", time " + trackPoint.getTime(); 53 | Extensions ext = trackPoint.getExtensions(); 54 | Double speed; 55 | if (ext != null) { 56 | speed = ext.getSpeed(); 57 | msg = msg.concat(", speed " + speed); 58 | } 59 | Log.d(TAG, msg); 60 | } 61 | } 62 | } 63 | } else { 64 | Log.e(TAG, "Error parsing gpx track!"); 65 | } 66 | } 67 | } 68 | -------------------------------------------------------------------------------- /app/src/main/res/layout/activity_main.xml: -------------------------------------------------------------------------------- 1 | 11 | 12 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /app/src/main/res/mipmap-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ticofab/android-gpx-parser/5a74a61a5bf4b885f8450f2697a502c7127342b7/app/src/main/res/mipmap-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ticofab/android-gpx-parser/5a74a61a5bf4b885f8450f2697a502c7127342b7/app/src/main/res/mipmap-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ticofab/android-gpx-parser/5a74a61a5bf4b885f8450f2697a502c7127342b7/app/src/main/res/mipmap-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ticofab/android-gpx-parser/5a74a61a5bf4b885f8450f2697a502c7127342b7/app/src/main/res/mipmap-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/values-w820dp/dimens.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 64dp 6 | 7 | -------------------------------------------------------------------------------- /app/src/main/res/values/dimens.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 16dp 4 | 16dp 5 | 6 | -------------------------------------------------------------------------------- /app/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | AndroidGpxParser 3 | 4 | Hello Android GPX Parser Sample App!\nCheck the logcat with tag GPXParserSampleActivity. 5 | 6 | -------------------------------------------------------------------------------- /app/src/main/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /build.gradle: -------------------------------------------------------------------------------- 1 | // Top-level build file where you can add configuration options common to all sub-projects/modules. 2 | 3 | buildscript { 4 | repositories { 5 | mavenCentral() 6 | maven { 7 | url 'https://maven.google.com/' 8 | name 'Google' 9 | } 10 | maven { url 'https://jitpack.io' } 11 | google() 12 | } 13 | dependencies { 14 | classpath 'com.android.tools.build:gradle:7.4.1' 15 | } 16 | } 17 | 18 | allprojects { 19 | repositories { 20 | mavenCentral() 21 | maven { 22 | url 'https://maven.google.com/' 23 | name 'Google' 24 | } 25 | maven { url 'https://jitpack.io' } 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /downloads-until-may-2021.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ticofab/android-gpx-parser/5a74a61a5bf4b885f8450f2697a502c7127342b7/downloads-until-may-2021.png -------------------------------------------------------------------------------- /gradle.properties: -------------------------------------------------------------------------------- 1 | # Project-wide Gradle settings. 2 | 3 | # IDE (e.g. Android Studio) users: 4 | # Gradle settings configured through the IDE *will override* 5 | # any settings specified in this file. 6 | 7 | # For more details on how to configure your build environment visit 8 | # http://www.gradle.org/docs/current/userguide/build_environment.html 9 | 10 | # Specifies the JVM arguments used for the daemon process. 11 | # The setting is particularly useful for tweaking memory settings. 12 | # Default value: -Xmx10248m -XX:MaxPermSize=256m 13 | # org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8 14 | 15 | # When configured, Gradle will run in incubating parallel mode. 16 | # This option should only be used with decoupled projects. More details, visit 17 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects 18 | # org.gradle.parallel=true 19 | android.enableJetifier=true 20 | android.useAndroidX=true -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ticofab/android-gpx-parser/5a74a61a5bf4b885f8450f2697a502c7127342b7/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | #Wed Feb 15 12:55:52 CET 2023 2 | distributionUrl=https\://services.gradle.org/distributions/gradle-8.0-bin.zip 3 | -------------------------------------------------------------------------------- /gradlew: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | ############################################################################## 4 | ## 5 | ## Gradle start up script for UN*X 6 | ## 7 | ############################################################################## 8 | 9 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 10 | DEFAULT_JVM_OPTS="" 11 | 12 | APP_NAME="Gradle" 13 | APP_BASE_NAME=`basename "$0"` 14 | 15 | # Use the maximum available, or set MAX_FD != -1 to use that value. 16 | MAX_FD="maximum" 17 | 18 | warn ( ) { 19 | echo "$*" 20 | } 21 | 22 | die ( ) { 23 | echo 24 | echo "$*" 25 | echo 26 | exit 1 27 | } 28 | 29 | # OS specific support (must be 'true' or 'false'). 30 | cygwin=false 31 | msys=false 32 | darwin=false 33 | case "`uname`" in 34 | CYGWIN* ) 35 | cygwin=true 36 | ;; 37 | Darwin* ) 38 | darwin=true 39 | ;; 40 | MINGW* ) 41 | msys=true 42 | ;; 43 | esac 44 | 45 | # Attempt to set APP_HOME 46 | # Resolve links: $0 may be a link 47 | PRG="$0" 48 | # Need this for relative symlinks. 49 | while [ -h "$PRG" ] ; do 50 | ls=`ls -ld "$PRG"` 51 | link=`expr "$ls" : '.*-> \(.*\)$'` 52 | if expr "$link" : '/.*' > /dev/null; then 53 | PRG="$link" 54 | else 55 | PRG=`dirname "$PRG"`"/$link" 56 | fi 57 | done 58 | SAVED="`pwd`" 59 | cd "`dirname \"$PRG\"`/" >/dev/null 60 | APP_HOME="`pwd -P`" 61 | cd "$SAVED" >/dev/null 62 | 63 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar 64 | 65 | # Determine the Java command to use to start the JVM. 66 | if [ -n "$JAVA_HOME" ] ; then 67 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then 68 | # IBM's JDK on AIX uses strange locations for the executables 69 | JAVACMD="$JAVA_HOME/jre/sh/java" 70 | else 71 | JAVACMD="$JAVA_HOME/bin/java" 72 | fi 73 | if [ ! -x "$JAVACMD" ] ; then 74 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME 75 | 76 | Please set the JAVA_HOME variable in your environment to match the 77 | location of your Java installation." 78 | fi 79 | else 80 | JAVACMD="java" 81 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 82 | 83 | Please set the JAVA_HOME variable in your environment to match the 84 | location of your Java installation." 85 | fi 86 | 87 | # Increase the maximum file descriptors if we can. 88 | if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then 89 | MAX_FD_LIMIT=`ulimit -H -n` 90 | if [ $? -eq 0 ] ; then 91 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then 92 | MAX_FD="$MAX_FD_LIMIT" 93 | fi 94 | ulimit -n $MAX_FD 95 | if [ $? -ne 0 ] ; then 96 | warn "Could not set maximum file descriptor limit: $MAX_FD" 97 | fi 98 | else 99 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" 100 | fi 101 | fi 102 | 103 | # For Darwin, add options to specify how the application appears in the dock 104 | if $darwin; then 105 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" 106 | fi 107 | 108 | # For Cygwin, switch paths to Windows format before running java 109 | if $cygwin ; then 110 | APP_HOME=`cygpath --path --mixed "$APP_HOME"` 111 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` 112 | JAVACMD=`cygpath --unix "$JAVACMD"` 113 | 114 | # We build the pattern for arguments to be converted via cygpath 115 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` 116 | SEP="" 117 | for dir in $ROOTDIRSRAW ; do 118 | ROOTDIRS="$ROOTDIRS$SEP$dir" 119 | SEP="|" 120 | done 121 | OURCYGPATTERN="(^($ROOTDIRS))" 122 | # Add a user-defined pattern to the cygpath arguments 123 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then 124 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" 125 | fi 126 | # Now convert the arguments - kludge to limit ourselves to /bin/sh 127 | i=0 128 | for arg in "$@" ; do 129 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` 130 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option 131 | 132 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition 133 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` 134 | else 135 | eval `echo args$i`="\"$arg\"" 136 | fi 137 | i=$((i+1)) 138 | done 139 | case $i in 140 | (0) set -- ;; 141 | (1) set -- "$args0" ;; 142 | (2) set -- "$args0" "$args1" ;; 143 | (3) set -- "$args0" "$args1" "$args2" ;; 144 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;; 145 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; 146 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; 147 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; 148 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; 149 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; 150 | esac 151 | fi 152 | 153 | # Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules 154 | function splitJvmOpts() { 155 | JVM_OPTS=("$@") 156 | } 157 | eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS 158 | JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME" 159 | 160 | exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@" 161 | -------------------------------------------------------------------------------- /gradlew.bat: -------------------------------------------------------------------------------- 1 | @if "%DEBUG%" == "" @echo off 2 | @rem ########################################################################## 3 | @rem 4 | @rem Gradle startup script for Windows 5 | @rem 6 | @rem ########################################################################## 7 | 8 | @rem Set local scope for the variables with windows NT shell 9 | if "%OS%"=="Windows_NT" setlocal 10 | 11 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 12 | set DEFAULT_JVM_OPTS= 13 | 14 | set DIRNAME=%~dp0 15 | if "%DIRNAME%" == "" set DIRNAME=. 16 | set APP_BASE_NAME=%~n0 17 | set APP_HOME=%DIRNAME% 18 | 19 | @rem Find java.exe 20 | if defined JAVA_HOME goto findJavaFromJavaHome 21 | 22 | set JAVA_EXE=java.exe 23 | %JAVA_EXE% -version >NUL 2>&1 24 | if "%ERRORLEVEL%" == "0" goto init 25 | 26 | echo. 27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 28 | echo. 29 | echo Please set the JAVA_HOME variable in your environment to match the 30 | echo location of your Java installation. 31 | 32 | goto fail 33 | 34 | :findJavaFromJavaHome 35 | set JAVA_HOME=%JAVA_HOME:"=% 36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe 37 | 38 | if exist "%JAVA_EXE%" goto init 39 | 40 | echo. 41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 42 | echo. 43 | echo Please set the JAVA_HOME variable in your environment to match the 44 | echo location of your Java installation. 45 | 46 | goto fail 47 | 48 | :init 49 | @rem Get command-line arguments, handling Windowz variants 50 | 51 | if not "%OS%" == "Windows_NT" goto win9xME_args 52 | if "%@eval[2+2]" == "4" goto 4NT_args 53 | 54 | :win9xME_args 55 | @rem Slurp the command line arguments. 56 | set CMD_LINE_ARGS= 57 | set _SKIP=2 58 | 59 | :win9xME_args_slurp 60 | if "x%~1" == "x" goto execute 61 | 62 | set CMD_LINE_ARGS=%* 63 | goto execute 64 | 65 | :4NT_args 66 | @rem Get arguments from the 4NT Shell from JP Software 67 | set CMD_LINE_ARGS=%$ 68 | 69 | :execute 70 | @rem Setup the command line 71 | 72 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar 73 | 74 | @rem Execute Gradle 75 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% 76 | 77 | :end 78 | @rem End local scope for the variables with windows NT shell 79 | if "%ERRORLEVEL%"=="0" goto mainEnd 80 | 81 | :fail 82 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of 83 | rem the _cmd.exe /c_ return code! 84 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 85 | exit /b 1 86 | 87 | :mainEnd 88 | if "%OS%"=="Windows_NT" endlocal 89 | 90 | :omega 91 | -------------------------------------------------------------------------------- /jitpack.yml: -------------------------------------------------------------------------------- 1 | jdk: 2 | - openjdk11 3 | -------------------------------------------------------------------------------- /parser/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /parser/build.gradle: -------------------------------------------------------------------------------- 1 | plugins { 2 | id 'com.android.library' 3 | id 'maven-publish' 4 | } 5 | 6 | android { 7 | compileSdk 33 8 | buildToolsVersion '33.0.0' 9 | 10 | useLibrary 'android.test.runner' 11 | useLibrary 'android.test.base' 12 | useLibrary 'android.test.mock' 13 | 14 | defaultConfig { 15 | minSdkVersion 16 16 | targetSdkVersion 33 17 | testInstrumentationRunner 'androidx.test.runner.AndroidJUnitRunner' 18 | } 19 | buildTypes { 20 | release { 21 | minifyEnabled false 22 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 23 | } 24 | } 25 | compileOptions { 26 | sourceCompatibility JavaVersion.VERSION_11 27 | targetCompatibility JavaVersion.VERSION_11 28 | } 29 | } 30 | 31 | dependencies { 32 | // JodaTime for Android 33 | // https://github.com/dlew/joda-time-android 34 | api 'net.danlew:android.joda:2.12.1.1' 35 | 36 | implementation "androidx.annotation:annotation:1.5.0" 37 | 38 | androidTestImplementation 'junit:junit:4.13.2' 39 | androidTestImplementation 'androidx.test.ext:junit:1.1.5' 40 | androidTestImplementation 'androidx.test:rules:1.5.0' 41 | } 42 | 43 | 44 | afterEvaluate { 45 | publishing { 46 | publications { 47 | // Creates a Maven publication called "release". 48 | release(MavenPublication) { 49 | // Applies the component for the release build variant. 50 | from components.release 51 | 52 | // You can then customize attributes of the publication as shown below. 53 | groupId = 'com.github.ticofab' 54 | artifactId = 'android-gpx-parser' 55 | version = '2.3.1' 56 | } 57 | } 58 | } 59 | } -------------------------------------------------------------------------------- /parser/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # By default, the flags in this file are appended to flags specified 3 | # in /Users/fabiotiriticco/Library/Android/sdk/tools/proguard/proguard-android.txt 4 | # You can edit the include path and order by changing the proguardFiles 5 | # directive in build.gradle. 6 | # 7 | # For more details, see 8 | # http://developer.android.com/guide/developing/tools/proguard.html 9 | 10 | # Add any project specific keep options here: 11 | 12 | # If your project uses WebView with JS, uncomment the following 13 | # and specify the fully qualified class name to the JavaScript interface 14 | # class: 15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 16 | # public *; 17 | #} 18 | -------------------------------------------------------------------------------- /parser/src/androidTest/assets/garminBaseCampExport-noclosingtag.gpx: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | Garmin International 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | A923 15 | A92 16 | A92 17 | Flag, Blue 18 | user 19 | 20 | 21 | SymbolAndName 22 | 23 | 24 | SymbolAndName 25 | 26 | 27 | 2017-02-24T17:29:36Z 28 | 29 | 30 | 31 | 32 | 33 | 34 | A99 und 13 35 | A99 und 13 36 | A99 und 13 37 | Flag, Blue 38 | user 39 | 40 | 41 | SymbolAndName 42 | 43 | 44 | SymbolAndName 45 | 46 | 47 | 2017-02-24T17:29:49Z 48 | 49 | 50 | 51 | 52 | 53 | 54 | Erding Ab 55 | Erding Ab 56 | Erding Ab 57 | Airport 58 | user 59 | 60 | 61 | SymbolAndName 62 | 63 | 64 | SymbolAndName 65 | 66 | 67 | 2017-02-24T17:29:42Z 68 | 69 | 70 | 71 | 72 | 73 | A92 und A9 bis A99 und 388 und Straße 74 | 75 | 76 | true 77 | Magenta 78 | 79 | 80 | Bicycling 81 | 82 | 83 | 84 | 85 | A92 und A9 86 | A92 und A9 87 | A92 und A9 88 | Waypoint 89 | 90 | 91 | FasterTime 92 | Standard 93 | 94 | 95 | 00004ACE7C002D00D4220F220820005B0044 96 | 97 | 98 | 99 | 100 | 101 | A92 102 | A92 103 | A92 104 | Waypoint 105 | 106 | 107 | 108 | 01004ACE7C002D00D4220D2208006B5E8353 109 | 110 | 111 | 112 | 113 | 114 | A921 115 | A92 116 | A92 117 | Waypoint 118 | 119 | 120 | 121 | 01004ACE7C002D00D4220D2208001E6EBD65 122 | 123 | 124 | 125 | 126 | 127 | A922 128 | A92 129 | A92 130 | Waypoint 131 | 132 | 133 | 134 | 01004ACE7C002D00D4220D2208002B764B80 135 | 136 | 137 | 138 | 139 | 140 | 15 und Straße 141 | 15 und Straße 142 | 15 und Straße 143 | Waypoint 144 | 145 | 146 | 147 | 00004ACE7C001D00D4220F220820008280A3 148 | 149 | 150 | 151 | 152 | 153 | 15 und 388 154 | 15 und 388 155 | 15 und 388 156 | Waypoint 157 | 158 | 159 | 160 | 00004ACE7C001E00D4220F220820806000A1 161 | 162 | 163 | 164 | 165 | 166 | A99 und 388 und Straße 167 | A99 und 388 und Straße 168 | A99 und 388 und Straße 169 | Waypoint 170 | 171 | 172 | FasterTime 173 | Standard 174 | 175 | 176 | 00004ACE7C002E00D4220F2208200047004A 177 | 178 | 179 | 180 | 181 | 182 | 183 | My Track 184 | 185 | 186 | DarkGray 187 | 188 | 189 | 190 | 191 | 192 | 193 | 194 | 195 | 196 | 197 | 198 | 199 | 200 | 201 | 202 | 203 | 204 | -------------------------------------------------------------------------------- /parser/src/androidTest/assets/garminBaseCampExport-truncated.gpx: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | Garmin International 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | A923 15 | A92 16 | A92 17 | Flag, Blue 18 | user 19 | 20 | 21 | SymbolAndName 22 | 23 | 24 | SymbolAndName 25 | 26 | 27 | 2017-02-24T17:29:36Z 28 | 29 | 30 | 31 | 32 | 33 | 34 | A99 und 13 35 | A99 und 13 36 | A99 und 13 37 | Flag, Blue 38 | user 39 | 40 | 41 | SymbolAndName 42 | 43 | 44 | SymbolAndName 45 | 46 | 47 | 2017-02-24T17:29:49Z 48 | 49 | 50 | 51 | 52 | 53 | 54 | Erding Ab 55 | Erding Ab 56 | Erding Ab 57 | Airport 58 | -------------------------------------------------------------------------------- /parser/src/androidTest/assets/garminBaseCampExport.gpx: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | Garmin International 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | A923 15 | A92 16 | A92 17 | Flag, Blue 18 | user 19 | 20 | 21 | SymbolAndName 22 | 23 | 24 | SymbolAndName 25 | 26 | 27 | 2017-02-24T17:29:36Z 28 | 29 | 30 | 31 | 32 | 33 | 34 | A99 und 13 35 | A99 und 13 36 | A99 und 13 37 | Flag, Blue 38 | user 39 | 40 | 41 | SymbolAndName 42 | 43 | 44 | SymbolAndName 45 | 46 | 47 | 2017-02-24T17:29:49Z 48 | 49 | 50 | 51 | 52 | 53 | 54 | Erding Ab 55 | Erding Ab 56 | Erding Ab 57 | Airport 58 | user 59 | 60 | 61 | SymbolAndName 62 | 63 | 64 | SymbolAndName 65 | 66 | 67 | 2017-02-24T17:29:42Z 68 | 69 | 70 | 71 | 72 | 73 | A92 und A9 bis A99 und 388 und Straße 74 | 75 | 76 | true 77 | Magenta 78 | 79 | 80 | Bicycling 81 | 82 | 83 | 84 | 85 | A92 und A9 86 | A92 und A9 87 | A92 und A9 88 | Waypoint 89 | 90 | 91 | FasterTime 92 | Standard 93 | 94 | 95 | 00004ACE7C002D00D4220F220820005B0044 96 | 97 | 98 | 99 | 100 | 101 | A92 102 | A92 103 | A92 104 | Waypoint 105 | 106 | 107 | 108 | 01004ACE7C002D00D4220D2208006B5E8353 109 | 110 | 111 | 112 | 113 | 114 | A921 115 | A92 116 | A92 117 | Waypoint 118 | 119 | 120 | 121 | 01004ACE7C002D00D4220D2208001E6EBD65 122 | 123 | 124 | 125 | 126 | 127 | A922 128 | A92 129 | A92 130 | Waypoint 131 | 132 | 133 | 134 | 01004ACE7C002D00D4220D2208002B764B80 135 | 136 | 137 | 138 | 139 | 140 | 15 und Straße 141 | 15 und Straße 142 | 15 und Straße 143 | Waypoint 144 | 145 | 146 | 147 | 00004ACE7C001D00D4220F220820008280A3 148 | 149 | 150 | 151 | 152 | 153 | 15 und 388 154 | 15 und 388 155 | 15 und 388 156 | Waypoint 157 | 158 | 159 | 160 | 00004ACE7C001E00D4220F220820806000A1 161 | 162 | 163 | 164 | 165 | 166 | A99 und 388 und Straße 167 | A99 und 388 und Straße 168 | A99 und 388 und Straße 169 | Waypoint 170 | 171 | 172 | FasterTime 173 | Standard 174 | 175 | 176 | 00004ACE7C002E00D4220F2208200047004A 177 | 178 | 179 | 180 | 181 | 182 | 183 | My Track 184 | 185 | 186 | DarkGray 187 | 188 | 189 | 190 | 191 | 192 | 193 | 194 | 195 | 196 | 197 | 198 | 199 | 200 | 201 | 202 | 203 | 204 | 205 | 206 | -------------------------------------------------------------------------------- /parser/src/androidTest/assets/metadata-full.gpx: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | metadata-full 6 | Full metadata test 7 | 8 | John Doe 9 | 10 | 11 | Example Org. 12 | text/html 13 | 14 | 15 | 16 | 2019 17 | https://www.apache.org/licenses/LICENSE-2.0.txt 18 | 19 | 20 | 21 | metadata, test 22 | 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /parser/src/androidTest/assets/metadata-minimal.gpx: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /parser/src/androidTest/assets/shores-of-derwentwater.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Walk_2321 5 | 6 | 7 | 8 | 1.0 9 | 10 | 0 11 | 12 | 13 | 14 | -1 15 | 1 16 | 0 17 | 18 | 19 | 20 | 5535.9444663809 21 | 22 | 23 | 24 | 80.5 25 | 26 | 27 | 79 28 | 29 | 30 | 81.6 31 | 32 | 33 | 74.8 34 | 35 | 36 | 74.9 37 | 38 | 39 | 77.8 40 | 41 | 42 | 74.7 43 | 44 | 45 | 77 46 | 47 | 48 | 77.8 49 | 50 | 51 | 79.7 52 | 53 | 54 | 79.3 55 | 56 | 57 | 76.8 58 | 59 | 60 | 77.7 61 | 62 | 63 | 78.8 64 | 65 | 66 | 77.9 67 | 68 | 69 | 78.7 70 | 71 | 72 | 78.7 73 | 74 | 75 | 80.3 76 | 77 | 78 | 81.2 79 | 80 | 81 | 82.1 82 | 83 | 84 | 80.2 85 | 86 | 87 | 80.8 88 | 89 | 90 | 74.3 91 | 92 | 93 | 74.3 94 | 95 | 96 | 74.3 97 | 98 | 99 | 77.9 100 | 101 | 102 | 77.3 103 | 104 | 105 | 77 106 | 107 | 108 | 76.9 109 | 110 | 111 | 78.5 112 | 113 | 114 | 77.5 115 | 116 | 117 | 74.3 118 | 119 | 120 | 74.3 121 | 122 | 123 | 74.3 124 | 125 | 126 | 79.8 127 | 128 | 129 | 77.8 130 | 131 | 132 | 74.4 133 | 134 | 135 | 77.2 136 | 137 | 138 | 74.3 139 | 140 | 141 | 74.3 142 | 143 | 144 | 80.6 145 | 146 | 147 | 74.3 148 | 149 | 150 | 74.3 151 | 152 | 153 | 74.3 154 | 155 | 156 | 74.3 157 | 158 | 159 | 74.3 160 | 161 | 162 | 74.3 163 | 164 | 165 | 74.3 166 | 167 | 168 | 75.3 169 | 170 | 171 | 74.3 172 | 173 | 174 | 80.1 175 | 176 | 177 | 95 178 | 179 | 180 | 75.4 181 | 182 | 183 | 77.7 184 | 185 | 186 | 76.6 187 | 188 | 189 | 76.3 190 | 191 | 192 | 76.8 193 | 194 | 195 | 77.1 196 | 197 | 198 | 80.7 199 | 200 | 201 | 83.2 202 | 203 | 204 | 83.3 205 | 206 | 207 | 85.1 208 | 209 | 210 | 79.1 211 | 212 | 213 | 78.1 214 | 215 | 216 | 76.7 217 | 218 | 219 | 75.7 220 | 221 | 222 | 74.3 223 | 224 | 225 | Walk_2321 226 | 227 | 80.5 228 | 229 | 230 | 79 231 | 232 | 233 | 81.6 234 | 235 | 236 | 74.8 237 | 238 | 239 | 74.9 240 | 241 | 242 | 77.8 243 | 244 | 245 | 74.7 246 | 247 | 248 | 77 249 | 250 | 251 | 77.8 252 | 253 | 254 | 79.7 255 | 256 | 257 | 79.3 258 | 259 | 260 | 76.8 261 | 262 | 263 | 77.7 264 | 265 | 266 | 78.8 267 | 268 | 269 | 77.9 270 | 271 | 272 | 78.7 273 | 274 | 275 | 78.7 276 | 277 | 278 | 80.3 279 | 280 | 281 | 81.2 282 | 283 | 284 | 82.1 285 | 286 | 287 | 80.2 288 | 289 | 290 | 80.8 291 | 292 | 293 | 74.3 294 | 295 | 296 | 74.3 297 | 298 | 299 | 74.3 300 | 301 | 302 | 77.9 303 | 304 | 305 | 77.3 306 | 307 | 308 | 77 309 | 310 | 311 | 76.9 312 | 313 | 314 | 78.5 315 | 316 | 317 | 77.5 318 | 319 | 320 | 74.3 321 | 322 | 323 | 74.3 324 | 325 | 326 | 74.3 327 | 328 | 329 | 79.8 330 | 331 | 332 | 77.8 333 | 334 | 335 | 74.4 336 | 337 | 338 | 77.2 339 | 340 | 341 | 74.3 342 | 343 | 344 | 74.3 345 | 346 | 347 | 80.6 348 | 349 | 350 | 74.3 351 | 352 | 353 | 74.3 354 | 355 | 356 | 74.3 357 | 358 | 359 | 74.3 360 | 361 | 362 | 74.3 363 | 364 | 365 | 74.3 366 | 367 | 368 | 74.3 369 | 370 | 371 | 75.3 372 | 373 | 374 | 74.3 375 | 376 | 377 | 80.1 378 | 379 | 380 | 95 381 | 382 | 383 | 75.4 384 | 385 | 386 | 77.7 387 | 388 | 389 | 76.6 390 | 391 | 392 | 76.3 393 | 394 | 395 | 76.8 396 | 397 | 398 | 77.1 399 | 400 | 401 | 80.7 402 | 403 | 404 | 83.2 405 | 406 | 407 | 83.3 408 | 409 | 410 | 85.1 411 | 412 | 413 | 79.1 414 | 415 | 416 | 78.1 417 | 418 | 419 | 76.7 420 | 421 | 422 | 75.7 423 | 424 | 425 | 74.3 426 | 427 | 428 | 429 | 430 | 431 | 33691e 432 | 1 433 | 8 434 | 435 | 436 | 437 | 438 | 80.5 439 | 440 | 441 | 79 442 | 443 | 444 | 81.6 445 | 446 | 447 | 74.8 448 | 449 | 450 | 74.9 451 | 452 | 453 | 77.8 454 | 455 | 456 | 74.7 457 | 458 | 459 | 77 460 | 461 | 462 | 77.8 463 | 464 | 465 | 79.7 466 | 467 | 468 | 79.3 469 | 470 | 471 | 76.8 472 | 473 | 474 | 77.7 475 | 476 | 477 | 78.8 478 | 479 | 480 | 77.9 481 | 482 | 483 | 78.7 484 | 485 | 486 | 78.7 487 | 488 | 489 | 80.3 490 | 491 | 492 | 81.2 493 | 494 | 495 | 82.1 496 | 497 | 498 | 80.2 499 | 500 | 501 | 80.8 502 | 503 | 504 | 74.3 505 | 506 | 507 | 74.3 508 | 509 | 510 | 74.3 511 | 512 | 513 | 77.9 514 | 515 | 516 | 77.3 517 | 518 | 519 | 77 520 | 521 | 522 | 76.9 523 | 524 | 525 | 78.5 526 | 527 | 528 | 77.5 529 | 530 | 531 | 74.3 532 | 533 | 534 | 74.3 535 | 536 | 537 | 74.3 538 | 539 | 540 | 79.8 541 | 542 | 543 | 77.8 544 | 545 | 546 | 74.4 547 | 548 | 549 | 77.2 550 | 551 | 552 | 74.3 553 | 554 | 555 | 74.3 556 | 557 | 558 | 80.6 559 | 560 | 561 | 74.3 562 | 563 | 564 | 74.3 565 | 566 | 567 | 74.3 568 | 569 | 570 | 74.3 571 | 572 | 573 | 74.3 574 | 575 | 576 | 74.3 577 | 578 | 579 | 74.3 580 | 581 | 582 | 75.3 583 | 584 | 585 | 74.3 586 | 587 | 588 | 80.1 589 | 590 | 591 | 95 592 | 593 | 594 | 75.4 595 | 596 | 597 | 77.7 598 | 599 | 600 | 76.6 601 | 602 | 603 | 76.3 604 | 605 | 606 | 76.8 607 | 608 | 609 | 77.1 610 | 611 | 612 | 80.7 613 | 614 | 615 | 83.2 616 | 617 | 618 | 83.3 619 | 620 | 621 | 85.1 622 | 623 | 624 | 79.1 625 | 626 | 627 | 78.1 628 | 629 | 630 | 76.7 631 | 632 | 633 | 75.7 634 | 635 | 636 | 74.3 637 | 638 | 639 | 640 | -------------------------------------------------------------------------------- /parser/src/androidTest/java/io/ticofab/androidgpxparser/parser/GPXParserTest.java: -------------------------------------------------------------------------------- 1 | package io.ticofab.androidgpxparser.parser; 2 | 3 | import android.content.res.AssetManager; 4 | 5 | import androidx.test.ext.junit.runners.AndroidJUnit4; 6 | import androidx.test.filters.MediumTest; 7 | import androidx.test.platform.app.InstrumentationRegistry; 8 | 9 | import org.joda.time.DateTime; 10 | import org.junit.Test; 11 | import org.junit.runner.RunWith; 12 | import org.xmlpull.v1.XmlPullParserException; 13 | 14 | import java.io.IOException; 15 | import java.io.InputStream; 16 | 17 | import io.ticofab.androidgpxparser.parser.domain.Author; 18 | import io.ticofab.androidgpxparser.parser.domain.Copyright; 19 | import io.ticofab.androidgpxparser.parser.domain.Email; 20 | import io.ticofab.androidgpxparser.parser.domain.Gpx; 21 | import io.ticofab.androidgpxparser.parser.domain.Link; 22 | import io.ticofab.androidgpxparser.parser.domain.Metadata; 23 | 24 | import static org.junit.Assert.assertEquals; 25 | import static org.junit.Assert.assertNotNull; 26 | import static org.junit.Assert.assertNull; 27 | import static org.junit.Assert.assertTrue; 28 | 29 | @MediumTest 30 | @RunWith(AndroidJUnit4.class) 31 | public class GPXParserTest { 32 | 33 | @Test 34 | public void testShoresOfDerwentwater() throws IOException, XmlPullParserException { 35 | InputStream input = getAssets().open("shores-of-derwentwater.xml"); 36 | Gpx gpx = new GPXParser().parse(input); 37 | assertNotNull(gpx); // testing that there is no crash, really 38 | } 39 | 40 | @Test 41 | public void testWadlbeisserExport() throws IOException, XmlPullParserException { 42 | InputStream input = getAssets().open("wadlbeisserExport.gpx"); 43 | Gpx gpx = new GPXParser().parse(input); 44 | assertEquals(0, gpx.getTracks().size()); 45 | assertEquals(2, gpx.getWayPoints().size()); 46 | assertEquals(1, gpx.getRoutes().size()); 47 | assertEquals(7847, gpx.getRoutes().get(0).getRoutePoints().size()); 48 | } 49 | 50 | @Test 51 | public void testGarminBaseCampExport() throws IOException, XmlPullParserException { 52 | InputStream input = getAssets().open("garminBaseCampExport.gpx"); 53 | Gpx gpx = new GPXParser().parse(input); 54 | assertEquals("http://www.garmin.com", gpx.getMetadata().getLink().getHref()); 55 | assertEquals("Garmin International", gpx.getMetadata().getLink().getText()); 56 | assertNotNull(gpx.getMetadata().getBounds()); 57 | 58 | assertEquals(1, gpx.getTracks().size()); 59 | assertEquals(1, gpx.getTracks().get(0).getTrackSegments().size()); 60 | assertEquals(10, gpx.getTracks().get(0).getTrackSegments().get(0).getTrackPoints().size()); 61 | assertEquals(3, gpx.getWayPoints().size()); 62 | assertEquals(1, gpx.getRoutes().size()); 63 | assertEquals(7, gpx.getRoutes().get(0).getRoutePoints().size()); 64 | assertEquals(" A92", gpx.getWayPoints().get(0).getDesc()); 65 | assertEquals("Erding Ab", gpx.getWayPoints().get(2).getDesc()); 66 | assertEquals("user", gpx.getWayPoints().get(0).getType()); 67 | } 68 | 69 | @Test(expected = XmlPullParserException.class) 70 | public void testGarminBaseCampExportTruncated() throws IOException, XmlPullParserException { 71 | InputStream input = getAssets().open("garminBaseCampExport-truncated.gpx"); 72 | new GPXParser().parse(input); 73 | } 74 | 75 | @Test(expected = XmlPullParserException.class) 76 | public void testGarminBaseCampExportNoClosingTag() throws IOException, XmlPullParserException { 77 | InputStream input = getAssets().open("garminBaseCampExport-noclosingtag.gpx"); 78 | Gpx gpx = new GPXParser().parse(input); 79 | assertEquals(1, gpx.getTracks().size()); 80 | } 81 | 82 | @Test 83 | public void testFullMetadataParsing() throws IOException, XmlPullParserException { 84 | InputStream input = getAssets().open("metadata-full.gpx"); 85 | Gpx gpx = new GPXParser().parse(input); 86 | 87 | final Metadata metadata = gpx.getMetadata(); 88 | // Name 89 | assertEquals("metadata-full", metadata.getName()); 90 | assertEquals("Full metadata test", metadata.getDesc()); 91 | 92 | // Author 93 | final Author author = metadata.getAuthor(); 94 | assertEquals("John Doe", author.getName()); 95 | 96 | // Author email 97 | final Email email = author.getEmail(); 98 | assertEquals("john.doe", email.getId()); 99 | assertEquals("example.org", email.getDomain()); 100 | 101 | // Author link 102 | final Link authorLink = author.getLink(); 103 | assertEquals("www.example.org", authorLink.getHref()); 104 | assertEquals("Example Org.", authorLink.getText()); 105 | assertEquals("text/html", authorLink.getType()); 106 | 107 | // Copyright 108 | final Copyright copyright = metadata.getCopyright(); 109 | assertEquals("Jane Doe", copyright.getAuthor()); 110 | assertEquals((Integer)2019, copyright.getYear()); 111 | assertEquals("https://www.apache.org/licenses/LICENSE-2.0.txt", copyright.getLicense()); 112 | 113 | // Link 114 | final Link link = metadata.getLink(); 115 | assertEquals("www.example.org", link.getHref()); 116 | assertNull(link.getText()); 117 | assertNull(link.getType()); 118 | 119 | // Time 120 | final DateTime expectedTime = DateTime.parse("2019-04-04T07:00:00+03:00"); 121 | assertTrue(expectedTime.isEqual(metadata.getTime())); 122 | 123 | // Keywords 124 | assertEquals("metadata, test", metadata.getKeywords()); 125 | } 126 | 127 | @Test 128 | public void testMinimalMetadataParsing() throws IOException, XmlPullParserException { 129 | InputStream input = getAssets().open("metadata-minimal.gpx"); 130 | Gpx gpx = new GPXParser().parse(input); 131 | 132 | final Metadata metadata = gpx.getMetadata(); 133 | 134 | // Author 135 | final Author author = metadata.getAuthor(); 136 | assertNull(author.getName()); 137 | assertNull(author.getEmail()); 138 | assertNull(author.getLink()); 139 | 140 | // Copyright 141 | final Copyright copyright = metadata.getCopyright(); 142 | assertEquals("Jane Doe", copyright.getAuthor()); 143 | assertNull(copyright.getYear()); 144 | assertNull(copyright.getLicense()); 145 | } 146 | 147 | public AssetManager getAssets() { 148 | return InstrumentationRegistry.getInstrumentation().getContext().getAssets(); 149 | } 150 | } 151 | -------------------------------------------------------------------------------- /parser/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 3 | -------------------------------------------------------------------------------- /parser/src/main/java/io/ticofab/androidgpxparser/parser/GPXParser.java: -------------------------------------------------------------------------------- 1 | package io.ticofab.androidgpxparser.parser; 2 | 3 | import android.util.Xml; 4 | 5 | import org.joda.time.DateTime; 6 | import org.joda.time.format.ISODateTimeFormat; 7 | import org.xmlpull.v1.XmlPullParser; 8 | import org.xmlpull.v1.XmlPullParserException; 9 | 10 | import java.io.IOException; 11 | import java.io.InputStream; 12 | import java.util.ArrayList; 13 | import java.util.List; 14 | 15 | import io.ticofab.androidgpxparser.parser.domain.Author; 16 | import io.ticofab.androidgpxparser.parser.domain.Bounds; 17 | import io.ticofab.androidgpxparser.parser.domain.Copyright; 18 | import io.ticofab.androidgpxparser.parser.domain.Email; 19 | import io.ticofab.androidgpxparser.parser.domain.Extensions; 20 | import io.ticofab.androidgpxparser.parser.domain.Gpx; 21 | import io.ticofab.androidgpxparser.parser.domain.Link; 22 | import io.ticofab.androidgpxparser.parser.domain.Metadata; 23 | import io.ticofab.androidgpxparser.parser.domain.Point; 24 | import io.ticofab.androidgpxparser.parser.domain.Route; 25 | import io.ticofab.androidgpxparser.parser.domain.RoutePoint; 26 | import io.ticofab.androidgpxparser.parser.domain.Track; 27 | import io.ticofab.androidgpxparser.parser.domain.TrackPoint; 28 | import io.ticofab.androidgpxparser.parser.domain.TrackSegment; 29 | import io.ticofab.androidgpxparser.parser.domain.WayPoint; 30 | 31 | public class GPXParser { 32 | 33 | static private final String TAG_GPX = "gpx"; 34 | static private final String TAG_VERSION = "version"; 35 | static private final String TAG_CREATOR = "creator"; 36 | static private final String TAG_METADATA = "metadata"; 37 | static private final String TAG_TRACK = "trk"; 38 | static private final String TAG_SEGMENT = "trkseg"; 39 | static private final String TAG_TRACK_POINT = "trkpt"; 40 | static private final String TAG_LAT = "lat"; 41 | static private final String TAG_LON = "lon"; 42 | static private final String TAG_ELEVATION = "ele"; 43 | static private final String TAG_TIME = "time"; 44 | static private final String TAG_SYM = "sym"; 45 | static private final String TAG_WAY_POINT = "wpt"; 46 | static private final String TAG_ROUTE = "rte"; 47 | static private final String TAG_ROUTE_POINT = "rtept"; 48 | static private final String TAG_NAME = "name"; 49 | static private final String TAG_DESC = "desc"; 50 | static private final String TAG_CMT = "cmt"; 51 | static private final String TAG_SRC = "src"; 52 | static private final String TAG_LINK = "link"; 53 | static private final String TAG_NUMBER = "number"; 54 | static private final String TAG_TYPE = "type"; 55 | static private final String TAG_TEXT = "text"; 56 | static private final String TAG_AUTHOR = "author"; 57 | static private final String TAG_COPYRIGHT = "copyright"; 58 | static private final String TAG_KEYWORDS = "keywords"; 59 | static private final String TAG_BOUNDS = "bounds"; 60 | static private final String TAG_MIN_LAT = "minlat"; 61 | static private final String TAG_MIN_LON = "minlon"; 62 | static private final String TAG_MAX_LAT = "maxlat"; 63 | static private final String TAG_MAX_LON = "maxlon"; 64 | static private final String TAG_HREF = "href"; 65 | static private final String TAG_YEAR = "year"; 66 | static private final String TAG_LICENSE = "license"; 67 | static private final String TAG_EMAIL = "email"; 68 | static private final String TAG_ID = "id"; 69 | static private final String TAG_DOMAIN = "domain"; 70 | 71 | // extensions-related tags 72 | static private final String TAG_EXTENSIONS = "extensions"; 73 | static private final String TAG_SPEED = "speed"; 74 | 75 | static private final String namespace = null; 76 | 77 | public Gpx parse(InputStream in) throws XmlPullParserException, IOException { 78 | try { 79 | XmlPullParser parser = Xml.newPullParser(); 80 | parser.setFeature(XmlPullParser.FEATURE_PROCESS_NAMESPACES, true); 81 | parser.setInput(in, null); 82 | parser.nextTag(); 83 | return readGpx(parser); 84 | } finally { 85 | in.close(); 86 | } 87 | } 88 | 89 | private Gpx readGpx(XmlPullParser parser) throws XmlPullParserException, IOException { 90 | List wayPoints = new ArrayList<>(); 91 | List tracks = new ArrayList<>(); 92 | List routes = new ArrayList<>(); 93 | 94 | parser.require(XmlPullParser.START_TAG, namespace, TAG_GPX); 95 | 96 | Gpx.Builder builder = new Gpx.Builder(); 97 | builder.setVersion(parser.getAttributeValue(namespace, TAG_VERSION)); 98 | builder.setCreator(parser.getAttributeValue(namespace, TAG_CREATOR)); 99 | 100 | while (loopMustContinue(parser.next())) { 101 | if (parser.getEventType() != XmlPullParser.START_TAG) { 102 | continue; 103 | } 104 | String name = parser.getName(); 105 | // Starts by looking for the entry tag 106 | switch (name) { 107 | case TAG_METADATA: 108 | builder.setMetadata(readMetadata(parser)); 109 | break; 110 | case TAG_WAY_POINT: 111 | wayPoints.add(readWayPoint(parser)); 112 | break; 113 | case TAG_ROUTE: 114 | routes.add(readRoute(parser)); 115 | break; 116 | case TAG_TRACK: 117 | tracks.add(readTrack(parser)); 118 | break; 119 | default: 120 | skip(parser); 121 | break; 122 | } 123 | } 124 | parser.require(XmlPullParser.END_TAG, namespace, TAG_GPX); 125 | return builder 126 | .setWayPoints(wayPoints) 127 | .setRoutes(routes) 128 | .setTracks(tracks) 129 | .build(); 130 | } 131 | 132 | // Parses the contents of an entry. If it encounters a title, summary, or link tag, hands them off 133 | // to their respective "read" methods for processing. Otherwise, skips the tag. 134 | private Track readTrack(XmlPullParser parser) throws XmlPullParserException, IOException { 135 | Track.Builder trackBuilder = new Track.Builder(); 136 | 137 | List segments = new ArrayList<>(); 138 | parser.require(XmlPullParser.START_TAG, namespace, TAG_TRACK); 139 | while (loopMustContinue(parser.next())) { 140 | if (parser.getEventType() != XmlPullParser.START_TAG) { 141 | continue; 142 | } 143 | String name = parser.getName(); 144 | switch (name) { 145 | case TAG_NAME: 146 | trackBuilder.setTrackName(readName(parser)); 147 | break; 148 | case TAG_SEGMENT: 149 | segments.add(readSegment(parser)); 150 | break; 151 | case TAG_DESC: 152 | trackBuilder.setTrackDesc(readDesc(parser)); 153 | break; 154 | case TAG_CMT: 155 | trackBuilder.setTrackCmt(readCmt(parser)); 156 | break; 157 | case TAG_SRC: 158 | trackBuilder.setTrackSrc(readString(parser, TAG_SRC)); 159 | break; 160 | case TAG_LINK: 161 | trackBuilder.setTrackLink(readLink(parser)); 162 | break; 163 | case TAG_NUMBER: 164 | trackBuilder.setTrackNumber(readNumber(parser)); 165 | break; 166 | case TAG_TYPE: 167 | trackBuilder.setTrackType(readString(parser, TAG_TYPE)); 168 | break; 169 | default: 170 | skip(parser); 171 | break; 172 | } 173 | } 174 | parser.require(XmlPullParser.END_TAG, namespace, TAG_TRACK); 175 | return trackBuilder 176 | .setTrackSegments(segments) 177 | .build(); 178 | } 179 | 180 | private Link readLink(XmlPullParser parser) throws IOException, XmlPullParserException { 181 | parser.require(XmlPullParser.START_TAG, namespace, TAG_LINK); 182 | 183 | Link.Builder linkBuilder = new Link.Builder(); 184 | linkBuilder.setLinkHref(parser.getAttributeValue(namespace, TAG_HREF)); 185 | 186 | while (loopMustContinue(parser.next())) { 187 | if (parser.getEventType() != XmlPullParser.START_TAG) { 188 | continue; 189 | } 190 | String name = parser.getName(); 191 | switch (name) { 192 | case TAG_TEXT: 193 | linkBuilder.setLinkText(readString(parser, TAG_TEXT)); 194 | break; 195 | case TAG_TYPE: 196 | linkBuilder.setLinkType(readString(parser, TAG_TYPE)); 197 | break; 198 | default: 199 | skip(parser); 200 | break; 201 | } 202 | } 203 | parser.require(XmlPullParser.END_TAG, namespace, TAG_LINK); 204 | return linkBuilder.build(); 205 | } 206 | 207 | private Bounds readBounds(XmlPullParser parser) throws IOException, XmlPullParserException { 208 | parser.require(XmlPullParser.START_TAG, namespace, TAG_BOUNDS); 209 | Bounds bounds = new Bounds.Builder() 210 | .setMinLat(Double.valueOf(parser.getAttributeValue(namespace, TAG_MIN_LAT))) 211 | .setMinLon(Double.valueOf(parser.getAttributeValue(namespace, TAG_MIN_LON))) 212 | .setMaxLat(Double.valueOf(parser.getAttributeValue(namespace, TAG_MAX_LAT))) 213 | .setMaxLon(Double.valueOf(parser.getAttributeValue(namespace, TAG_MAX_LON))) 214 | .build(); 215 | 216 | parser.nextTag(); 217 | 218 | parser.require(XmlPullParser.END_TAG, namespace, TAG_BOUNDS); 219 | 220 | return bounds; 221 | } 222 | 223 | // Processes summary tags in the feed. 224 | private TrackSegment readSegment(XmlPullParser parser) throws IOException, XmlPullParserException { 225 | List points = new ArrayList<>(); 226 | parser.require(XmlPullParser.START_TAG, namespace, TAG_SEGMENT); 227 | while (loopMustContinue(parser.next())) { 228 | if (parser.getEventType() != XmlPullParser.START_TAG) { 229 | continue; 230 | } 231 | String name = parser.getName(); 232 | if (TAG_TRACK_POINT.equals(name)) { 233 | points.add(readTrackPoint(parser)); 234 | } else { 235 | skip(parser); 236 | } 237 | } 238 | parser.require(XmlPullParser.END_TAG, namespace, TAG_SEGMENT); 239 | return new TrackSegment.Builder() 240 | .setTrackPoints(points) 241 | .build(); 242 | } 243 | 244 | private Route readRoute(XmlPullParser parser) throws IOException, XmlPullParserException { 245 | List points = new ArrayList<>(); 246 | parser.require(XmlPullParser.START_TAG, namespace, TAG_ROUTE); 247 | Route.Builder routeBuilder = new Route.Builder(); 248 | 249 | while (loopMustContinue(parser.next())) { 250 | if (parser.getEventType() != XmlPullParser.START_TAG) { 251 | continue; 252 | } 253 | String name = parser.getName(); 254 | switch (name) { 255 | case TAG_ROUTE_POINT: 256 | points.add(readRoutePoint(parser)); 257 | break; 258 | case TAG_NAME: 259 | routeBuilder.setRouteName(readName(parser)); 260 | break; 261 | case TAG_DESC: 262 | routeBuilder.setRouteDesc(readDesc(parser)); 263 | break; 264 | case TAG_CMT: 265 | routeBuilder.setRouteCmt(readCmt(parser)); 266 | break; 267 | case TAG_SRC: 268 | routeBuilder.setRouteSrc(readString(parser, TAG_SRC)); 269 | break; 270 | case TAG_LINK: 271 | routeBuilder.setRouteLink(readLink(parser)); 272 | break; 273 | case TAG_NUMBER: 274 | routeBuilder.setRouteNumber(readNumber(parser)); 275 | break; 276 | case TAG_TYPE: 277 | routeBuilder.setRouteType(readString(parser, TAG_TYPE)); 278 | break; 279 | default: 280 | skip(parser); 281 | break; 282 | } 283 | } 284 | parser.require(XmlPullParser.END_TAG, namespace, TAG_ROUTE); 285 | return routeBuilder 286 | .setRoutePoints(points) 287 | .build(); 288 | } 289 | 290 | /** 291 | * Reads a single point, which can either be a {@link TrackPoint}, {@link RoutePoint} or {@link WayPoint}. 292 | * 293 | * @param builder The prepared builder, one of {@link TrackPoint.Builder}, {@link RoutePoint.Builder} or {@link WayPoint.Builder}. 294 | * @param parser Parser 295 | * @param tagName Tag name, e.g. trkpt, rtept, wpt 296 | */ 297 | private Point readPoint(Point.Builder builder, XmlPullParser parser, String tagName) throws XmlPullParserException, IOException { 298 | parser.require(XmlPullParser.START_TAG, namespace, tagName); 299 | 300 | builder.setLatitude(Double.valueOf(parser.getAttributeValue(namespace, TAG_LAT))); 301 | builder.setLongitude(Double.valueOf(parser.getAttributeValue(namespace, TAG_LON))); 302 | 303 | while (loopMustContinue(parser.next())) { 304 | if (parser.getEventType() != XmlPullParser.START_TAG) { 305 | continue; 306 | } 307 | String name = parser.getName(); 308 | switch (name) { 309 | case TAG_NAME: 310 | builder.setName(readName(parser)); 311 | break; 312 | case TAG_DESC: 313 | builder.setDesc(readDesc(parser)); 314 | break; 315 | case TAG_ELEVATION: 316 | builder.setElevation(readElevation(parser)); 317 | break; 318 | case TAG_TIME: 319 | builder.setTime(readTime(parser)); 320 | break; 321 | case TAG_TYPE: 322 | builder.setType(readType(parser)); 323 | break; 324 | case TAG_EXTENSIONS: 325 | builder.setExtensions(readExtensions(parser)); 326 | break; 327 | case TAG_SYM: 328 | builder.setSym(readSym(parser)); 329 | break; 330 | case TAG_CMT: 331 | builder.setCmt(readCmt(parser)); 332 | break; 333 | default: 334 | skip(parser); 335 | break; 336 | } 337 | } 338 | 339 | parser.require(XmlPullParser.END_TAG, namespace, tagName); 340 | return builder.build(); 341 | } 342 | 343 | private Metadata readMetadata(XmlPullParser parser) throws XmlPullParserException, IOException { 344 | Metadata.Builder metadataBuilder = new Metadata.Builder(); 345 | 346 | parser.require(XmlPullParser.START_TAG, namespace, TAG_METADATA); 347 | while (loopMustContinue(parser.next())) { 348 | if (parser.getEventType() != XmlPullParser.START_TAG) { 349 | continue; 350 | } 351 | String name = parser.getName(); 352 | switch (name) { 353 | case TAG_NAME: 354 | metadataBuilder.setName(readName(parser)); 355 | break; 356 | case TAG_DESC: 357 | metadataBuilder.setDesc(readDesc(parser)); 358 | break; 359 | case TAG_AUTHOR: 360 | metadataBuilder.setAuthor(readAuthor(parser)); 361 | break; 362 | case TAG_COPYRIGHT: 363 | metadataBuilder.setCopyright(readCopyright(parser)); 364 | break; 365 | case TAG_LINK: 366 | metadataBuilder.setLink(readLink(parser)); 367 | break; 368 | case TAG_TIME: 369 | metadataBuilder.setTime(readTime(parser)); 370 | break; 371 | case TAG_KEYWORDS: 372 | metadataBuilder.setKeywords(readString(parser, TAG_KEYWORDS)); 373 | break; 374 | case TAG_BOUNDS: 375 | metadataBuilder.setBounds(readBounds(parser)); 376 | break; 377 | case TAG_EXTENSIONS: 378 | default: 379 | skip(parser); 380 | break; 381 | } 382 | } 383 | parser.require(XmlPullParser.END_TAG, namespace, TAG_METADATA); 384 | return metadataBuilder.build(); 385 | } 386 | 387 | private Author readAuthor(XmlPullParser parser) throws XmlPullParserException, IOException { 388 | Author.Builder authorBuilder = new Author.Builder(); 389 | 390 | parser.require(XmlPullParser.START_TAG, namespace, TAG_AUTHOR); 391 | while (loopMustContinue(parser.next())) { 392 | if (parser.getEventType() != XmlPullParser.START_TAG) { 393 | continue; 394 | } 395 | String name = parser.getName(); 396 | switch (name) { 397 | case TAG_NAME: 398 | authorBuilder.setName(readString(parser, TAG_NAME)); 399 | break; 400 | case TAG_EMAIL: 401 | authorBuilder.setEmail(readEmail(parser)); 402 | break; 403 | case TAG_LINK: 404 | authorBuilder.setLink(readLink(parser)); 405 | break; 406 | default: 407 | skip(parser); 408 | break; 409 | } 410 | } 411 | parser.require(XmlPullParser.END_TAG, namespace, TAG_AUTHOR); 412 | return authorBuilder.build(); 413 | } 414 | 415 | private Email readEmail(XmlPullParser parser) throws IOException, XmlPullParserException { 416 | parser.require(XmlPullParser.START_TAG, namespace, TAG_EMAIL); 417 | 418 | Email.Builder emailBuilder = new Email.Builder(); 419 | emailBuilder.setId(parser.getAttributeValue(namespace, TAG_ID)); 420 | emailBuilder.setDomain(parser.getAttributeValue(namespace, TAG_DOMAIN)); 421 | 422 | // Email tag is self closed, advance the parser to next event 423 | parser.next(); 424 | 425 | parser.require(XmlPullParser.END_TAG, namespace, TAG_EMAIL); 426 | return emailBuilder.build(); 427 | } 428 | 429 | private Copyright readCopyright(XmlPullParser parser) throws XmlPullParserException, IOException { 430 | parser.require(XmlPullParser.START_TAG, namespace, TAG_COPYRIGHT); 431 | 432 | Copyright.Builder copyrightBuilder = new Copyright.Builder(); 433 | copyrightBuilder.setAuthor(parser.getAttributeValue(namespace, TAG_AUTHOR)); 434 | 435 | while (loopMustContinue(parser.next())) { 436 | if (parser.getEventType() != XmlPullParser.START_TAG) { 437 | continue; 438 | } 439 | String name = parser.getName(); 440 | switch (name) { 441 | case TAG_YEAR: 442 | copyrightBuilder.setYear(readYear(parser)); 443 | break; 444 | case TAG_LICENSE: 445 | copyrightBuilder.setLicense(readString(parser, TAG_LICENSE)); 446 | break; 447 | default: 448 | skip(parser); 449 | break; 450 | } 451 | } 452 | parser.require(XmlPullParser.END_TAG, namespace, TAG_COPYRIGHT); 453 | return copyrightBuilder.build(); 454 | } 455 | 456 | private WayPoint readWayPoint(XmlPullParser parser) throws XmlPullParserException, IOException { 457 | return (WayPoint) readPoint(new WayPoint.Builder(), parser, TAG_WAY_POINT); 458 | } 459 | 460 | private TrackPoint readTrackPoint(XmlPullParser parser) throws IOException, XmlPullParserException { 461 | return (TrackPoint) readPoint(new TrackPoint.Builder(), parser, TAG_TRACK_POINT); 462 | } 463 | 464 | private RoutePoint readRoutePoint(XmlPullParser parser) throws IOException, XmlPullParserException { 465 | return (RoutePoint) readPoint(new RoutePoint.Builder(), parser, TAG_ROUTE_POINT); 466 | } 467 | 468 | private String readName(XmlPullParser parser) throws IOException, XmlPullParserException { 469 | return readString(parser, TAG_NAME); 470 | } 471 | 472 | private String readDesc(XmlPullParser parser) throws IOException, XmlPullParserException { 473 | return readString(parser, TAG_DESC); 474 | } 475 | 476 | private String readType(XmlPullParser parser) throws IOException, XmlPullParserException { 477 | return readString(parser, TAG_TYPE); 478 | } 479 | 480 | private String readCmt(XmlPullParser parser) throws IOException, XmlPullParserException { 481 | return readString(parser, TAG_CMT); 482 | } 483 | 484 | private String readString(XmlPullParser parser, String tag) throws IOException, XmlPullParserException { 485 | parser.require(XmlPullParser.START_TAG, namespace, tag); 486 | String value = readText(parser); 487 | parser.require(XmlPullParser.END_TAG, namespace, tag); 488 | return value; 489 | } 490 | 491 | private Double readElevation(XmlPullParser parser) throws IOException, XmlPullParserException { 492 | parser.require(XmlPullParser.START_TAG, namespace, TAG_ELEVATION); 493 | Double ele = Double.valueOf(readText(parser)); 494 | parser.require(XmlPullParser.END_TAG, namespace, TAG_ELEVATION); 495 | return ele; 496 | } 497 | 498 | private DateTime readTime(XmlPullParser parser) throws IOException, XmlPullParserException { 499 | parser.require(XmlPullParser.START_TAG, namespace, TAG_TIME); 500 | DateTime time = ISODateTimeFormat.dateTimeParser().parseDateTime(readText(parser)); 501 | parser.require(XmlPullParser.END_TAG, namespace, TAG_TIME); 502 | return time; 503 | } 504 | private String readSym(XmlPullParser parser) throws IOException, XmlPullParserException { 505 | parser.require(XmlPullParser.START_TAG, namespace, TAG_SYM); 506 | String value = readText(parser); 507 | parser.require(XmlPullParser.END_TAG, namespace, TAG_SYM); 508 | return value; 509 | } 510 | 511 | private String readText(XmlPullParser parser) throws IOException, XmlPullParserException { 512 | String result = ""; 513 | if (parser.next() == XmlPullParser.TEXT) { 514 | result = parser.getText(); 515 | parser.nextTag(); 516 | } 517 | return result; 518 | } 519 | 520 | private Integer readNumber(XmlPullParser parser) throws IOException, XmlPullParserException, NumberFormatException { 521 | parser.require(XmlPullParser.START_TAG, namespace, TAG_NUMBER); 522 | Integer number = Integer.valueOf(readText(parser)); 523 | parser.require(XmlPullParser.END_TAG, namespace, TAG_NUMBER); 524 | return number; 525 | } 526 | 527 | private Double readSpeed(XmlPullParser parser) throws IOException, XmlPullParserException { 528 | parser.require(XmlPullParser.START_TAG, namespace, TAG_SPEED); 529 | double speed; 530 | try { 531 | speed = Double.parseDouble(readText(parser)); 532 | } catch (NumberFormatException e) { 533 | // there was an issue parsing speed, default to 0.0 534 | speed = 0.0; 535 | } 536 | parser.require(XmlPullParser.END_TAG, namespace, TAG_SPEED); 537 | return speed; 538 | } 539 | 540 | private Integer readYear(XmlPullParser parser) throws IOException, XmlPullParserException, NumberFormatException { 541 | parser.require(XmlPullParser.START_TAG, namespace, TAG_YEAR); 542 | String yearStr = readText(parser); 543 | 544 | // we might need to strip an optional time-zone, even though I've never seen it 545 | // "2019" vs "2019+05:00" or "2019-03:00" 546 | int timeZoneStart = yearStr.indexOf('+'); 547 | if (timeZoneStart == -1) timeZoneStart = yearStr.indexOf('-'); 548 | yearStr = (timeZoneStart == -1) ? yearStr : yearStr.substring(0, timeZoneStart); 549 | 550 | Integer year = Integer.valueOf(yearStr); 551 | parser.require(XmlPullParser.END_TAG, namespace, TAG_YEAR); 552 | return year; 553 | } 554 | 555 | private Extensions readExtensions(XmlPullParser parser) throws IOException, XmlPullParserException { 556 | Extensions.Builder extensionsBuilder = new Extensions.Builder(); 557 | 558 | parser.require(XmlPullParser.START_TAG, namespace, TAG_EXTENSIONS); 559 | while (loopMustContinue(parser.next())) { 560 | if (parser.getEventType() != XmlPullParser.START_TAG) { 561 | continue; 562 | } 563 | String name = parser.getName(); 564 | switch (name) { 565 | case TAG_SPEED: 566 | extensionsBuilder.setSpeed(readSpeed(parser)); 567 | break; 568 | default: 569 | skip(parser); 570 | break; 571 | } 572 | } 573 | parser.require(XmlPullParser.END_TAG, namespace, TAG_EXTENSIONS); 574 | return extensionsBuilder.build(); 575 | } 576 | 577 | private void skip(XmlPullParser parser) throws XmlPullParserException, IOException { 578 | if (parser.getEventType() != XmlPullParser.START_TAG) { 579 | throw new IllegalStateException(); 580 | } 581 | int depth = 1; 582 | while (depth != 0) { 583 | switch (parser.next()) { 584 | case XmlPullParser.END_TAG: 585 | depth--; 586 | break; 587 | case XmlPullParser.START_TAG: 588 | depth++; 589 | break; 590 | } 591 | } 592 | } 593 | 594 | private boolean loopMustContinue(int next) { 595 | return next != XmlPullParser.END_TAG && next != XmlPullParser.END_DOCUMENT; 596 | } 597 | } 598 | -------------------------------------------------------------------------------- /parser/src/main/java/io/ticofab/androidgpxparser/parser/domain/Author.java: -------------------------------------------------------------------------------- 1 | package io.ticofab.androidgpxparser.parser.domain; 2 | 3 | public class Author { 4 | 5 | private final String mName; 6 | private final Email mEmail; 7 | private final Link mLink; 8 | 9 | private Author(Builder builder) { 10 | this.mName = builder.mName; 11 | this.mEmail = builder.mEmail; 12 | this.mLink = builder.mLink; 13 | } 14 | 15 | public String getName() { 16 | return mName; 17 | } 18 | 19 | public Email getEmail() { 20 | return mEmail; 21 | } 22 | 23 | public Link getLink() { 24 | return mLink; 25 | } 26 | 27 | public static class Builder { 28 | private String mName; 29 | private Email mEmail; 30 | private Link mLink; 31 | 32 | public Builder setName(String name) { 33 | mName = name; 34 | return this; 35 | } 36 | 37 | public Builder setEmail(Email email) { 38 | mEmail = email; 39 | return this; 40 | } 41 | 42 | public Builder setLink(Link link) { 43 | mLink = link; 44 | return this; 45 | } 46 | 47 | public Author build() { 48 | return new Author(this); 49 | } 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /parser/src/main/java/io/ticofab/androidgpxparser/parser/domain/Bounds.java: -------------------------------------------------------------------------------- 1 | package io.ticofab.androidgpxparser.parser.domain; 2 | 3 | public class Bounds { 4 | 5 | private final Double mMinLat; 6 | private final Double mMinLon; 7 | private final Double mMaxLat; 8 | private final Double mMaxLon; 9 | 10 | private Bounds(Builder builder) { 11 | mMinLat = builder.mMinLat; 12 | mMinLon = builder.mMinLon; 13 | mMaxLat = builder.mMaxLat; 14 | mMaxLon = builder.mMaxLon; 15 | } 16 | 17 | public Double getMinLat() { 18 | return mMinLat; 19 | } 20 | 21 | public Double getMinLon() { 22 | return mMinLon; 23 | } 24 | 25 | public Double getMaxLat() { 26 | return mMaxLat; 27 | } 28 | 29 | public Double getMaxLon() { 30 | return mMaxLon; 31 | } 32 | 33 | public static class Builder { 34 | private Double mMinLat; 35 | private Double mMinLon; 36 | private Double mMaxLat; 37 | private Double mMaxLon; 38 | 39 | public Builder setMinLat(Double minLat) { 40 | mMinLat = minLat; 41 | return this; 42 | } 43 | 44 | public Builder setMinLon(Double minLon) { 45 | mMinLon = minLon; 46 | return this; 47 | } 48 | 49 | public Builder setMaxLat(Double maxLat) { 50 | mMaxLat = maxLat; 51 | return this; 52 | } 53 | 54 | public Builder setMaxLon(Double maxLon) { 55 | mMaxLon = maxLon; 56 | return this; 57 | } 58 | 59 | public Bounds build() { 60 | return new Bounds(this); 61 | } 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /parser/src/main/java/io/ticofab/androidgpxparser/parser/domain/Copyright.java: -------------------------------------------------------------------------------- 1 | package io.ticofab.androidgpxparser.parser.domain; 2 | 3 | public class Copyright { 4 | 5 | private final String mAuthor; 6 | private final Integer mYear; 7 | private final String mLicense; 8 | 9 | private Copyright(Builder builder) { 10 | mAuthor = builder.mAuthor; 11 | mYear = builder.mYear; 12 | mLicense = builder.mLicense; 13 | } 14 | 15 | public String getAuthor() { 16 | return mAuthor; 17 | } 18 | 19 | public Integer getYear() { 20 | return mYear; 21 | } 22 | 23 | public String getLicense() { 24 | return mLicense; 25 | } 26 | 27 | public static class Builder { 28 | private String mAuthor; 29 | private Integer mYear; 30 | private String mLicense; 31 | 32 | public Builder setAuthor(String author) { 33 | mAuthor = author; 34 | return this; 35 | } 36 | 37 | public Builder setYear(Integer year) { 38 | mYear = year; 39 | return this; 40 | } 41 | 42 | public Builder setLicense(String license) { 43 | mLicense = license; 44 | return this; 45 | } 46 | 47 | public Copyright build() { 48 | return new Copyright(this); 49 | } 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /parser/src/main/java/io/ticofab/androidgpxparser/parser/domain/Email.java: -------------------------------------------------------------------------------- 1 | package io.ticofab.androidgpxparser.parser.domain; 2 | 3 | public class Email { 4 | 5 | private String mId; 6 | private String mDomain; 7 | 8 | private Email(Builder builder) { 9 | this.mId = builder.mId; 10 | this.mDomain = builder.mDomain; 11 | } 12 | 13 | public String getId() { 14 | return mId; 15 | } 16 | 17 | public String getDomain() { 18 | return mDomain; 19 | } 20 | 21 | public static class Builder { 22 | private String mId; 23 | private String mDomain; 24 | 25 | public Builder setId(String id) { 26 | mId = id; 27 | return this; 28 | } 29 | 30 | public Builder setDomain(String domain) { 31 | mDomain = domain; 32 | return this; 33 | } 34 | 35 | public Email build() { 36 | return new Email(this); 37 | } 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /parser/src/main/java/io/ticofab/androidgpxparser/parser/domain/Extensions.java: -------------------------------------------------------------------------------- 1 | package io.ticofab.androidgpxparser.parser.domain; 2 | 3 | /** 4 | * 5 | * NOTE: 6 | * 7 | * Extensions to the GPX 1.1 format are completely arbitrary. The "speed" extension is 8 | * added as it seems to be quite common, but anything else is by default not supported. If an 9 | * extension is supported, it must be considered best-effort and it might fail in some cases. 10 | * 11 | * For instance, someone might have a track where speed is reported as 12 | * 13 | * 15 km/h 14 | * 15 | * The current Speed implementation uses Double numbers. The example above would fail. 16 | * 17 | */ 18 | public class Extensions { 19 | 20 | private final Double mSpeed; 21 | 22 | private Extensions(Extensions.Builder builder) { 23 | mSpeed = builder.mSpeed; 24 | } 25 | 26 | public Double getSpeed() { 27 | return mSpeed; 28 | } 29 | 30 | public static class Builder { 31 | private Double mSpeed; 32 | 33 | public Builder setSpeed(Double speed) { 34 | mSpeed = speed; 35 | return this; 36 | } 37 | 38 | public Extensions build() { 39 | return new Extensions(this); 40 | } 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /parser/src/main/java/io/ticofab/androidgpxparser/parser/domain/Gpx.java: -------------------------------------------------------------------------------- 1 | package io.ticofab.androidgpxparser.parser.domain; 2 | 3 | import java.util.ArrayList; 4 | import java.util.Collections; 5 | import java.util.List; 6 | 7 | public class Gpx { 8 | private final String mVersion; 9 | private final String mCreator; 10 | private final Metadata mMetadata; 11 | private final List mWayPoints; 12 | private final List mRoutes; 13 | private final List mTracks; 14 | 15 | private Gpx(Builder builder) { 16 | mVersion = builder.mVersion; 17 | mCreator = builder.mCreator; 18 | mMetadata = builder.mMetadata; 19 | mWayPoints = Collections.unmodifiableList(new ArrayList<>(builder.mWayPoints)); 20 | mRoutes = Collections.unmodifiableList(new ArrayList<>(builder.mRoutes)); 21 | mTracks = Collections.unmodifiableList(new ArrayList<>(builder.mTracks)); 22 | } 23 | 24 | public String getVersion() { return mVersion; } 25 | 26 | public String getCreator() { return mCreator; } 27 | 28 | public Metadata getMetadata() { 29 | return mMetadata; 30 | } 31 | 32 | public List getWayPoints() { 33 | return mWayPoints; 34 | } 35 | 36 | public List getRoutes() { 37 | return mRoutes; 38 | } 39 | 40 | public List getTracks() { 41 | return mTracks; 42 | } 43 | 44 | public static class Builder { 45 | private List mWayPoints; 46 | private List mRoutes; 47 | private List mTracks; 48 | private String mVersion; 49 | private String mCreator; 50 | private Metadata mMetadata; 51 | 52 | public Builder setTracks(List tracks) { 53 | mTracks = tracks; 54 | return this; 55 | } 56 | 57 | public Builder setWayPoints(List wayPoints) { 58 | mWayPoints = wayPoints; 59 | return this; 60 | } 61 | 62 | public Builder setRoutes(List routes) { 63 | this.mRoutes = routes; 64 | return this; 65 | } 66 | 67 | public Builder setVersion(String version) { 68 | mVersion = version; 69 | return this; 70 | } 71 | 72 | public Builder setCreator(String creator) { 73 | mCreator = creator; 74 | return this; 75 | } 76 | 77 | public Builder setMetadata(Metadata mMetadata) { 78 | this.mMetadata = mMetadata; 79 | return this; 80 | } 81 | 82 | public Gpx build() { 83 | return new Gpx(this); 84 | } 85 | 86 | 87 | } 88 | } 89 | -------------------------------------------------------------------------------- /parser/src/main/java/io/ticofab/androidgpxparser/parser/domain/Link.java: -------------------------------------------------------------------------------- 1 | package io.ticofab.androidgpxparser.parser.domain; 2 | 3 | /** 4 | * Created by Stu Stirling on 04/10/2017. 5 | */ 6 | 7 | public class Link { 8 | 9 | private final String mLinkHref; 10 | private final String mLinkText; 11 | private final String mLinkType; 12 | 13 | private Link(Builder builder) { 14 | mLinkHref = builder.mLinkHref; 15 | mLinkText = builder.mLinkText; 16 | mLinkType = builder.mLinkType; 17 | } 18 | 19 | public String getHref() { 20 | return mLinkHref; 21 | } 22 | 23 | public String getText() { 24 | return mLinkText; 25 | } 26 | 27 | public String getType() { 28 | return mLinkType; 29 | } 30 | 31 | public static class Builder { 32 | private String mLinkHref; 33 | private String mLinkText; 34 | private String mLinkType; 35 | 36 | public Builder() { 37 | 38 | } 39 | 40 | public Builder setLinkHref(String linkHref) { 41 | mLinkHref = linkHref; 42 | return this; 43 | } 44 | 45 | public Builder setLinkText(String linkText) { 46 | mLinkText = linkText; 47 | return this; 48 | } 49 | 50 | public Builder setLinkType(String linkType ) { 51 | mLinkType = linkType; 52 | return this; 53 | } 54 | 55 | public Link build(){ 56 | return new Link(this); 57 | } 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /parser/src/main/java/io/ticofab/androidgpxparser/parser/domain/Metadata.java: -------------------------------------------------------------------------------- 1 | package io.ticofab.androidgpxparser.parser.domain; 2 | 3 | import org.joda.time.DateTime; 4 | 5 | public class Metadata { 6 | 7 | private final String mName; 8 | private final String mDesc; 9 | private final Author mAuthor; 10 | private final Copyright mCopyright; 11 | private final Link mLink; 12 | private final DateTime mTime; 13 | private final String mKeywords; 14 | private final Bounds mBounds; 15 | private final String mExtensions; 16 | 17 | private Metadata(Metadata.Builder builder) { 18 | mName = builder.mName; 19 | mDesc = builder.mDesc; 20 | mAuthor = builder.mAuthor; 21 | mCopyright = builder.mCopyright; 22 | mLink = builder.mLink; 23 | mTime = builder.mTime; 24 | mKeywords = builder.mKeywords; 25 | mBounds = builder.mBounds; 26 | mExtensions = builder.mExtensions; 27 | } 28 | 29 | public String getName() { 30 | return mName; 31 | } 32 | 33 | public String getDesc() { 34 | return mDesc; 35 | } 36 | 37 | public Author getAuthor() { 38 | return mAuthor; 39 | } 40 | 41 | public Copyright getCopyright() { 42 | return mCopyright; 43 | } 44 | 45 | public Link getLink() { 46 | return mLink; 47 | } 48 | 49 | public DateTime getTime() { 50 | return mTime; 51 | } 52 | 53 | public String getKeywords() { 54 | return mKeywords; 55 | } 56 | 57 | public Bounds getBounds() { 58 | return mBounds; 59 | } 60 | 61 | public String getExtensions() { 62 | return mExtensions; 63 | } 64 | 65 | public static class Builder { 66 | private String mName; 67 | private String mDesc; 68 | private Author mAuthor; 69 | private Copyright mCopyright; 70 | private Link mLink; 71 | private DateTime mTime; 72 | private String mKeywords; 73 | private Bounds mBounds; 74 | private String mExtensions; 75 | 76 | public Builder setName(String name) { 77 | mName = name; 78 | return this; 79 | } 80 | 81 | public Builder setDesc(String desc) { 82 | mDesc = desc; 83 | return this; 84 | } 85 | 86 | public Builder setAuthor(Author author) { 87 | mAuthor = author; 88 | return this; 89 | } 90 | 91 | public Builder setCopyright(Copyright copyright) { 92 | mCopyright = copyright; 93 | return this; 94 | } 95 | 96 | public Builder setLink(Link link) { 97 | mLink = link; 98 | return this; 99 | } 100 | 101 | public Builder setTime(DateTime time) { 102 | mTime = time; 103 | return this; 104 | } 105 | 106 | public Builder setKeywords(String keywords) { 107 | mKeywords = keywords; 108 | return this; 109 | } 110 | 111 | public Builder setBounds(Bounds bounds) { 112 | mBounds = bounds; 113 | return this; 114 | } 115 | 116 | public Metadata build() { 117 | return new Metadata(this); 118 | } 119 | 120 | 121 | } 122 | } 123 | -------------------------------------------------------------------------------- /parser/src/main/java/io/ticofab/androidgpxparser/parser/domain/Point.java: -------------------------------------------------------------------------------- 1 | package io.ticofab.androidgpxparser.parser.domain; 2 | 3 | import org.joda.time.DateTime; 4 | 5 | /** 6 | * A point containing a location, time and name. 7 | */ 8 | public abstract class Point { 9 | private final Double mLatitude; 10 | private final Double mLongitude; 11 | private final Double mElevation; 12 | private final DateTime mTime; 13 | private final String mName; 14 | private final String mDesc; 15 | private final String mType; 16 | private final String mSym; 17 | private final String mCmt; 18 | private final Extensions mExtensions; 19 | 20 | Point(Builder builder) { 21 | mLatitude = builder.mLatitude; 22 | mLongitude = builder.mLongitude; 23 | mElevation = builder.mElevation; 24 | mTime = builder.mTime; 25 | mName = builder.mName; 26 | mDesc = builder.mDesc; 27 | mType = builder.mType; 28 | mSym = builder.mSym; 29 | mCmt = builder.mCmt; 30 | mExtensions = builder.mExtensions; 31 | } 32 | 33 | /** 34 | * @return the latitude in degrees 35 | */ 36 | public Double getLatitude() { 37 | return mLatitude; 38 | } 39 | 40 | /** 41 | * @return the longitude in degrees 42 | */ 43 | public Double getLongitude() { 44 | return mLongitude; 45 | } 46 | 47 | /** 48 | * @return the elevation in meters 49 | */ 50 | public Double getElevation() { 51 | return mElevation; 52 | } 53 | 54 | public DateTime getTime() { 55 | return mTime; 56 | } 57 | 58 | /** 59 | * @return the point name 60 | */ 61 | public String getName() { 62 | return mName; 63 | } 64 | 65 | /** 66 | * @return the description 67 | */ 68 | public String getDesc() { 69 | return mDesc; 70 | } 71 | 72 | /** 73 | * @return the type (category) 74 | */ 75 | public String getType() { 76 | return mType; 77 | } 78 | 79 | /** 80 | * @return the point symbol 81 | */ 82 | public String getSym() { 83 | return mSym; 84 | } 85 | 86 | /** 87 | * @return the point cmt 88 | */ 89 | public String getCmt() { 90 | return mCmt; 91 | } 92 | 93 | /** 94 | * @return the extensions 95 | */ 96 | public Extensions getExtensions() { 97 | return mExtensions; 98 | } 99 | 100 | public static abstract class Builder { 101 | private Double mLatitude; 102 | private Double mLongitude; 103 | private Double mElevation; 104 | private DateTime mTime; 105 | private String mName; 106 | private String mDesc; 107 | private String mType; 108 | private String mSym; 109 | private String mCmt; 110 | private Extensions mExtensions; 111 | 112 | public Builder setLatitude(Double latitude) { 113 | mLatitude = latitude; 114 | return this; 115 | } 116 | 117 | public Builder setLongitude(Double longitude) { 118 | mLongitude = longitude; 119 | return this; 120 | } 121 | 122 | public Builder setElevation(Double elevation) { 123 | mElevation = elevation; 124 | return this; 125 | } 126 | 127 | public Builder setTime(DateTime time) { 128 | mTime = time; 129 | return this; 130 | } 131 | 132 | public Builder setName(String mame) { 133 | mName = mame; 134 | return this; 135 | } 136 | 137 | public Builder setDesc(String desc) { 138 | mDesc = desc; 139 | return this; 140 | } 141 | 142 | public Builder setType(String type) { 143 | mType = type; 144 | return this; 145 | } 146 | 147 | public Builder setSym(String sym) { 148 | mSym = sym; 149 | return this; 150 | } 151 | public Builder setCmt(String cmt) { 152 | mCmt = cmt; 153 | return this; 154 | } 155 | 156 | public Builder setExtensions(Extensions extensions) { 157 | mExtensions = extensions; 158 | return this; 159 | } 160 | 161 | public abstract Point build(); 162 | } 163 | } 164 | -------------------------------------------------------------------------------- /parser/src/main/java/io/ticofab/androidgpxparser/parser/domain/Route.java: -------------------------------------------------------------------------------- 1 | package io.ticofab.androidgpxparser.parser.domain; 2 | 3 | import java.util.ArrayList; 4 | import java.util.Collections; 5 | import java.util.List; 6 | 7 | public class Route { 8 | private final List mRoutePoints; 9 | private final String mRouteName; 10 | private final String mRouteDesc; 11 | private final String mRouteCmt; 12 | private final String mRouteSrc; 13 | private final Integer mRouteNumber; 14 | private final Link mRouteLink; 15 | private final String mRouteType; 16 | 17 | private Route(Builder builder) { 18 | mRoutePoints = Collections.unmodifiableList(new ArrayList<>(builder.mRoutePoints)); 19 | mRouteName = builder.mRouteName; 20 | mRouteDesc = builder.mRouteDesc; 21 | mRouteCmt = builder.mRouteCmt; 22 | mRouteSrc = builder.mRouteSrc; 23 | mRouteNumber = builder.mRouteNumber; 24 | mRouteLink = builder.mRouteLink; 25 | mRouteType = builder.mRouteType; 26 | } 27 | 28 | public List getRoutePoints() { 29 | return mRoutePoints; 30 | } 31 | 32 | public String getRouteName() { 33 | return mRouteName; 34 | } 35 | 36 | public String getRouteDesc() { 37 | return mRouteDesc; 38 | } 39 | 40 | public String getRouteCmt() { 41 | return mRouteCmt; 42 | } 43 | 44 | public String getRouteSrc() { 45 | return mRouteSrc; 46 | } 47 | 48 | public Integer getRouteNumber() { 49 | return mRouteNumber; 50 | } 51 | 52 | public Link getRouteLink() { 53 | return mRouteLink; 54 | } 55 | 56 | public String getRouteType() { 57 | return mRouteType; 58 | } 59 | 60 | public static class Builder { 61 | private List mRoutePoints; 62 | private String mRouteName; 63 | private String mRouteDesc; 64 | private String mRouteCmt; 65 | private String mRouteSrc; 66 | private Integer mRouteNumber; 67 | private Link mRouteLink; 68 | private String mRouteType; 69 | 70 | public Builder setRoutePoints(List routePoints) { 71 | mRoutePoints = routePoints; 72 | return this; 73 | } 74 | 75 | public Builder setRouteName(String routeName) { 76 | mRouteName = routeName; 77 | return this; 78 | } 79 | 80 | public Builder setRouteDesc(String routeDesc) { 81 | mRouteDesc = routeDesc; 82 | return this; 83 | } 84 | 85 | public Builder setRouteCmt(String routeCmt) { 86 | mRouteCmt = routeCmt; 87 | return this; 88 | } 89 | 90 | public Builder setRouteSrc(String routeSrc) { 91 | mRouteSrc = routeSrc; 92 | return this; 93 | } 94 | 95 | public Builder setRouteNumber(Integer routeNumber) { 96 | mRouteNumber = routeNumber; 97 | return this; 98 | } 99 | 100 | public Builder setRouteLink(Link routeLink) { 101 | mRouteLink = routeLink; 102 | return this; 103 | } 104 | 105 | public Builder setRouteType(String routeType) { 106 | mRouteType = routeType; 107 | return this; 108 | } 109 | 110 | public Route build() { 111 | return new Route(this); 112 | } 113 | } 114 | } 115 | -------------------------------------------------------------------------------- /parser/src/main/java/io/ticofab/androidgpxparser/parser/domain/RoutePoint.java: -------------------------------------------------------------------------------- 1 | package io.ticofab.androidgpxparser.parser.domain; 2 | 3 | /** 4 | * A route point (rtept) element. 5 | */ 6 | public class RoutePoint extends Point { 7 | 8 | private RoutePoint(Builder builder) { 9 | super(builder); 10 | } 11 | 12 | public static class Builder extends Point.Builder { 13 | 14 | @Override 15 | public RoutePoint build() { 16 | return new RoutePoint(this); 17 | } 18 | } 19 | 20 | } 21 | -------------------------------------------------------------------------------- /parser/src/main/java/io/ticofab/androidgpxparser/parser/domain/Track.java: -------------------------------------------------------------------------------- 1 | package io.ticofab.androidgpxparser.parser.domain; 2 | 3 | import java.util.ArrayList; 4 | import java.util.Collections; 5 | import java.util.List; 6 | 7 | public class Track { 8 | private final String mTrackName; 9 | private final List mTrackSegments; 10 | private final String mTrackDesc; 11 | private final String mTrackCmt; 12 | private final String mTrackSrc; 13 | private final Integer mTrackNumber; 14 | private final Link mTrackLink; 15 | private final String mTrackType; 16 | 17 | private Track(Builder builder) { 18 | mTrackName = builder.mTrackName; 19 | mTrackDesc = builder.mTrackDesc; 20 | mTrackCmt = builder.mTrackCmt; 21 | mTrackSrc = builder.mTrackSrc; 22 | mTrackNumber = builder.mTrackNumber; 23 | mTrackSegments = Collections.unmodifiableList(new ArrayList<>(builder.mTrackSegments)); 24 | mTrackLink = builder.mTrackLink; 25 | mTrackType = builder.mTrackType; 26 | } 27 | 28 | public String getTrackName() { 29 | return mTrackName; 30 | } 31 | 32 | public String getTrackDesc() { 33 | return mTrackDesc; 34 | } 35 | 36 | public String getTrackCmt() { 37 | return mTrackCmt; 38 | } 39 | 40 | public String getTrackSrc() { 41 | return mTrackSrc; 42 | } 43 | 44 | public Integer getTrackNumber() { 45 | return mTrackNumber; 46 | } 47 | 48 | public Link getTrackLink() { 49 | return mTrackLink; 50 | } 51 | 52 | public String getTrackType() { 53 | return mTrackType; 54 | } 55 | 56 | public List getTrackSegments() { 57 | return mTrackSegments; 58 | } 59 | 60 | public static class Builder { 61 | private String mTrackName; 62 | private List mTrackSegments; 63 | private String mTrackDesc; 64 | private String mTrackCmt; 65 | private String mTrackSrc; 66 | private Integer mTrackNumber; 67 | private Link mTrackLink; 68 | private String mTrackType; 69 | 70 | public Builder setTrackName(String trackName) { 71 | mTrackName = trackName; 72 | return this; 73 | } 74 | 75 | public Builder setTrackDesc(String trackDesc) { 76 | mTrackDesc = trackDesc; 77 | return this; 78 | } 79 | 80 | public Builder setTrackSegments(List trackSegments) { 81 | mTrackSegments = trackSegments; 82 | return this; 83 | } 84 | 85 | public Builder setTrackCmt(String trackCmt) { 86 | mTrackCmt = trackCmt; 87 | return this; 88 | } 89 | 90 | public Builder setTrackSrc(String trackSrc) { 91 | mTrackSrc = trackSrc; 92 | return this; 93 | } 94 | 95 | public Builder setTrackNumber(Integer trackNumber) { 96 | mTrackNumber = trackNumber; 97 | return this; 98 | } 99 | 100 | public Builder setTrackLink(Link link) { 101 | mTrackLink = link; 102 | return this; 103 | } 104 | 105 | public Builder setTrackType(String type) { 106 | mTrackType = type; 107 | return this; 108 | } 109 | 110 | public Track build() { 111 | return new Track(this); 112 | } 113 | 114 | 115 | } 116 | } 117 | -------------------------------------------------------------------------------- /parser/src/main/java/io/ticofab/androidgpxparser/parser/domain/TrackPoint.java: -------------------------------------------------------------------------------- 1 | package io.ticofab.androidgpxparser.parser.domain; 2 | 3 | /** 4 | * A track point (trkpt) element. 5 | */ 6 | public class TrackPoint extends Point { 7 | 8 | private TrackPoint(Builder builder) { 9 | super(builder); 10 | } 11 | 12 | public static class Builder extends Point.Builder { 13 | 14 | @Override 15 | public TrackPoint build() { 16 | return new TrackPoint(this); 17 | } 18 | } 19 | 20 | } 21 | -------------------------------------------------------------------------------- /parser/src/main/java/io/ticofab/androidgpxparser/parser/domain/TrackSegment.java: -------------------------------------------------------------------------------- 1 | package io.ticofab.androidgpxparser.parser.domain; 2 | 3 | import java.util.ArrayList; 4 | import java.util.Collections; 5 | import java.util.List; 6 | 7 | public class TrackSegment { 8 | private final List mTrackPoints; 9 | 10 | private TrackSegment(Builder builder) { 11 | mTrackPoints = Collections.unmodifiableList(new ArrayList<>(builder.mTrackPoints)); 12 | } 13 | 14 | public List getTrackPoints() { 15 | return mTrackPoints; 16 | } 17 | 18 | public static class Builder { 19 | private List mTrackPoints; 20 | 21 | public Builder setTrackPoints(List trackPoints) { 22 | mTrackPoints = trackPoints; 23 | return this; 24 | } 25 | 26 | public TrackSegment build() { 27 | return new TrackSegment(this); 28 | } 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /parser/src/main/java/io/ticofab/androidgpxparser/parser/domain/WayPoint.java: -------------------------------------------------------------------------------- 1 | package io.ticofab.androidgpxparser.parser.domain; 2 | 3 | /** 4 | * A way point (wpt element). 5 | */ 6 | public class WayPoint extends Point { 7 | 8 | private WayPoint(Builder builder) { 9 | super(builder); 10 | } 11 | 12 | public static class Builder extends Point.Builder { 13 | 14 | @Override 15 | public WayPoint build() { 16 | return new WayPoint(this); 17 | } 18 | } 19 | 20 | } 21 | -------------------------------------------------------------------------------- /settings.gradle: -------------------------------------------------------------------------------- 1 | include ':parser', ':app' --------------------------------------------------------------------------------