├── .editorconfig
├── .github
└── workflows
│ └── gradle.yml
├── .gitignore
├── LICENSE.txt
├── NOTICE.txt
├── README.md
├── RELEASE_NOTES.md
├── build.gradle.kts
├── buildSrc
├── build.gradle.kts
├── lib
│ └── java2html.jar
├── resources
│ └── javadoc
│ │ ├── java.se
│ │ └── element-list
│ │ └── stylesheet.css
└── src
│ └── main
│ ├── java
│ └── io
│ │ └── jenetics
│ │ └── gradle
│ │ ├── Colorizer.java
│ │ ├── ColorizerTask.java
│ │ └── package-info.java
│ └── kotlin
│ ├── Env.kt
│ └── io
│ └── jenetics
│ └── gradle
│ └── dsl
│ └── Extensions.kt
├── gradle
└── wrapper
│ ├── gradle-wrapper.jar
│ └── gradle-wrapper.properties
├── gradlew
├── gradlew.bat
├── jpx
├── build.gradle.kts
└── src
│ ├── main
│ └── java
│ │ ├── io
│ │ └── jenetics
│ │ │ └── jpx
│ │ │ ├── Bounds.java
│ │ │ ├── Copyright.java
│ │ │ ├── DGPSStation.java
│ │ │ ├── Degrees.java
│ │ │ ├── Email.java
│ │ │ ├── Filter.java
│ │ │ ├── Filters.java
│ │ │ ├── Fix.java
│ │ │ ├── Format.java
│ │ │ ├── GPX.java
│ │ │ ├── IO.java
│ │ │ ├── IndentingXMLStreamWriter.java
│ │ │ ├── Instants.java
│ │ │ ├── Latitude.java
│ │ │ ├── Length.java
│ │ │ ├── Link.java
│ │ │ ├── Lists.java
│ │ │ ├── Longitude.java
│ │ │ ├── Metadata.java
│ │ │ ├── NonCloseableInputStream.java
│ │ │ ├── NonCloseableOutputStream.java
│ │ │ ├── NonNullList.java
│ │ │ ├── Person.java
│ │ │ ├── Point.java
│ │ │ ├── Route.java
│ │ │ ├── SerialProxy.java
│ │ │ ├── Speed.java
│ │ │ ├── Strings.java
│ │ │ ├── TimeFormat.java
│ │ │ ├── Track.java
│ │ │ ├── TrackSegment.java
│ │ │ ├── UInt.java
│ │ │ ├── WayPoint.java
│ │ │ ├── XML.java
│ │ │ ├── XMLProvider.java
│ │ │ ├── XMLReader.java
│ │ │ ├── XMLReaders.java
│ │ │ ├── XMLStreamReaderAdapter.java
│ │ │ ├── XMLStreamWriterAdapter.java
│ │ │ ├── XMLWriter.java
│ │ │ ├── XMLWriters.java
│ │ │ ├── format
│ │ │ ├── CompositeFormat.java
│ │ │ ├── ConstFormat.java
│ │ │ ├── Elevation.java
│ │ │ ├── Field.java
│ │ │ ├── Format.java
│ │ │ ├── FormatterException.java
│ │ │ ├── LatitudeDegree.java
│ │ │ ├── LatitudeMinute.java
│ │ │ ├── LatitudeNS.java
│ │ │ ├── LatitudeSecond.java
│ │ │ ├── Location.java
│ │ │ ├── LocationBuilder.java
│ │ │ ├── LocationFormatter.java
│ │ │ ├── LongitudeDegree.java
│ │ │ ├── LongitudeEW.java
│ │ │ ├── LongitudeMinute.java
│ │ │ ├── LongitudeSecond.java
│ │ │ ├── OptionalFormat.java
│ │ │ ├── ParseException.java
│ │ │ ├── Plus.java
│ │ │ └── package-info.java
│ │ │ ├── geom
│ │ │ ├── DoubleAdder.java
│ │ │ ├── Ellipsoid.java
│ │ │ ├── Geoid.java
│ │ │ ├── LengthCollector.java
│ │ │ ├── MathUtils.java
│ │ │ └── package-info.java
│ │ │ └── package-info.java
│ │ └── module-info.java
│ └── test
│ ├── java
│ └── io
│ │ └── jenetics
│ │ └── jpx
│ │ ├── BoundsTest.java
│ │ ├── CopyrightTest.java
│ │ ├── DGPSStationTest.java
│ │ ├── DegreesTest.java
│ │ ├── EmailTest.java
│ │ ├── FiltersTest.java
│ │ ├── FixTest.java
│ │ ├── Formats.java
│ │ ├── GPXTest.java
│ │ ├── IOTest.java
│ │ ├── LatitudeTest.java
│ │ ├── LengthTest.java
│ │ ├── LinkTest.java
│ │ ├── ListsTest.java
│ │ ├── LongitudeTest.java
│ │ ├── MetadataTest.java
│ │ ├── ObjectTester.java
│ │ ├── PersonTest.java
│ │ ├── Randoms.java
│ │ ├── RouteTest.java
│ │ ├── Serialization.java
│ │ ├── SpeedTest.java
│ │ ├── TimeFormatTest.java
│ │ ├── TrackSegmentTest.java
│ │ ├── TrackTest.java
│ │ ├── UIntTest.java
│ │ ├── WayPointTest.java
│ │ ├── XMLProviderTest.java
│ │ ├── XMLStreamTestBase.java
│ │ ├── XMLTest.java
│ │ ├── ZonedDateTimesTest.java
│ │ ├── format
│ │ ├── Fixture.java
│ │ ├── FormatTest.java
│ │ ├── LocationFormatterTest.java
│ │ ├── LocationRandom.java
│ │ ├── ParseTest.java
│ │ ├── PatternTest.java
│ │ └── TokenTest.java
│ │ └── geom
│ │ ├── GeoidTest.java
│ │ └── MathUtilsTest.java
│ └── resources
│ └── io
│ └── jenetics
│ └── jpx
│ ├── Austria.gpx
│ ├── GPX-full.gpx
│ ├── GPX_10-1.gpx
│ ├── GPX_10-2.gpx
│ ├── GPX_10-3.gpx
│ ├── GPX_10-4.gpx
│ ├── GPX_10-5.gpx
│ ├── GPX_10-6.gpx
│ ├── GPX_empty_extensions.gpx
│ ├── GPX_extensions.gpx
│ ├── GPX_invalid_extensions.gpx
│ ├── Gpx-full-sample.gpx
│ ├── ISSUE-151.gpx
│ ├── ISSUE-170.gpx
│ ├── ISSUE-186.gpx
│ ├── ISSUE-38.gpx.xml
│ ├── ISSUE-49.gpx
│ ├── ISSUE-51.gpx
│ ├── ISSUE-77.gpx
│ ├── ISSUE-78.gpx
│ ├── ISSUE-82.gpx
│ ├── ISSUE-86.gpx
│ ├── empty-ele.xml
│ ├── empty-gpx.xml
│ ├── empty-metadata.xml
│ ├── empty-route.xml
│ ├── empty-track-segment.xml
│ ├── empty-track.xml
│ ├── empty-waypoint.xml
│ ├── extensions-gpx.gpx
│ ├── extensions-metadata.gpx
│ ├── extensions-route.gpx
│ ├── extensions-track.gpx
│ ├── extensions-tracksegment.gpx
│ ├── extensions-waypoint.gpx
│ ├── extensions.gpx
│ ├── invalid-latlon.xml
│ ├── io.jenetics.jpx.XMLProvider
│ └── serialization
│ ├── gpx_0.obj
│ ├── gpx_0.xml
│ ├── gpx_1.obj
│ ├── gpx_1.xml
│ ├── gpx_10.obj
│ ├── gpx_10.xml
│ ├── gpx_11.obj
│ ├── gpx_11.xml
│ ├── gpx_12.obj
│ ├── gpx_12.xml
│ ├── gpx_13.obj
│ ├── gpx_13.xml
│ ├── gpx_14.obj
│ ├── gpx_14.xml
│ ├── gpx_2.obj
│ ├── gpx_2.xml
│ ├── gpx_3.obj
│ ├── gpx_3.xml
│ ├── gpx_4.obj
│ ├── gpx_4.xml
│ ├── gpx_5.obj
│ ├── gpx_5.xml
│ ├── gpx_6.obj
│ ├── gpx_6.xml
│ ├── gpx_7.obj
│ ├── gpx_7.xml
│ ├── gpx_8.obj
│ ├── gpx_8.xml
│ ├── gpx_9.obj
│ └── gpx_9.xml
└── settings.gradle.kts
/.editorconfig:
--------------------------------------------------------------------------------
1 | root = true
2 |
3 | [*]
4 | charset = utf-8
5 | indent_style = tab
6 | indent_size = 4
7 | tab_width = 4
8 |
9 | [*.{java,gradle,groovy,kt,kts}]
10 | trim_trailing_whitespace = true
11 | insert_final_newline = true
12 |
--------------------------------------------------------------------------------
/.github/workflows/gradle.yml:
--------------------------------------------------------------------------------
1 | name: JPX Build
2 |
3 | on:
4 | push:
5 | branches:
6 | - master
7 | - releases/*
8 | - issues/*
9 | pull_request:
10 | branches:
11 | - master
12 | - releases/*
13 |
14 | jobs:
15 | build:
16 | runs-on: ${{ matrix.os }}
17 | strategy:
18 | matrix:
19 | os: [ ubuntu-latest, macos-latest ]
20 | java-version: [ 17, 21, 23 ]
21 | steps:
22 | - uses: actions/checkout@v2
23 |
24 | - name: Set up JDK ${{ matrix.java-version }} on ${{ matrix.os }}
25 | uses: actions/setup-java@v2
26 | with:
27 | java-version: ${{ matrix.java-version }}
28 | distribution: 'zulu'
29 | - name: Build with Gradle
30 | run: ./gradlew build --stacktrace --info
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | # Created by .ignore support plugin (hsz.mobi)
2 | ### Java template
3 | *.class
4 |
5 | # BlueJ files
6 | *.ctxt
7 |
8 | # Mobile Tools for Java (J2ME)
9 | .mtj.tmp/
10 | out/
11 |
12 | # Package Files #
13 | *.jar
14 | *.war
15 | *.ear
16 |
17 | # virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
18 | hs_err_pid*
19 | ### Gradle template
20 | .gradle
21 | /build/
22 |
23 | # Ignore Gradle GUI config
24 | gradle-app.setting
25 |
26 | # Avoid ignoring Gradle wrapper jar file (.jar files are usually ignored)
27 | !gradle-wrapper.jar
28 |
29 | # Cache of project
30 | .gradletasknamecache
31 |
32 | # # Work around https://youtrack.jetbrains.com/issue/IDEA-116898
33 | # gradle/wrapper/gradle-wrapper.properties
34 |
35 | .idea
36 | build
37 | classes
38 |
39 | */srv/var/dbdata
40 | */srv/var/lib-pgadmin
41 |
42 | # NetBeans.gitignore https://github.com/github/gitignore/blob/master/Global/NetBeans.gitignore
43 | **/nbproject/private/
44 | **/nbproject/Makefile-*.mk
45 | **/nbproject/Package-*.bash
46 | jpx/build/
47 | jpx/bin/
48 | jpx/nbbuild/
49 | jpx/dist/
50 | jpx/nbdist/
51 | .nb-gradle/
52 | .project
53 | .settings/
54 | .classpath
55 | *.iml
--------------------------------------------------------------------------------
/NOTICE.txt:
--------------------------------------------------------------------------------
1 | JPX: Java GPX Algorithm Library
2 | Copyright (c) 20016-2016 Franz Wilhelmstötter
3 |
4 | ===============================================================================
5 | TestNG (http://testng.org).
6 |
7 | ===============================================================================
8 |
9 |
--------------------------------------------------------------------------------
/buildSrc/build.gradle.kts:
--------------------------------------------------------------------------------
1 | import org.jetbrains.kotlin.gradle.dsl.JvmTarget
2 | import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
3 |
4 | /*
5 | * Java GPX Library (@__identifier__@).
6 | * Copyright (c) @__year__@ Franz Wilhelmstötter
7 | *
8 | * Licensed under the Apache License, Version 2.0 (the "License");
9 | * you may not use this file except in compliance with the License.
10 | * You may obtain a copy of the License at
11 | *
12 | * http://www.apache.org/licenses/LICENSE-2.0
13 | *
14 | * Unless required by applicable law or agreed to in writing, software
15 | * distributed under the License is distributed on an "AS IS" BASIS,
16 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17 | * See the License for the specific language governing permissions and
18 | * limitations under the License.
19 | *
20 | * Author:
21 | * Franz Wilhelmstötter (franz.wilhelmstoetter@gmail.com)
22 | */
23 |
24 | /**
25 | * @author Franz Wilhelmstötter
26 | * @since 2.1
27 | * @version 3.2
28 | */
29 | plugins {
30 | `java-gradle-plugin`
31 | `kotlin-dsl`
32 | }
33 |
34 | repositories {
35 | mavenLocal()
36 | gradlePluginPortal()
37 | }
38 |
39 | tasks.withType {
40 | compilerOptions {
41 | jvmTarget.set(JvmTarget.JVM_17)
42 | }
43 | }
44 |
45 | configure {
46 | sourceCompatibility = JavaVersion.VERSION_17
47 | targetCompatibility = JavaVersion.VERSION_17
48 | }
49 |
--------------------------------------------------------------------------------
/buildSrc/lib/java2html.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jenetics/jpx/d14c86706f43695354097e36baf7d89590443cdc/buildSrc/lib/java2html.jar
--------------------------------------------------------------------------------
/buildSrc/src/main/java/io/jenetics/gradle/ColorizerTask.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Java GPX Library (@__identifier__@).
3 | * Copyright (c) @__year__@ Franz Wilhelmstötter
4 | *
5 | * Licensed under the Apache License, Version 2.0 (the "License");
6 | * you may not use this file except in compliance with the License.
7 | * You may obtain a copy of the License at
8 | *
9 | * http://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software
12 | * distributed under the License is distributed on an "AS IS" BASIS,
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | * See the License for the specific language governing permissions and
15 | * limitations under the License.
16 | *
17 | * Author:
18 | * Franz Wilhelmstötter (franz.wilhelmstoetter@gmail.com)
19 | */
20 | package io.jenetics.gradle;
21 |
22 | import java.io.File;
23 | import java.io.IOException;
24 |
25 | import org.gradle.api.DefaultTask;
26 | import org.gradle.api.tasks.InputFile;
27 | import org.gradle.api.tasks.TaskAction;
28 | import org.gradle.api.tasks.TaskExecutionException;
29 |
30 | /**
31 | * @author Franz Wilhelmstötter
32 | * @since 1.4
33 | * @version 6.1
34 | */
35 | public class ColorizerTask extends DefaultTask {
36 |
37 | private File _directory;
38 |
39 | @InputFile
40 | public File getDirectory() {
41 | return _directory;
42 | }
43 |
44 | public void setDirectory(final File directory) {
45 | _directory = directory;
46 | }
47 |
48 | @TaskAction
49 | public void colorize() {
50 | try {
51 | final Colorizer colorizer = new Colorizer(_directory);
52 | colorizer.colorize();
53 |
54 | getLogger().lifecycle(
55 | "Colorizer processed {} files and modified {}.",
56 | colorizer.getProcessed(), colorizer.getModified()
57 | );
58 | } catch (final IOException e) {
59 | throw new TaskExecutionException(this, e);
60 | }
61 | }
62 |
63 | }
64 |
--------------------------------------------------------------------------------
/buildSrc/src/main/java/io/jenetics/gradle/package-info.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Java GPX Library (@__identifier__@).
3 | * Copyright (c) @__year__@ Franz Wilhelmstötter
4 | *
5 | * Licensed under the Apache License, Version 2.0 (the "License");
6 | * you may not use this file except in compliance with the License.
7 | * You may obtain a copy of the License at
8 | *
9 | * http://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software
12 | * distributed under the License is distributed on an "AS IS" BASIS,
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | * See the License for the specific language governing permissions and
15 | * limitations under the License.
16 | *
17 | * Author:
18 | * Franz Wilhelmstötter (franz.wilhelmstoetter@gmail.com)
19 | */
20 |
21 | /**
22 | * @author Franz Wilhelmstötter
23 | * @since 1.4
24 | * @version 1.4
25 | */
26 | package io.jenetics.gradle;
27 |
--------------------------------------------------------------------------------
/buildSrc/src/main/kotlin/Env.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Java GPX Library (@__identifier__@).
3 | * Copyright (c) @__year__@ Franz Wilhelmstötter
4 | *
5 | * Licensed under the Apache License, Version 2.0 (the "License");
6 | * you may not use this file except in compliance with the License.
7 | * You may obtain a copy of the License at
8 | *
9 | * http://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software
12 | * distributed under the License is distributed on an "AS IS" BASIS,
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | * See the License for the specific language governing permissions and
15 | * limitations under the License.
16 | *
17 | * Author:
18 | * Franz Wilhelmstötter (franz.wilhelmstoetter@gmail.com)
19 | */
20 |
21 | import java.time.Year
22 | import java.time.ZonedDateTime
23 | import java.time.format.DateTimeFormatter
24 |
25 | /**
26 | * Common environment values.
27 | */
28 | object Env {
29 | private val NOW: ZonedDateTime = ZonedDateTime.now()
30 |
31 | private val YEAR: Year = Year.now();
32 |
33 | val COPYRIGHT_YEAR = "2016-${YEAR}"
34 |
35 | private val DATE_FORMAT: DateTimeFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm")
36 |
37 | val BUILD_DATE: String = DATE_FORMAT.format(NOW)
38 |
39 | val BUILD_JDK: String = System.getProperty("java.version")
40 |
41 | val BUILD_OS_NAME: String = System.getProperty("os.name")
42 |
43 | val BUILD_OS_ARCH: String = System.getProperty("os.arch")
44 |
45 | val BUILD_OS_VERSION: String = System.getProperty("os.version")
46 |
47 | val BUILD_BY: String = System.getProperty("user.name")
48 |
49 | }
50 |
51 | /**
52 | * Information about the library and author.
53 | */
54 | object JPX {
55 | const val VERSION = "3.2.1"
56 | const val ID = "jpx"
57 | const val NAME = "jpx"
58 | const val GROUP = "io.jenetics"
59 | const val AUTHOR = "Franz Wilhelmstötter"
60 | const val EMAIL = "franz.wilhelmstoetter@gmail.com"
61 | const val URL = "https://github.com/jenetics/jpx"
62 | }
63 |
64 | /**
65 | * Environment variables for publishing to Maven Central.
66 | */
67 | object Maven {
68 | const val SNAPSHOT_URL = "https://oss.sonatype.org/content/repositories/snapshots/"
69 | const val RELEASE_URL = "https://oss.sonatype.org/service/local/staging/deploy/maven2/"
70 |
71 | const val SCM_URL = "https://github.com/jenetics/jpx"
72 | const val SCM_CONNECTION = "scm:git:https://github.com/jenetics/jpx.git"
73 | const val DEVELOPER_CONNECTION = "scm:git:https://github.com/jenetics/jpx.git"
74 | }
75 |
--------------------------------------------------------------------------------
/buildSrc/src/main/kotlin/io/jenetics/gradle/dsl/Extensions.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Java GPX Library (@__identifier__@).
3 | * Copyright (c) @__year__@ Franz Wilhelmstötter
4 | *
5 | * Licensed under the Apache License, Version 2.0 (the "License");
6 | * you may not use this file except in compliance with the License.
7 | * You may obtain a copy of the License at
8 | *
9 | * http://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software
12 | * distributed under the License is distributed on an "AS IS" BASIS,
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | * See the License for the specific language governing permissions and
15 | * limitations under the License.
16 | *
17 | * Author:
18 | * Franz Wilhelmstötter (franz.wilhelmstoetter@gmail.com)
19 | */
20 |
21 | /**
22 | * @author Franz Wilhelmstötter
23 | * @since 3.2
24 | * @version 3.2
25 | */
26 | package io.jenetics.gradle.dsl
27 |
28 | import org.gradle.api.Project
29 | import org.gradle.kotlin.dsl.extra
30 |
31 | /**
32 | * Gets the module name of the project, as configured in the build file.
33 | */
34 | var Project.moduleName: String
35 | get() = if (this.isModule) this.extra.get("moduleName").toString()
36 | else this.name
37 | set(value) = this.extra.set("moduleName", value)
38 |
39 | /**
40 | * Checks if the project is configured as a module.
41 | */
42 | val Project.isModule: Boolean
43 | get() = this.extra.has("moduleName")
44 |
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jenetics/jpx/d14c86706f43695354097e36baf7d89590443cdc/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | distributionBase=GRADLE_USER_HOME
2 | distributionPath=wrapper/dists
3 | distributionUrl=https\://services.gradle.org/distributions/gradle-8.11-all.zip
4 | networkTimeout=10000
5 | validateDistributionUrl=true
6 | zipStoreBase=GRADLE_USER_HOME
7 | zipStorePath=wrapper/dists
8 |
--------------------------------------------------------------------------------
/gradlew.bat:
--------------------------------------------------------------------------------
1 | @rem
2 | @rem Copyright 2015 the original author or authors.
3 | @rem
4 | @rem Licensed under the Apache License, Version 2.0 (the "License");
5 | @rem you may not use this file except in compliance with the License.
6 | @rem You may obtain a copy of the License at
7 | @rem
8 | @rem https://www.apache.org/licenses/LICENSE-2.0
9 | @rem
10 | @rem Unless required by applicable law or agreed to in writing, software
11 | @rem distributed under the License is distributed on an "AS IS" BASIS,
12 | @rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | @rem See the License for the specific language governing permissions and
14 | @rem limitations under the License.
15 | @rem
16 | @rem SPDX-License-Identifier: Apache-2.0
17 | @rem
18 |
19 | @if "%DEBUG%"=="" @echo off
20 | @rem ##########################################################################
21 | @rem
22 | @rem Gradle startup script for Windows
23 | @rem
24 | @rem ##########################################################################
25 |
26 | @rem Set local scope for the variables with windows NT shell
27 | if "%OS%"=="Windows_NT" setlocal
28 |
29 | set DIRNAME=%~dp0
30 | if "%DIRNAME%"=="" set DIRNAME=.
31 | @rem This is normally unused
32 | set APP_BASE_NAME=%~n0
33 | set APP_HOME=%DIRNAME%
34 |
35 | @rem Resolve any "." and ".." in APP_HOME to make it shorter.
36 | for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi
37 |
38 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
39 | set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
40 |
41 | @rem Find java.exe
42 | if defined JAVA_HOME goto findJavaFromJavaHome
43 |
44 | set JAVA_EXE=java.exe
45 | %JAVA_EXE% -version >NUL 2>&1
46 | if %ERRORLEVEL% equ 0 goto execute
47 |
48 | echo. 1>&2
49 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 1>&2
50 | echo. 1>&2
51 | echo Please set the JAVA_HOME variable in your environment to match the 1>&2
52 | echo location of your Java installation. 1>&2
53 |
54 | goto fail
55 |
56 | :findJavaFromJavaHome
57 | set JAVA_HOME=%JAVA_HOME:"=%
58 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe
59 |
60 | if exist "%JAVA_EXE%" goto execute
61 |
62 | echo. 1>&2
63 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 1>&2
64 | echo. 1>&2
65 | echo Please set the JAVA_HOME variable in your environment to match the 1>&2
66 | echo location of your Java installation. 1>&2
67 |
68 | goto fail
69 |
70 | :execute
71 | @rem Setup the command line
72 |
73 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
74 |
75 |
76 | @rem Execute Gradle
77 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %*
78 |
79 | :end
80 | @rem End local scope for the variables with windows NT shell
81 | if %ERRORLEVEL% equ 0 goto mainEnd
82 |
83 | :fail
84 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
85 | rem the _cmd.exe /c_ return code!
86 | set EXIT_CODE=%ERRORLEVEL%
87 | if %EXIT_CODE% equ 0 set EXIT_CODE=1
88 | if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE%
89 | exit /b %EXIT_CODE%
90 |
91 | :mainEnd
92 | if "%OS%"=="Windows_NT" endlocal
93 |
94 | :omega
95 |
--------------------------------------------------------------------------------
/jpx/build.gradle.kts:
--------------------------------------------------------------------------------
1 | import io.jenetics.gradle.dsl.moduleName
2 |
3 | /*
4 | * Java GPX Library (@__identifier__@).
5 | * Copyright (c) @__year__@ Franz Wilhelmstötter
6 | *
7 | * Licensed under the Apache License, Version 2.0 (the "License");
8 | * you may not use this file except in compliance with the License.
9 | * You may obtain a copy of the License at
10 | *
11 | * http://www.apache.org/licenses/LICENSE-2.0
12 | *
13 | * Unless required by applicable law or agreed to in writing, software
14 | * distributed under the License is distributed on an "AS IS" BASIS,
15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 | * See the License for the specific language governing permissions and
17 | * limitations under the License.
18 | *
19 | * Author:
20 | * Franz Wilhelmstötter (franz.wilhelmstoetter@gmail.com)
21 | */
22 |
23 | /**
24 | * @author Franz Wilhelmstötter
25 | * @since 1.0
26 | * @version 2.1
27 | */
28 | plugins {
29 | `java-library`
30 | idea
31 | `maven-publish`
32 | }
33 |
34 | description = "JPX - Java GPX (GPS) Library"
35 |
36 | moduleName = "io.jenetics.jpx"
37 |
38 | dependencies {
39 | testImplementation(libs.assertj)
40 | testImplementation(libs.equalsverifier)
41 | testImplementation(libs.prngine)
42 | testImplementation(libs.testng)
43 | }
44 |
--------------------------------------------------------------------------------
/jpx/src/main/java/io/jenetics/jpx/Filter.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Java GPX Library (@__identifier__@).
3 | * Copyright (c) @__year__@ Franz Wilhelmstötter
4 | *
5 | * Licensed under the Apache License, Version 2.0 (the "License");
6 | * you may not use this file except in compliance with the License.
7 | * You may obtain a copy of the License at
8 | *
9 | * http://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software
12 | * distributed under the License is distributed on an "AS IS" BASIS,
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | * See the License for the specific language governing permissions and
15 | * limitations under the License.
16 | *
17 | * Author:
18 | * Franz Wilhelmstötter (franz.wilhelmstoetter@gmail.com)
19 | */
20 | package io.jenetics.jpx;
21 |
22 | import java.util.List;
23 | import java.util.function.Function;
24 | import java.util.function.Predicate;
25 |
26 | /**
27 | * Filter interface which contains the {@code filter}, {@code map},
28 | * {@code flatMap} and {@code listMap} methods for transforming values from
29 | * type {@code T}.
30 | *
31 | * @param the value type for the transformed objects
32 | * @param the result type of the filtered object
33 | *
34 | * @author Franz Wilhelmstötter
35 | * @version 1.1
36 | * @since 1.1
37 | */
38 | public interface Filter {
39 |
40 | /**
41 | * Return a filter consisting of the elements of this filter that matches
42 | * the given predicate.
43 | *
44 | * @param predicate a non-interfering, stateless predicate to apply to each
45 | * element to determine if it should be included
46 | * @return a new filter
47 | */
48 | Filter filter(final Predicate super T> predicate);
49 |
50 | /**
51 | * Return a filter with the results of applying the given mapper function.
52 | *
53 | * @param mapper a non-interfering, stateless function to apply to each
54 | * element
55 | * @return a new filter
56 | */
57 | Filter map(final Function super T, ? extends T> mapper);
58 |
59 | /**
60 | * Return a filter consisting of the results of replacing each element with
61 | * the contents of the mapped elements.
62 | *
63 | * @param mapper a non-interfering, stateless function to apply to each
64 | * element which produces a list of new values
65 | * @return a new filter
66 | */
67 | Filter flatMap(final Function super T, ? extends List> mapper);
68 |
69 | /**
70 | * Return a filter with the results of the applying given mapper function.
71 | *
72 | * @param mapper a non-interfering, stateless function to apply to the
73 | * existing elements
74 | * @return a new filter
75 | */
76 | Filter listMap(final Function super List, ? extends List> mapper);
77 |
78 | /**
79 | * Return a new object of type {@code R} which contains the elements of the
80 | * applied filter functions.
81 | *
82 | * @return a new object created from the given filter
83 | */
84 | R build();
85 |
86 | }
87 |
--------------------------------------------------------------------------------
/jpx/src/main/java/io/jenetics/jpx/Fix.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Java GPX Library (@__identifier__@).
3 | * Copyright (c) @__year__@ Franz Wilhelmstötter
4 | *
5 | * Licensed under the Apache License, Version 2.0 (the "License");
6 | * you may not use this file except in compliance with the License.
7 | * You may obtain a copy of the License at
8 | *
9 | * http://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software
12 | * distributed under the License is distributed on an "AS IS" BASIS,
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | * See the License for the specific language governing permissions and
15 | * limitations under the License.
16 | *
17 | * Author:
18 | * Franz Wilhelmstötter (franz.wilhelmstoetter@gmail.com)
19 | */
20 | package io.jenetics.jpx;
21 |
22 | import static java.util.Objects.requireNonNull;
23 |
24 | import java.util.Optional;
25 |
26 | /**
27 | * Type of GPS fix. {@code none} means GPS had no fix. To signify "the fix info
28 | * is unknown", leave out {@code Fix} entirely. {@code pps} = military signal
29 | * used.
30 | *
31 | * @author Franz Wilhelmstötter
32 | * @version 1.2
33 | * @since 1.0
34 | */
35 | public enum Fix {
36 |
37 | NONE("none"),
38 | DIM_2("2d"),
39 | DIM_3("3d"),
40 | DGPS("dgps"),
41 | PPS("pps");
42 |
43 | private final String _value;
44 |
45 | Fix(final String value) {
46 | _value = requireNonNull(value);
47 | }
48 |
49 | /**
50 | * Return the string representation of the GPS {@code Fix}. {@code none},
51 | * {@code 2d}. {@code 3d}, {@code dgps} or {@code pps}.
52 | *
53 | * @return the string representation of the GPS {@code Fix}
54 | */
55 | public String getValue() {
56 | return _value;
57 | }
58 |
59 | /**
60 | * Return the {@code Fix} constant for the given fix {@code value}.
61 | *
62 | * @param name the GPS fix names
63 | * @return the GPS fix for the given value, or {@code Optional.empty()} if
64 | * the given {@code name} is invalid
65 | */
66 | public static Optional ofName(final String name) {
67 | return switch (name) {
68 | case "none" -> Optional.of(Fix.NONE);
69 | case "2d" -> Optional.of(Fix.DIM_2);
70 | case "3d" -> Optional.of(Fix.DIM_3);
71 | case "dgps" -> Optional.of(Fix.DGPS);
72 | case "pps" -> Optional.of(Fix.PPS);
73 | default -> Optional.empty();
74 | };
75 | }
76 |
77 | static String format(final Fix fix) {
78 | return fix != null ? fix._value : null;
79 | }
80 |
81 | static Fix parse(final String value) {
82 | final String fix = Strings.trim(value);
83 |
84 | return fix != null
85 | ? Fix.ofName(fix).orElseThrow(() ->
86 | new IllegalArgumentException(String.format(
87 | "Invalid value for: '%s'.", fix)))
88 | : null;
89 | }
90 | }
91 |
--------------------------------------------------------------------------------
/jpx/src/main/java/io/jenetics/jpx/Format.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Java GPX Library (@__identifier__@).
3 | * Copyright (c) @__year__@ Franz Wilhelmstötter
4 | *
5 | * Licensed under the Apache License, Version 2.0 (the "License");
6 | * you may not use this file except in compliance with the License.
7 | * You may obtain a copy of the License at
8 | *
9 | * http://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software
12 | * distributed under the License is distributed on an "AS IS" BASIS,
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | * See the License for the specific language governing permissions and
15 | * limitations under the License.
16 | *
17 | * Author:
18 | * Franz Wilhelmstötter (franz.wilhelmstoetter@gmail.com)
19 | */
20 | package io.jenetics.jpx;
21 |
22 | import static java.lang.String.format;
23 |
24 | import java.net.URI;
25 | import java.net.URISyntaxException;
26 | import java.time.Duration;
27 | import java.time.Year;
28 |
29 | /**
30 | * Some helper methods for parsing GPS values.
31 | *
32 | * @author Franz Wilhelmstötter
33 | * @version 1.2
34 | * @since 1.0
35 | */
36 | final class Format {
37 |
38 | private Format() {
39 | }
40 |
41 | static Double parseDouble(final String value) {
42 | final String d = Strings.trim(value);
43 | return d != null ? Double.parseDouble(d) : null;
44 | }
45 |
46 | /**
47 | * Convert the given {@code object} into a duration value. If the
48 | * {@code object} is {@code null}, {@code null} is returned.
49 | *
50 | * @param value the object to convert
51 | * @return the converted object
52 | */
53 | static Duration parseDuration(final String value) {
54 | final String duration = Strings.trim(value);
55 | return duration != null
56 | ? Duration.ofSeconds(Long.parseLong(duration))
57 | : null;
58 | }
59 |
60 | static String toDurationString(final Duration duration) {
61 | return duration != null ? Long.toString(duration.getSeconds()) : null;
62 | }
63 |
64 | /**
65 | * Convert the given {@code object} into a year value. If the
66 | * {@code object} is {@code null}, {@code null} is returned.
67 | *
68 | * @param value the string value to parse
69 | * @return the converted object
70 | */
71 | static Year parseYear(final String value) {
72 | final String year = Strings.trim(value);
73 | return year != null ? Year.of(Integer.parseInt(year)) : null;
74 | }
75 |
76 | static String toYearString(final Year year) {
77 | return year != null ? Integer.toString(year.getValue()) : null;
78 | }
79 |
80 | /**
81 | * Convert the given {@code object} into a URI value. If the
82 | * {@code object} is {@code null}, {@code null} is returned.
83 | *
84 | * @param value the string to convert
85 | * @return the converted object
86 | */
87 | static URI parseURI(final String value) {
88 | try {
89 | final String uri = Strings.trim(value);
90 | return uri != null ? new URI(uri) : null;
91 | } catch (URISyntaxException e) {
92 | throw new IllegalArgumentException(format(
93 | "Invalid URI value: '%s'.", value
94 | ));
95 | }
96 | }
97 |
98 | static String toUriString(final URI uri) {
99 | return uri != null ? uri.toString() : null;
100 | }
101 |
102 | static String toIntString(final Number number) {
103 | return number != null ? Integer.toString(number.intValue()) : null;
104 | }
105 |
106 | }
107 |
--------------------------------------------------------------------------------
/jpx/src/main/java/io/jenetics/jpx/Instants.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Java GPX Library (@__identifier__@).
3 | * Copyright (c) @__year__@ Franz Wilhelmstötter
4 | *
5 | * Licensed under the Apache License, Version 2.0 (the "License");
6 | * you may not use this file except in compliance with the License.
7 | * You may obtain a copy of the License at
8 | *
9 | * http://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software
12 | * distributed under the License is distributed on an "AS IS" BASIS,
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | * See the License for the specific language governing permissions and
15 | * limitations under the License.
16 | *
17 | * Author:
18 | * Franz Wilhelmstötter (franz.wilhelmstoetter@gmail.com)
19 | */
20 | package io.jenetics.jpx;
21 |
22 | import java.io.DataInput;
23 | import java.io.DataOutput;
24 | import java.io.IOException;
25 | import java.time.Instant;
26 |
27 | /**
28 | * @author Franz Wilhelmstötter
29 | * @version 3.0
30 | * @since 1.2
31 | */
32 | final class Instants {
33 |
34 | private Instants() {
35 | }
36 |
37 | static void write(final Instant time, final DataOutput out)
38 | throws IOException
39 | {
40 | IO.writeLong(time.getEpochSecond(), out);
41 | IO.writeInt(time.getNano(), out);
42 | }
43 |
44 | static Instant read(final DataInput in) throws IOException {
45 | final var seconds = IO.readLong(in);
46 | final var nanos = IO.readInt(in);
47 | return Instant.ofEpochSecond(seconds, nanos);
48 | }
49 |
50 | }
51 |
--------------------------------------------------------------------------------
/jpx/src/main/java/io/jenetics/jpx/Lists.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Java GPX Library (@__identifier__@).
3 | * Copyright (c) @__year__@ Franz Wilhelmstötter
4 | *
5 | * Licensed under the Apache License, Version 2.0 (the "License");
6 | * you may not use this file except in compliance with the License.
7 | * You may obtain a copy of the License at
8 | *
9 | * http://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software
12 | * distributed under the License is distributed on an "AS IS" BASIS,
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | * See the License for the specific language governing permissions and
15 | * limitations under the License.
16 | *
17 | * Author:
18 | * Franz Wilhelmstötter (franz.wilhelmstoetter@gmail.com)
19 | */
20 | package io.jenetics.jpx;
21 |
22 | import static java.util.Objects.requireNonNull;
23 |
24 | import java.util.Collection;
25 | import java.util.HashSet;
26 | import java.util.Iterator;
27 | import java.util.List;
28 | import java.util.Objects;
29 | import java.util.Set;
30 |
31 | /**
32 | * Helper methods for handling lists. All method handles null values correctly.
33 | *
34 | * @author Franz Wilhelmstötter
35 | * @version 2.0
36 | * @since 1.0
37 | */
38 | final class Lists {
39 |
40 | private Lists() {
41 | }
42 |
43 | static List copyOf(final List extends T> list) {
44 | return list == null ? List.of() : List.copyOf(list);
45 | }
46 |
47 | static void copyTo(
48 | final List extends T> source,
49 | final List super T> target
50 | ) {
51 | requireNonNull(target);
52 | if (source != null) {
53 | source.forEach(Objects::requireNonNull);
54 | }
55 |
56 | target.clear();
57 | if (source != null) {
58 | target.addAll(source);
59 | }
60 | }
61 |
62 | static int hashCode(final List> list) {
63 | return list != null
64 | ? 17*list.stream().mapToInt(Objects::hashCode).sum() + 31
65 | : 0;
66 | }
67 |
68 | static boolean equals(final List> b, final List> a) {
69 | boolean result = false;
70 | if (a != null) {
71 | if (b != null) {
72 | result = a.size() == b.size();
73 | if (result) {
74 | result = a.isEmpty()|| containsAll(a, b);
75 | }
76 | }
77 | } else {
78 | result = b == null;
79 | }
80 |
81 | return result;
82 | }
83 |
84 | private static boolean containsAll(final Collection> a, final Collection> b) {
85 | final Iterator> ita = a.iterator();
86 | final Set